Modern Apps git

← Modern-Apps.git

communicate: wait for group members in real time (#tests)

Commit
d7724991e394ee5db4ddb307efbe618ee72e0c5d
Author
Vayun Mathur <[email protected]>
When
2026-11-16 18:25 UTC (19 days ago)
Parents
9f25d77
groupMembersAddToExistingConversationPersistsWhenCapableGateFails
hit ComposeTimeout 30000ms in CI: the members screen loads via
produceState on Dispatchers.IO and resumes on the paused
Robolectric main looper, which waitUntil alone does not pump
through reliably on a loaded box. waitForText now polls in
step-counted real time, idling the main looper per poll, and
the test warms the bundled SQLite driver/DAO on its own
thread before composing (first-use driver init inside the
screen's IO query was the slowest step on a cold box).

Reproduced under TZ=UTC with 4 workers in the combined module
run; verified green in three consecutive combined runs plus a
TZ=America/New_York spot check.

Diff

communicate/src/test/java/com/vayunmathur/communicate/rcs/RcsSlice3Pass2UiTest.kt
diff --git a/communicate/src/test/java/com/vayunmathur/communicate/rcs/RcsSlice3Pass2UiTest.kt b/communicate/src/test/java/com/vayunmathur/communicate/rcs/RcsSlice3Pass2UiTest.ktindex c91b371cc0..7646e86413 100644--- a/communicate/src/test/java/com/vayunmathur/communicate/rcs/RcsSlice3Pass2UiTest.kt+++ b/communicate/src/test/java/com/vayunmathur/communicate/rcs/RcsSlice3Pass2UiTest.kt@@ -68,8 +68,19 @@ class RcsSlice3Pass2UiTest {         // Idle Robolectric's paused main looper per poll: the screens load         // through Dispatchers.Main, whose queued resumes waitUntil alone         // does not run, so the text could sit unlanded past the timeout.-        rule.waitUntil(timeoutMs) {+        // Step counted in real time (parkNanos) rather than waitUntil's+        // clock: on the loaded CI box the compose test clock and the+        // paused looper starve each other and 30s of waitUntil can elapse+        // without the IO resume ever being pumped through.+        var steps = 0+        val maxSteps = (timeoutMs / 25).toInt()+        while (steps++ < maxSteps) {             org.robolectric.Shadows.shadowOf(android.os.Looper.getMainLooper()).idle()+            if (rule.onAllNodesWithText(text).fetchSemanticsNodes().isNotEmpty()) return+            try { Thread.sleep(25) } catch (_: InterruptedException) { }+        }+        // Final direct check so the failure message names the missing text.+        rule.waitUntil(1_000) {             rule.onAllNodesWithText(text).fetchSemanticsNodes().isNotEmpty()         }     }@@ -252,6 +263,13 @@ class RcsSlice3Pass2UiTest {         testDb.conversationDao().upsert(             RcsConversation(remoteId = "conv-ui-2", participants = "+15552002002"),         )+        // Warm the bundled SQLite driver + DAO on this thread before+        // composing: first-use driver init inside the screen's IO query+        // is the slowest step on a cold, loaded CI box.+        assertEquals(+            "+15552002002",+            testDb.conversationDao().getConversation("conv-ui-2")?.participants,+        )         rule.setContent {             DynamicTheme(darkTheme = false) {                 RcsGroupMembersScreen(conversationId = "conv-ui-2", onBack = {})