Fix A11y tests (#5104)

* replace NavigationStack with ElementNavigationStack to allow the content to be rendered without a NavigationStack in a11y tests

* fix a11y tests

* update xcodeproject

* swiftformat fix

* use iOS 26.1 for CI

* use a wrapper to solve the issue for a11y tests

* ElementNavigationStack only uses the trick in DEBUG mode, and added a swiftlint rule to prevent the usage of NavigationStack
This commit is contained in:
Mauro
2026-02-13 16:45:58 +01:00
committed by GitHub
parent b11438e38d
commit 0e40cc7008
83 changed files with 254 additions and 180 deletions
@@ -135,19 +135,19 @@ struct LoginScreen_Previews: PreviewProvider, TestablePreview {
static let unconfiguredViewModel = makeViewModel(homeserverAddress: "somethingtofailconfiguration")
static var previews: some View {
NavigationStack {
ElementNavigationStack {
LoginScreen(context: viewModel.context)
}
.snapshotPreferences(expect: viewModel.context.observe(\.viewState.homeserver.loginMode).map { $0 == .password })
.previewDisplayName("Initial State")
NavigationStack {
ElementNavigationStack {
LoginScreen(context: credentialsViewModel.context)
}
.snapshotPreferences(expect: credentialsViewModel.context.observe(\.viewState.homeserver.loginMode).map { $0 == .password })
.previewDisplayName("Credentials Entered")
NavigationStack {
ElementNavigationStack {
LoginScreen(context: unconfiguredViewModel.context)
}
.previewDisplayName("Unsupported")
@@ -140,19 +140,19 @@ struct ServerConfirmationScreen_Previews: PreviewProvider, TestablePreview {
static let pickerViewModel = makeViewModel(mode: .picker(["dept1.company.com", "dept2.company.com", "dept3.company.com"]), flow: .login)
static var previews: some View {
NavigationStack {
ElementNavigationStack {
ServerConfirmationScreen(context: loginViewModel.context)
.toolbar(.visible, for: .navigationBar)
}
.previewDisplayName("Login")
NavigationStack {
ElementNavigationStack {
ServerConfirmationScreen(context: registerViewModel.context)
.toolbar(.visible, for: .navigationBar)
}
.previewDisplayName("Register")
NavigationStack {
ElementNavigationStack {
ServerConfirmationScreen(context: pickerViewModel.context)
.toolbar(.visible, for: .navigationBar)
}
@@ -97,15 +97,15 @@ struct ServerSelection_Previews: PreviewProvider, TestablePreview {
static let invalidViewModel = makeViewModel(for: "thisisbad")
static var previews: some View {
NavigationStack {
ElementNavigationStack {
ServerSelectionScreen(context: matrixViewModel.context)
}
NavigationStack {
ElementNavigationStack {
ServerSelectionScreen(context: emptyViewModel.context)
}
NavigationStack {
ElementNavigationStack {
ServerSelectionScreen(context: invalidViewModel.context)
}
.snapshotPreferences(expect: invalidViewModel.context.observe(\.viewState.hasValidationError))
@@ -169,7 +169,7 @@ struct SoftLogoutScreen_Previews: PreviewProvider, TestablePreview {
}
static func screen(for viewModel: SoftLogoutScreenViewModel) -> some View {
NavigationStack {
ElementNavigationStack {
SoftLogoutScreen(context: viewModel.context)
.navigationBarTitleDisplayMode(.inline)
.toolbar {