* fix(#478): rework default login to use unified ConnectionProfile model - AuthManager: drop legacy auth_token path; getToken/setToken now delegate to the selected profile (profile token only, no global fallback) - setHost/setPort always write the selected profile (no top-level host/port branch) - Add DEFAULT_PROFILE_ID + ensureDefaultProfile()/ensureDefaultSelected() so the selected profile is never null; ensureDefaultSelected() only falls back when nothing is selected (never clobbers an existing choice); ensureDefaultProfile() only injects a Default profile on fresh install, never into an existing list - One-time migration folds legacy standalone auth_token into the Default profile, batched into a single SharedPreferences transaction (guarded by legacy_default_migrated) - ConnectViewModel.connect() persists via setToken/setHost/setPort (delegate to the selected profile) — keeps the existing persistence contract - Connect/Settings: remove the '(none)'/standalone profile option; deleteProfile falls back to Default profile instead of null selection - Update AuthManagerTest/ConnectViewModelTest to the unified model; fix test stub ordering + migration re-init; remove dead connect_profile_none / settings_profile_none strings Closes #478 * fix: stub AuthManager.ensureDefaultSelected() in E2eIntegrationTest The #478 ConnectViewModel.connect() success branch now calls AuthManager.ensureDefaultSelected() on the non-saveProfile path. E2eIntegrationTest.setUp() mocks AuthManager as a non-relaxed mockkObject but never stubs that method, so the unstubbed call throws MockKException inside viewModelScope.launch, leaving connectionSuccess unset and failing 3 tests: - testFullUserSessionFlow - testConnectViewModel_onPairingString_base64Format - testConnectViewModel_onPairingString_urlFormat Add the missing stub. Verified locally: full suite 322/322 passing. --------- Co-authored-by: ronia <ronia@m57>
This commit is contained in:
1 parent
b65d0297e0
commit
aa59e704a4
11 files changed
+229
-155
No files matched your search
@@ -410,21 +410,6 @@ class ConnectViewModelTest {
|
||||
verify { AuthManager.setSelectedProfileId("test-id") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSelectProfile_null_clearsState() {
|
||||
val viewModel = ConnectViewModel(mockApp)
|
||||
viewModel.selectProfile(null)
|
||||
|
||||
val state = viewModel.uiState.value
|
||||
assertEquals("", state.profileName)
|
||||
assertEquals("127.0.0.1", state.host)
|
||||
assertEquals("9119", state.port)
|
||||
assertEquals("", state.token)
|
||||
assertNull(state.selectedProfile)
|
||||
|
||||
verify { AuthManager.setSelectedProfileId(null) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConnect_saveProfile_savesAndSelects() =
|
||||
runTest {
|
||||
@@ -525,7 +510,7 @@ class ConnectViewModelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testConnect_withoutSaveProfile_clearsSelectedProfile() =
|
||||
fun testConnect_withoutSaveProfile_persistsToDefaultProfile() =
|
||||
runTest {
|
||||
val viewModel = ConnectViewModel(mockApp)
|
||||
viewModel.onTokenChange("standalone-token")
|
||||
@@ -548,9 +533,9 @@ class ConnectViewModelTest {
|
||||
viewModel.connect()
|
||||
advanceUntilIdle()
|
||||
|
||||
verify { AuthManager.setSelectedProfileId(null) }
|
||||
verify { AuthManager.setToken("standalone-token") }
|
||||
verify { AuthManager.setHost("10.0.0.1") }
|
||||
verify { AuthManager.setPort(9119) }
|
||||
verify(exactly = 0) { AuthManager.saveConnectionProfiles(any()) }
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user