Go through more screens in the integration tests

This commit is contained in:
Stefan Ceriu 2023-08-24 18:20:23 +03:00 committed by Stefan Ceriu
parent 6171d878b0
commit 7712bb0082
4 changed files with 78 additions and 25 deletions

View File

@ -29,6 +29,7 @@ struct A11yIdentifiers {
static let roomNotificationSettingsScreen = RoomNotificationSettingsScreen()
static let serverConfirmationScreen = ServerConfirmationScreen()
static let sessionVerificationScreen = SessionVerificationScreen()
static let settingsScreen = SettingsScreen()
static let softLogoutScreen = SoftLogoutScreen()
static let startChatScreen = StartChatScreen()
static let roomMemberDetailsScreen = RoomMemberDetailsScreen()
@ -98,6 +99,7 @@ struct A11yIdentifiers {
let name = "room-name"
let avatar = "room-avatar"
let attachmentPicker = "room-attachment_picker"
let timelineItemActionMenu = "room-timeline_item_action_menu"
}
struct RoomDetailsScreen {
@ -133,6 +135,10 @@ struct A11yIdentifiers {
let close = "session_verification-close"
}
struct SettingsScreen {
let logout = "settings-logout"
}
struct SoftLogoutScreen {
let title = "soft_logout-title"
let message = "soft_logout-message"

View File

@ -157,6 +157,8 @@ public struct TimelineItemMenu: View {
}
}
}
.accessibilityElement(children: .combine)
.accessibilityIdentifier(A11yIdentifiers.roomScreen.timelineItemActionMenu)
.presentationDetents([.medium, .large])
.presentationBackground(Color.compound.bgCanvasDefault)
.presentationDragIndicator(.visible)

View File

@ -166,7 +166,7 @@ struct SettingsScreen: View {
kind: .button {
showingLogoutConfirmation = true
})
.accessibilityIdentifier("logoutButton")
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.logout)
.alert(L10n.screenSignoutConfirmationDialogTitle, isPresented: $showingLogoutConfirmation) {
Button(L10n.screenSignoutConfirmationDialogSubmit,
role: .destructive,

View File

@ -32,11 +32,6 @@ class LoginTests: XCTestCase {
self.runLoginLogoutFlow()
}
}
guard let actualDuration = parser.valueForMetric(.clockMonotonicTime) else {
XCTFail("Couldn't retrieve duration")
return
}
}
private func runLoginLogoutFlow() {
@ -131,24 +126,74 @@ class LoginTests: XCTestCase {
XCTAssertTrue(profileButton.waitForExistence(timeout: 300.0))
// Open the first room in the list.
let rooms = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix))
rooms.firstMatch.tap()
// Temporary sleep to get it working.
sleep(20)
// Go back to the home screen.
app.navigationBars.firstMatch.buttons["All Chats"].tap()
let firstRoom = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix)).firstMatch
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
firstRoom.tap()
// Long press on the last message
let lastMessage = app.cells.firstMatch
XCTAssertTrue(lastMessage.waitForExistence(timeout: 10.0))
lastMessage.press(forDuration: 2.0)
// Hide the bottom sheet
let timelineItemActionMenu = app.otherElements[A11yIdentifiers.roomScreen.timelineItemActionMenu].firstMatch
XCTAssertTrue(timelineItemActionMenu.waitForExistence(timeout: 10.0))
timelineItemActionMenu.swipeDown(velocity: .fast)
// Open the room details
let roomHeader = app.staticTexts["room-name"]
XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0))
roomHeader.tap()
// Open the room member details
let roomMembers = app.buttons["room_details-people"]
XCTAssertTrue(roomMembers.waitForExistence(timeout: 10.0))
roomMembers.tap()
// Open the first member's details
let firstRoomMember = app.scrollViews.buttons.firstMatch
XCTAssertTrue(firstRoomMember.waitForExistence(timeout: 10.0))
firstRoomMember.tap()
// Go back to the room member details
var backButton = app.buttons["People"]
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
backButton.tap()
// Go back to the room details
backButton = app.buttons["Back"]
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
backButton.tap()
// Go back to the room
backButton = app.buttons["Back"]
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
backButton.tap()
// Go back to the room list
backButton = app.navigationBars.firstMatch.buttons["All Chats"]
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
backButton.tap()
// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
profileButton.forceTap()
let menuLogoutButton = app.buttons["Sign out"]
XCTAssertTrue(menuLogoutButton.waitForExistence(timeout: 10.0))
menuLogoutButton.tap()
// Open the settings
let settingsButton = app.buttons["Settings"]
XCTAssertTrue(settingsButton.waitForExistence(timeout: 10.0))
settingsButton.tap()
let alertLogoutButton = app.buttons["Sign out"]
// Logout
let logoutButton = app.buttons[A11yIdentifiers.settingsScreen.logout]
XCTAssertTrue(logoutButton.waitForExistence(timeout: 10.0))
logoutButton.tap()
// Confirm logout
let alertLogoutButton = app.alerts.firstMatch.buttons["Sign out"]
XCTAssertTrue(alertLogoutButton.waitForExistence(timeout: 10.0))
alertLogoutButton.tap()
// Check that we're back on the login screen
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
}
}