everysync: wait for the account mirror in the error-text test
- Commit
f3c1624ec866602fcadfe6784e2b5cbfc25b4645- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-07 20:00 UTC (28 days ago)
- Parents
f2cafce
syncErrorTextMapsAbortCodes upserted an account with a sync error and immediately read it back. AccountStore.get reads DataStoreUtils' asynchronously-updated mirror, so on the loaded CI box the just-committed lastSyncError was not yet visible and syncErrorText returned null for pull_transport_failed (run 8f356294). The test now waits until AccountStore itself sees each written error before asserting on syncErrorText, both in the code loop and in the distinct-strings check. No production change. Verified locally on devvm24805: :everysync:testDevUnitTest for ViewModel2Test green.
Diff
everysync/src/test/java/com/vayunmathur/everysync/ViewModel2Test.kt
diff --git a/everysync/src/test/java/com/vayunmathur/everysync/ViewModel2Test.kt b/everysync/src/test/java/com/vayunmathur/everysync/ViewModel2Test.ktindex 89140357ae..418e0cdda7 100644--- a/everysync/src/test/java/com/vayunmathur/everysync/ViewModel2Test.kt+++ b/everysync/src/test/java/com/vayunmathur/everysync/ViewModel2Test.kt@@ -76,14 +76,23 @@ class ViewModel2Test { "local_read_failed" to true, "relay_unavailable" to true, "some raw error" to false, )) { store.upsert(AccountConfig("err-acc", "e2ee", emptySet(), lastSyncError = "vault sync aborted: $code (notes)"))+ // AccountStore.get reads DataStoreUtils' asynchronously-updated+ // mirror, so the just-committed error may not be visible yet on+ // a loaded box; wait until the store itself sees this write.+ assertTrue(+ await { store.get("err-acc")?.lastSyncError?.contains(code) == true },+ "store never showed $code: ${store.get("err-acc")?.lastSyncError}",+ ) val text = vm.syncErrorText("err-acc") assertNotNull(text, code) if (!expectDistinct) assertEquals("vault sync aborted: some raw error (notes)", text) } // Distinct codes map to distinct user-facing strings store.upsert(AccountConfig("err-acc", "e2ee", emptySet(), lastSyncError = "pull_transport_failed"))+ assertTrue(await { store.get("err-acc")?.lastSyncError == "pull_transport_failed" }) val a = vm.syncErrorText("err-acc") store.upsert(AccountConfig("err-acc", "e2ee", emptySet(), lastSyncError = "log_undecryptable"))+ assertTrue(await { store.get("err-acc")?.lastSyncError == "log_undecryptable" }) assertTrue(a != vm.syncErrorText("err-acc")) Unit } }