fix(#478): rework default login to use unified ConnectionProfile model (#482)

* 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:
M57andronia authored and GitHub committed 2026-07-07 20:50:53 +03:00
1 parent b65d0297e0
commit aa59e704a4
11 files changed
+229 -155

No files matched your search

@@ -107,6 +107,7 @@ class E2eIntegrationTest {
// so only resources used by ConnectViewModel + enum labels need stubs.
every { mockApp.getString(any<Int>()) } returns ""
every { AuthManager.setSelectedProfileId(any()) } returns Unit
every { AuthManager.ensureDefaultSelected() } returns Unit
every { AuthManager.getProfileToken(any()) } returns null
every { AuthManager.setProfileToken(any(), any()) } returns Unit
every { AuthManager.saveConnectionProfiles(any()) } returns Unit