test: the notifications view model is built inside each test, after the test Main dispatcher is set (#6275)
release / govulncheck (push) Successful in 18s
release / web (push) Successful in 1m22s
release / go (push) Successful in 1m39s
release / integration (push) Successful in 5m12s
release / android (push) Successful in 5m23s
release / Build signed APK (releases and dev) (push) Successful in 5m42s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 27s
release / Verify release artifacts (tag releases only) (push) Skipped

Built as a property initializer it ran at class construction, before
MainDispatcherExtension's beforeEach, so viewModelScope.launch in init hit
the missing Main dispatcher. Its uncaught exceptions also failed the next
coroutine test in the JVM (RetryTransientIoTest).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 09:49:22 -04:00
co-authored by Claude Opus 5.5
parent f381622d20
commit eac320c8d7
@@ -24,7 +24,8 @@ class NotificationsViewModelTest {
private val network: NetworkStatusController = mockk {
every { state } returns MutableStateFlow(ServerHealth.Healthy)
}
private val viewModel = NotificationsViewModel(repository, network)
// Lazy: built inside each test, after the extension has swapped in the test Main dispatcher.
private val viewModel by lazy { NotificationsViewModel(repository, network) }
private fun row(id: String, read: Boolean) = CachedNotificationEntity(
id = id,