From a80a6b8b0f355c537fb37720ab4ba2eb3051ffe8 Mon Sep 17 00:00:00 2001 From: Sedat Qaja Date: Mon, 19 Oct 2026 09:18:08 +0200 Subject: [PATCH] fix(healthchat): keep legacy accounts on the typed account provider --- .../HealthChat/HealthChatAppSettingsHook.swift | 2 +- ...uthenticationStartScreenViewModelTests.swift | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ElementX/Sources/AppHooks/HealthChat/HealthChatAppSettingsHook.swift b/ElementX/Sources/AppHooks/HealthChat/HealthChatAppSettingsHook.swift index 81ef70f2d..0bcbcbd75 100644 --- a/ElementX/Sources/AppHooks/HealthChat/HealthChatAppSettingsHook.swift +++ b/ElementX/Sources/AppHooks/HealthChat/HealthChatAppSettingsHook.swift @@ -15,7 +15,7 @@ import Foundation /// - Legacy `element.io` help/encryption/copyright URLs are passed through unchanged for now. struct HealthChatAppSettingsHook: AppSettingsHookProtocol { func configure(_ appSettings: AppSettings) -> AppSettings { - appSettings.override(accountProviders: ["healthchat.ch"], + appSettings.override(accountProviders: [.generic("healthchat.ch")], allowOtherAccountProviders: false, hideBrandChrome: false, pushGatewayBaseURL: "https://sygnal.healthchat.ch", diff --git a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift index ea5c2d9bd..0662e02d3 100644 --- a/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift +++ b/UnitTests/Sources/AuthenticationStartScreenViewModelTests.swift @@ -225,6 +225,23 @@ final class AuthenticationStartScreenViewModelTests { #expect(account == classicAppAccount) } + @Test + func healthChatProviderAllowsLegacyAccount() async { + // Given the account providers HealthChat ships with and an account from the legacy HealthChat app. + let classicAppAccount = makeClassicAppAccount(serverName: "healthchat.ch", + homeserverURL: "https://matrix.healthchat.ch") + appSettings = HealthChatAppSettingsHook().configure(appSettings) + await setupViewModel(classicAppAccount: classicAppAccount) + + // Then the legacy account must still be offered for migration. A silent failure here logs every + // updating user out of the migration path, so the real hook values are tested, not a stand-in. + guard case .welcomeBack(let account) = context.viewState.classicAppMode else { + Issue.record("Expected classicAppMode to be .welcomeBack") + return + } + #expect(account == classicAppAccount) + } + @Test func singleProviderWithDisallowedClassicAppAccount() async { // Given a view model for an app that only allows a single provider that does NOT match the Classic account's server.