Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
test(agent): let startup land before resetting Main in the permission gate test
Durganshue882b72140c4
diff --git a/app/src/test/java/com/gotcha/agent/ChatViewModelPermissionGateTest.kt b/app/src/test/java/com/gotcha/agent/ChatViewModelPermissionGateTest.ktindex 7a71a9e..7ceee0c 100644--- a/app/src/test/java/com/gotcha/agent/ChatViewModelPermissionGateTest.kt+++ b/app/src/test/java/com/gotcha/agent/ChatViewModelPermissionGateTest.kt@@ -1,11 +1,14 @@package com.gotcha.agentimport android.app.Application+import androidx.lifecycle.viewModelScopeimport androidx.test.core.app.ApplicationProviderimport com.gotcha.data.Settingsimport com.gotcha.data.SettingsRepositoryimport com.gotcha.testsupport.FakeAndroidKeyStoreimport kotlinx.coroutines.async+import kotlinx.coroutines.job+import kotlinx.coroutines.joinAllimport kotlinx.coroutines.test.StandardTestDispatcherimport kotlinx.coroutines.test.resetMainimport kotlinx.coroutines.test.runCurrent@@ -50,6 +53,22 @@ class ChatViewModelPermissionGateTest {@Afterfun tearDown() {+ // The runner's startup (chat migration, sample seeding) and the+ // ViewModel's first session listing hop to Dispatchers.IO and come back+ // on Main. Resetting Main while one of them is on its way back trips the+ // test dispatcher's concurrency check — "Dispatchers.Main is used+ // concurrently with setting it" — which failed CI intermittently. A test+ // that never yields only starts that work as runTest finishes, so the+ // race was widest right here. Let it all land first.+ runTest(dispatcher) {+ viewModel.runner.startup.join()+ val work = viewModel.viewModelScope.coroutineContext.job+ while (true) {+ val active = work.children.filter { it.isActive }.toList()+ if (active.isEmpty()) break+ active.joinAll()+ }+ }kotlinx.coroutines.Dispatchers.resetMain()}