From 6535aeef1a72249bf8adffb1b356284ad09b465b Mon Sep 17 00:00:00 2001 From: KremeCN <3265494849@qq.com> Date: Mon, 24 Aug 2026 21:50:00 +0800 Subject: [PATCH] fix: require real ABSDK success before authentication --- android/app/src/main/AndroidManifest.xml | 2 + .../ui/session/AppSessionViewModelTest.kt | 126 ++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 android/app/src/test/kotlin/com/flagship/abox/manager/ui/session/AppSessionViewModelTest.kt diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index f3b7d57..5b9189a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,9 +1,11 @@ + = + remote.observeSession(otherProfileId) + } + val viewModel = AppSessionViewModel(newCoordinator(crossProfileGateway), profiles) + backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) { + viewModel.uiState.collect {} + } + advanceUntilIdle() + + assertTrue(viewModel.uiState.value is AppSessionUiState.Login) + } + + @Test + fun successfulAboxLoginAuthenticatesActiveProfile() = runTest { + saveAndActivateAboxProfile(aboxProfileId) + val coordinator = newCoordinator() + val viewModel = AppSessionViewModel(coordinator, profiles) + backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) { + viewModel.uiState.collect {} + } + advanceUntilIdle() + + coordinator.login( + profileId = aboxProfileId, + credentials = credentials, + rememberUsername = false, + autoLogin = false, + ) + advanceUntilIdle() + + val state = viewModel.uiState.value + assertTrue(state is AppSessionUiState.Authenticated) + } + + private companion object { + val aboxProfileId = ProviderProfileId("abox-default") + val otherProfileId = ProviderProfileId("abox-other") + } +}