Modern Apps git

← Modern-Apps.git

astronomy: deflake object detail page tests (125 tests)

Commit
a3393f03937492ca17f3adcf374b0bad039ee813
Author
Vayun Mathur <[email protected]>
When
2026-11-15 03:32 UTC (21 days ago)
Parents
24ad0c6
AstronomyPagesTest 'object detail page renders the sun' failed
in the loaded full check on assertExists. The test waited only
for catalogReady, then set a manual location, selected the Sun
and composed ObjectDetailPage - but the detail is resolved from
visibleSky, which is recomputed on Dispatchers.Default once the
observer location lands in the combine. Until that emission the
snapshot has no Sun, the page renders 'object not found', and
the assertExists on the first frames races the recompute; under
load the Default-dispatcher work is what gets starved.

The test now waits for visibleSky to actually contain the Sun
before composing, and polls for the Sun node afterwards instead
of asserting on the first frame, since the page collects
visibleSky asynchronously even once composed. The assertion
itself (a node with text Sun exists on the SUN detail page) is
unchanged.

Verified: before, the failure appeared in the loaded 128-worker
full check while isolated reruns passed (3/3 isolated baseline
runs green with --no-build-cache). After: 5 consecutive green
:astronomy:testDevUnitTest runs, 3 isolated at
--max-workers=32 and 2 under load at --max-workers=64 on a
busy host (125 tests).

Diff

astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt
diff --git a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.ktindex 0f25d5472b..dc44ad11a1 100644--- a/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt+++ b/astronomy/src/test/java/com/vayunmathur/astronomy/ui/AstronomyPagesTest.kt@@ -47,8 +47,21 @@ class AstronomyPagesTest {         await("catalog") { vm.catalogReady.value }         vm.setManualLocation(37.0, -122.0)         vm.selectObject("SUN")+        // The detail resolves from visibleSky, which is recomputed on+        // Dispatchers.Default after the location lands: catalogReady alone+        // does not mean the Sun is in the sky snapshot yet. Composing+        // before that emission renders "object not found" and the+        // assertExists below races the recompute under load.+        await("visible sun") { vm.visibleSky.value.sun != null }         rule.setContent { ObjectDetailPage(backStack = stack(), viewModel = vm, objectId = "SUN") }-        rule.onNodeWithText("Sun", substring = true).assertExists()+        // The page collects visibleSky asynchronously even once composed,+        // so poll for the node rather than asserting on the first frame.+        await("sun node") {+            runCatching {+                rule.onNodeWithText("Sun", substring = true).assertExists()+                true+            }.getOrDefault(false)+        }     }      @Test fun `settings page renders through the view model`() {