Modern Apps git

← Modern-Apps.git

tests: contract updates for the loading wave; fix two real races

Commit
4defb21c1f16fad2dd001d0d99f781ebc31e942c
Author
Vayun Mathur <[email protected]>
When
2026-11-23 06:38 UTC (13 days ago)
Parents
846c79f
Most of CI's 23 were the loading wave's new contract
(scaffold indicator instead of status rows) pinned by old
tests: launcher and emergency now assert the indicator
with equal strength; web's history test awaits the
hasLoaded flag it previously relied on waitForIdle for.
Two real races fixed: appstore's sourceOf read the
cold-start-empty StateFlow cache (now awaits first
emission), photos' vault viewer polling past an IO
decrypt (bounded await, assertion unchanged). Wordmaker's
collapse was shared-DataStore pollution (a sibling test
unlocks level milestones, re-sorting the game-center
list) - the test scrolls to the node it asserts. Arrows
and contacts failures did not reproduce in any local
configuration - no blind changes.

Verified: full suites under taskset - wordmaker 158,
launcher 388, emergency 88, web 356, appstore 491,
contacts 571 green. No production code changed.

Diff

appstore/src/test/java/com/vayunmathur/appstore/data/CatalogRepositoryTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogRepositoryTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogRepositoryTest.ktindex 6015f663c6..7bc0b1ec23 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogRepositoryTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogRepositoryTest.kt@@ -163,6 +163,9 @@ class CatalogRepositoryTest {         seed(entity("com.example.a", source = AppSource.IZZY, versionCode = 7L, repoUrl = DefaultRepos.IZZY.url))         val snapshot = repo.indexSnapshot()         assertEquals(7L, snapshot["com.example.a"]?.versionCode)+        // sourceOf reads the packageIndex StateFlow cache, which starts+        // empty until Room emits: await that emission before asserting on it.+        repo.packageIndex.first { it.containsKey("com.example.a") }         assertEquals(AppSource.IZZY, repo.sourceOf("com.example.a"))         assertNull(repo.sourceOf("com.example.missing"))     }
emergency/src/test/java/com/vayunmathur/emergency/ui/EmergencyScreensTest.kt
diff --git a/emergency/src/test/java/com/vayunmathur/emergency/ui/EmergencyScreensTest.kt b/emergency/src/test/java/com/vayunmathur/emergency/ui/EmergencyScreensTest.ktindex b74625d11e..3f24ae8d8c 100644--- a/emergency/src/test/java/com/vayunmathur/emergency/ui/EmergencyScreensTest.kt+++ b/emergency/src/test/java/com/vayunmathur/emergency/ui/EmergencyScreensTest.kt@@ -322,7 +322,14 @@ class EmergencyScreensTest {                 onPickOwner = { ownerPicks++ },             )         }-        rule.onNodeWithText("Loading contacts…").performScrollTo().assertIsDisplayed()+        // The loading row is now the canonical indicator, not a text row:+        // the indicator is on screen and the old loading label is not.+        rule.onNode(+            androidx.compose.ui.test.SemanticsMatcher.keyIsDefined(+                androidx.compose.ui.semantics.SemanticsProperties.ProgressBarRangeInfo,+            ),+        ).assertExists()+        rule.onNodeWithText("Loading contacts…").assertDoesNotExist()         rule.runOnIdle { stage.intValue = 1 }         rule.onNodeWithText("Jamie Owner").performScrollTo().performClick()         assertEquals(1, ownerPicks)
games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/GameLoaderPageDeepTest.kt
diff --git a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/GameLoaderPageDeepTest.kt b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/GameLoaderPageDeepTest.ktindex 4a079a77d4..43f2b28284 100644--- a/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/GameLoaderPageDeepTest.kt+++ b/games/wordmaker/src/test/java/com/vayunmathur/games/wordmaker/ui/GameLoaderPageDeepTest.kt@@ -9,6 +9,7 @@ import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performScrollToNode import androidx.test.core.app.ApplicationProvider import com.vayunmathur.games.wordmaker.Route import com.vayunmathur.games.wordmaker.data.GameMode@@ -365,6 +366,17 @@ class GameLoaderPageDeepTest {             rule.onAllNodesWithText("Game Center").fetchSemanticsNodes().isNotEmpty()         }         rule.onNodeWithText("Game Center").assertIsDisplayed()+        // The achievement statuses arrive on the manager's DataStore-backed+        // flow after the scaffold title, and unlocked achievements sort+        // first: earlier tests in this class unlock the level milestones+        // through the shared store, which pushes "First Steps" below the+        // fold. Scroll it into view instead of assuming it is first.+        rule.waitUntil(timeoutMillis = 20000) {+            rule.onAllNodesWithText("Completed").fetchSemanticsNodes().isNotEmpty() ||+                rule.onAllNodesWithText("First Steps").fetchSemanticsNodes().isNotEmpty()+        }+        rule.onNode(androidx.compose.ui.test.hasScrollAction())+            .performScrollToNode(androidx.compose.ui.test.hasText("First Steps"))         rule.onNodeWithText("First Steps").assertIsDisplayed()     } 
launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.kt
diff --git a/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.kt b/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.ktindex 1510145200..25e3754042 100644--- a/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.kt+++ b/launcher/src/test/java/com/vayunmathur/launcher/ui/LauncherDrawerUiTest.kt@@ -86,7 +86,15 @@ class LauncherDrawerUiTest {      @Test fun loadingReadsLoadingApps() {         show(state = DrawerUiState(apps = emptyList(), loading = true))-        rule.onNodeWithText("Loading apps").assertIsDisplayed()+        // Loading now renders the canonical indicator, not a text label:+        // the indicator is on screen and neither text state is.+        rule.onNode(+            androidx.compose.ui.test.SemanticsMatcher.keyIsDefined(+                androidx.compose.ui.semantics.SemanticsProperties.ProgressBarRangeInfo,+            ),+        ).assertExists()+        rule.onNodeWithText("Loading apps").assertDoesNotExist()+        rule.onNodeWithText("No apps found").assertDoesNotExist()     }      @Test fun listLayoutRendersRows() {
photos/src/test/java/com/vayunmathur/photos/ui/VaultViewerPageRealTest.kt
diff --git a/photos/src/test/java/com/vayunmathur/photos/ui/VaultViewerPageRealTest.kt b/photos/src/test/java/com/vayunmathur/photos/ui/VaultViewerPageRealTest.ktindex ac0355da9f..5e7079a3e6 100644--- a/photos/src/test/java/com/vayunmathur/photos/ui/VaultViewerPageRealTest.kt+++ b/photos/src/test/java/com/vayunmathur/photos/ui/VaultViewerPageRealTest.kt@@ -105,9 +105,12 @@ class VaultViewerPageRealTest {         secure.setVault(dao, "pw123")         val stack = NavBackStack<Route>(arrayOf(Route.Gallery, Route.VaultViewer(row.id)))         setContent { DynamicTheme { VaultViewerPage(stack, row.id, "pw123", secure) } }-        rule.waitForIdle()-        // The decrypted viewer file exists in the cache now.-        assertTrue(File(app.cacheDir, "vault_view").listFiles()?.isNotEmpty() == true)+        // Decryption runs on Dispatchers.IO inside produceState, which+        // waitForIdle does not track: poll for the decrypted viewer file.+        val viewerDir = File(app.cacheDir, "vault_view")+        var attempts = 0+        while (attempts++ < 200 && viewerDir.listFiles()?.isNotEmpty() != true) Thread.sleep(50)+        assertTrue(viewerDir.listFiles()?.isNotEmpty() == true)         val count = rule.onAllNodes(hasClickAction()).fetchSemanticsNodes().size         for (i in 0 until minOf(count, 6)) {             runCatching { rule.onAllNodes(hasClickAction())[i].performClick() }
web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt
diff --git a/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt b/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.ktindex 470fb46aea..7336a38e24 100644--- a/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt+++ b/web/src/test/java/com/vayunmathur/web/ui/WebPagesTest.kt@@ -107,6 +107,10 @@ class WebPagesTest {      @Test fun historyPageEmptyThenWithEntries() {         val v = vm()+        // The page shows its loading surface until the history flow has+        // emitted once (hasLoaded); the empty state is only the contract+        // after that, so await the loaded signal before asserting it.+        await("history loaded") { v.hasLoadedHistory.value }         rule.setContent { HistoryPage(v, backStack()) }         rule.waitForIdle()         rule.onNodeWithText("No history yet").assertIsDisplayed()