From 78fc5b98fac99a5aa72cb70dea87e939efe2bf2d Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 18 Nov 2026 19:20:57 +0100 Subject: [PATCH] Keep incomplete kept groups in the wizard's course Written-by: Gemini 4 Hydrogen (Antigravity) Written-by: Claude Fable 5.2 --- .../view/compose/wizard/SetupWizardState.kt | 8 +-- .../compose/wizard/SetupWizardStateTest.kt | 59 +++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt index 57775428..e13d7e24 100644 --- a/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt +++ b/app-desktop/src/main/kotlin/kst4contest/view/compose/wizard/SetupWizardState.kt @@ -148,7 +148,7 @@ class SetupWizardState(prefs: ChatPreferences) { val keep = loginSource == WizardSource.KEEP callsign = if (keep) storedCallsign else "" password = if (keep) storedPassword else "" - loginShown = !keep + loginShown = !keep || !loginComplete appliedLoginSource = loginSource } @@ -161,7 +161,7 @@ class SetupWizardState(prefs: ChatPreferences) { secondCategory = if (keep) storedSecondCategory else null // A kept category is the operator's; the suggestion must not replace it. categoryChosenByOperator = keep - stationShown = !keep + stationShown = !keep || !stationComplete appliedStationSource = stationSource } } @@ -210,8 +210,8 @@ class SetupWizardState(prefs: ChatPreferences) { get() = isPlausibleCallsign(callsign) && password.isNotEmpty() private val stationComplete: Boolean - get() = isLocator(locator) && bands.isNotEmpty() && category != null && - (!secondChat || (secondCategory != null && secondCategory != category)) + get() = isLocator(locator) && bands.isNotEmpty() && category in CATEGORY_NUMBERS && + (!secondChat || secondCategory in secondCategoryOptions) /** Whether everything the profile needs to log in is there. */ val mandatoryComplete: Boolean diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt index 2a1e2a8b..fa8780f3 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardStateTest.kt @@ -292,4 +292,63 @@ class SetupWizardStateTest { assertFalse(kept.turnsOffSecondChat) assertFalse(kept.leavesIntegrationsUntouched) } + + @Test + fun keepingAStationWithMissingLocatorKeepsTheSitePageInTheCourse() { + val state = SetupWizardState(duplicatedProfile().apply { setStn_loginLocatorMainCat("") }) + state.chooseStationSource(WizardSource.KEEP) + state.next() + + assertTrue(state.pages.contains(WizardPage.SITE)) + state.name = "Philipp" + state.next() + state.callsign = "DL0TEST" + state.password = "secret" + state.next() + + assertEquals(WizardPage.SITE, state.page) + assertEquals(setOf(WizardBand.B144, WizardBand.B432), state.bands) + assertEquals(2, state.category) + } + + @Test + fun keepingALoginWithMissingPasswordKeepsTheLoginPageInTheCourse() { + val state = SetupWizardState(configuredProfile().apply { setStn_loginPassword("") }) + state.chooseLoginSource(WizardSource.KEEP) + state.chooseStationSource(WizardSource.KEEP) + state.next() + + assertTrue(state.pages.contains(WizardPage.LOGIN)) + assertEquals("DL0TEST", state.callsign) + assertEquals("", state.password) + assertFalse(state.mandatoryComplete) + } + + @Test + fun keepingAnUnknownCategoryIsIncompleteAndKeepsTheSitePage() { + val state = SetupWizardState(configuredProfile().apply { setLoginChatCategoryMain(ChatCategory(13)) }) + state.chooseLoginSource(WizardSource.KEEP) + state.chooseStationSource(WizardSource.KEEP) + state.next() + + assertFalse(state.mandatoryComplete) + assertTrue(state.pages.contains(WizardPage.SITE)) + } + + @Test + fun keepingValidCategoriesOutsideTheBandSuggestionsCompletesAndSkipsSite() { + val state = SetupWizardState( + configuredProfile().apply { + setLoginChatCategoryMain(ChatCategory(7)) + setLoginToSecondChatEnabled(true) + setLoginChatCategorySecond(ChatCategory(9)) + }, + ) + state.chooseLoginSource(WizardSource.KEEP) + state.chooseStationSource(WizardSource.KEEP) + state.next() + + assertTrue(state.mandatoryComplete) + assertFalse(state.pages.contains(WizardPage.SITE)) + } }