Fixed UI test problems introduced after the accessibility identifier … (#586)

* Fixed UI test problems introduced after the accessibility identifier changes
* Disable parallel UITests, they don't seem to work properly
* Fix UITests `elementFallbackLanguage`
This commit is contained in:
Stefan Ceriu
2023-02-16 12:42:50 +02:00
committed by GitHub
parent e91e0513b6
commit f44075e67e
6 changed files with 20 additions and 8 deletions
@@ -23,6 +23,7 @@ struct A11yIdentifiers {
static let loginScreen = LoginScreen()
static let onboardingScreen = OnboardingScreen()
static let roomScreen = RoomScreen()
static let roomDetailsScreen = RoomDetailsScreen()
static let sessionVerificationScreen = SessionVerificationScreen()
static let softLogoutScreen = SoftLogoutScreen()
@@ -64,15 +65,20 @@ struct A11yIdentifiers {
}
struct RoomScreen {
let name = "room_name"
let avatar = "room_avatar"
let name = "room-name"
let avatar = "room-avatar"
}
struct RoomDetailsScreen {
let avatar = "room_details-avatar"
let people = "room_details-people"
}
struct SessionVerificationScreen {
let requestVerification = "session_verification-request_verification"
let startSasVerification = "session_verification-start_sas_verification"
let acceptChallenge = "session_verification-accept_challenge"
let declineChallenge = "session_verification-accept_challenge"
let declineChallenge = "session_verification-decline_challenge"
let close = "session_verification-close"
}
@@ -52,6 +52,7 @@ struct RoomDetailsScreen: View {
contentID: context.viewState.roomId,
avatarSize: .room(on: .details),
imageProvider: context.imageProvider)
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.avatar)
Text(context.viewState.title)
.foregroundColor(.element.primaryContent)
@@ -119,6 +120,7 @@ struct RoomDetailsScreen: View {
}
.listRowInsets(listRowInsets)
.foregroundColor(.element.primaryContent)
.accessibilityIdentifier(A11yIdentifiers.roomDetailsScreen.people)
.disabled(context.viewState.isLoadingMembers)
} header: {
Text(ElementL10n.roomDetailsAboutSectionTitle)
@@ -34,13 +34,13 @@ class UITestsAppCoordinator: AppCoordinatorProtocol {
}
func start() {
Bundle.elementFallbackLanguage = "en"
guard let screenID = Tests.screenID else { fatalError("Unable to launch with unknown screen.") }
let mockScreen = MockScreen(id: screenID)
navigationRootCoordinator.setRootCoordinator(mockScreen.coordinator)
self.mockScreen = mockScreen
Bundle.elementFallbackLanguage = "en"
}
func toPresentable() -> AnyView {
+3
View File
@@ -24,7 +24,10 @@ struct Application {
"IS_RUNNING_UI_TESTS": "1",
"UI_TESTS_SCREEN": identifier.rawValue
]
// Use the same fallback language as the real app so translation comparison works
Bundle.elementFallbackLanguage = "en"
app.launch()
return app
}
@@ -21,14 +21,16 @@ class RoomDetailsScreenUITests: XCTestCase {
func testInitialStateComponents() {
let app = Application.launch(.roomDetailsScreen)
XCTAssert(app.staticTexts[A11yIdentifiers.roomScreen.avatar].exists)
XCTAssert(app.staticTexts[A11yIdentifiers.roomDetailsScreen.avatar].exists)
XCTAssert(app.buttons[A11yIdentifiers.roomDetailsScreen.people].waitForExistence(timeout: 1))
app.assertScreenshot(.roomDetailsScreen)
}
func testInitialStateComponentsWithRoomAvatar() {
let app = Application.launch(.roomDetailsScreenWithRoomAvatar)
XCTAssert(app.images[A11yIdentifiers.roomScreen.avatar].waitForExistence(timeout: 1))
XCTAssert(app.images[A11yIdentifiers.roomDetailsScreen.avatar].waitForExistence(timeout: 1))
XCTAssert(app.buttons[A11yIdentifiers.roomDetailsScreen.people].waitForExistence(timeout: 1))
app.assertScreenshot(.roomDetailsScreenWithRoomAvatar)
}
}
@@ -53,7 +53,6 @@
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:ElementX.xcodeproj",
"identifier" : "0E28CD62691FDBC63147D5E3",