From f44075e67ee2bceb13c7e15bb1ff829ece5e488c Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 16 Feb 2023 12:42:50 +0200 Subject: [PATCH] =?UTF-8?q?Fixed=20UI=20test=20problems=20introduced=20aft?= =?UTF-8?q?er=20the=20accessibility=20identifier=20=E2=80=A6=20(#586)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed UI test problems introduced after the accessibility identifier changes * Disable parallel UITests, they don't seem to work properly * Fix UITests `elementFallbackLanguage` --- .../Sources/Other/AccessibilityIdentifiers.swift | 12 +++++++++--- .../Screens/RoomDetails/View/RoomDetailsScreen.swift | 2 ++ ElementX/Sources/UITests/UITestsAppCoordinator.swift | 4 ++-- UITests/Sources/Application.swift | 3 +++ UITests/Sources/RoomDetailsScreenUITests.swift | 6 ++++-- UITests/SupportingFiles/UITests.xctestplan | 1 - 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ElementX/Sources/Other/AccessibilityIdentifiers.swift b/ElementX/Sources/Other/AccessibilityIdentifiers.swift index f4fb8b35d..dd03369e5 100644 --- a/ElementX/Sources/Other/AccessibilityIdentifiers.swift +++ b/ElementX/Sources/Other/AccessibilityIdentifiers.swift @@ -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" } diff --git a/ElementX/Sources/Screens/RoomDetails/View/RoomDetailsScreen.swift b/ElementX/Sources/Screens/RoomDetails/View/RoomDetailsScreen.swift index bae92a2ea..b69817909 100644 --- a/ElementX/Sources/Screens/RoomDetails/View/RoomDetailsScreen.swift +++ b/ElementX/Sources/Screens/RoomDetails/View/RoomDetailsScreen.swift @@ -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) diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index c82aa96d1..af4cf0bbf 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -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 { diff --git a/UITests/Sources/Application.swift b/UITests/Sources/Application.swift index 94d594251..503da5844 100644 --- a/UITests/Sources/Application.swift +++ b/UITests/Sources/Application.swift @@ -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 } diff --git a/UITests/Sources/RoomDetailsScreenUITests.swift b/UITests/Sources/RoomDetailsScreenUITests.swift index 846300e92..e6e47d082 100644 --- a/UITests/Sources/RoomDetailsScreenUITests.swift +++ b/UITests/Sources/RoomDetailsScreenUITests.swift @@ -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) } } diff --git a/UITests/SupportingFiles/UITests.xctestplan b/UITests/SupportingFiles/UITests.xctestplan index e7ea48c2c..a95a05b29 100644 --- a/UITests/SupportingFiles/UITests.xctestplan +++ b/UITests/SupportingFiles/UITests.xctestplan @@ -53,7 +53,6 @@ }, "testTargets" : [ { - "parallelizable" : true, "target" : { "containerPath" : "container:ElementX.xcodeproj", "identifier" : "0E28CD62691FDBC63147D5E3",