mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fix flakey AuthenticationService test. (#4270)
The AppSettings overrides were being propagated.
This commit is contained in:
@@ -13,6 +13,7 @@ import XCTest
|
|||||||
class AuthenticationStartScreenViewModelTests: XCTestCase {
|
class AuthenticationStartScreenViewModelTests: XCTestCase {
|
||||||
var clientBuilderFactory: AuthenticationClientBuilderFactoryMock!
|
var clientBuilderFactory: AuthenticationClientBuilderFactoryMock!
|
||||||
var client: ClientSDKMock!
|
var client: ClientSDKMock!
|
||||||
|
var appSettings: AppSettings!
|
||||||
var authenticationService: AuthenticationServiceProtocol!
|
var authenticationService: AuthenticationServiceProtocol!
|
||||||
|
|
||||||
var viewModel: AuthenticationStartScreenViewModel!
|
var viewModel: AuthenticationStartScreenViewModel!
|
||||||
@@ -20,8 +21,9 @@ class AuthenticationStartScreenViewModelTests: XCTestCase {
|
|||||||
|
|
||||||
override func setUp() {
|
override func setUp() {
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
let appSettings = AppSettings()
|
appSettings = AppSettings()
|
||||||
ServiceLocator.shared.register(appSettings: appSettings)
|
// These app settings are kept local to the tests on purpose as if they are registered in the
|
||||||
|
// ServiceLocator, the providers override that we apply will break other tests in the suite.
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tearDown() {
|
override func tearDown() {
|
||||||
@@ -142,13 +144,13 @@ class AuthenticationStartScreenViewModelTests: XCTestCase {
|
|||||||
authenticationService = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()),
|
authenticationService = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()),
|
||||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||||
clientBuilderFactory: clientBuilderFactory,
|
clientBuilderFactory: clientBuilderFactory,
|
||||||
appSettings: ServiceLocator.shared.settings,
|
appSettings: appSettings,
|
||||||
appHooks: AppHooks())
|
appHooks: AppHooks())
|
||||||
|
|
||||||
viewModel = AuthenticationStartScreenViewModel(authenticationService: authenticationService,
|
viewModel = AuthenticationStartScreenViewModel(authenticationService: authenticationService,
|
||||||
provisioningParameters: provisioningParameters,
|
provisioningParameters: provisioningParameters,
|
||||||
isBugReportServiceEnabled: true,
|
isBugReportServiceEnabled: true,
|
||||||
appSettings: ServiceLocator.shared.settings,
|
appSettings: appSettings,
|
||||||
userIndicatorController: UserIndicatorControllerMock())
|
userIndicatorController: UserIndicatorControllerMock())
|
||||||
|
|
||||||
// Add a fake window in order for the OIDC flow to continue
|
// Add a fake window in order for the OIDC flow to continue
|
||||||
@@ -156,7 +158,6 @@ class AuthenticationStartScreenViewModelTests: XCTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func setAllowedAccountProviders(_ providers: [String]) {
|
private func setAllowedAccountProviders(_ providers: [String]) {
|
||||||
let appSettings: AppSettings! = ServiceLocator.shared.settings
|
|
||||||
appSettings.override(accountProviders: providers,
|
appSettings.override(accountProviders: providers,
|
||||||
allowOtherAccountProviders: false,
|
allowOtherAccountProviders: false,
|
||||||
pushGatewayBaseURL: appSettings.pushGatewayBaseURL,
|
pushGatewayBaseURL: appSettings.pushGatewayBaseURL,
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ class ServerConfirmationScreenViewModelTests: XCTestCase {
|
|||||||
override func setUp() {
|
override func setUp() {
|
||||||
AppSettings.resetAllSettings()
|
AppSettings.resetAllSettings()
|
||||||
appSettings = AppSettings()
|
appSettings = AppSettings()
|
||||||
ServiceLocator.shared.register(appSettings: appSettings)
|
// These app settings are kept local to the tests on purpose as if they are registered in the
|
||||||
|
// ServiceLocator, the providers override that we apply will break other tests in the suite.
|
||||||
}
|
}
|
||||||
|
|
||||||
override func tearDown() {
|
override func tearDown() {
|
||||||
|
|||||||
Reference in New Issue
Block a user