Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various integration test tweaks following test homeserver and account… #2317

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ElementX/Sources/Other/Extensions/XCUIElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension XCUIElement {
if isHittable {
tap()
} else {
let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.0, dy: 0.0))
let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5))
coordinate.tap()
}
}
Expand Down
22 changes: 15 additions & 7 deletions IntegrationTests/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ extension XCUIApplication {
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
confirmButton.tap()

// Server cofirmation is network bound and might take a while
let continueButton = buttons[A11yIdentifiers.serverConfirmationScreen.continue]
XCTAssertTrue(continueButton.waitForExistence(timeout: 10.0))
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
continueButton.tap()

let usernameTextField = textFields[A11yIdentifiers.loginScreen.emailUsername]
Expand All @@ -56,10 +57,13 @@ extension XCUIApplication {

nextButton.tap()

sleep(10)
// Wait for login to finish
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: usernameTextField)
currentTestCase.waitForExpectations(timeout: 300.0)

// Handle analytics prompt screen
if staticTexts[A11yIdentifiers.analyticsPromptScreen.title].waitForExistence(timeout: 1.0) {
if staticTexts[A11yIdentifiers.analyticsPromptScreen.title].waitForExistence(timeout: 10.0) {
// Wait for login and then handle save password sheet
let savePasswordButton = buttons["Save Password"]
if savePasswordButton.waitForExistence(timeout: 10.0) {
Expand All @@ -79,9 +83,9 @@ extension XCUIApplication {

// Handle the notifications permission alert https://stackoverflow.com/a/58171074/730924
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let alertAllowButton = springboard.buttons.element(boundBy: 1)
if alertAllowButton.waitForExistence(timeout: 10.0) {
alertAllowButton.tap()
let notificationAlertDeclineButton = springboard.buttons.element(boundBy: 0)
if notificationAlertDeclineButton.waitForExistence(timeout: 10.0) {
notificationAlertDeclineButton.tap()
}

// Migration screen may be shown as an overlay.
Expand All @@ -108,8 +112,12 @@ extension XCUIApplication {
}

func logout() {
let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]
// On first login when multiple sheets get presented the profile button is not hittable
// Moving the scroll fixed it for some obscure reason
swipeDown()

let profileButton = buttons[A11yIdentifiers.homeScreen.userAvatar]

// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
profileButton.forceTap()

Expand Down
12 changes: 9 additions & 3 deletions IntegrationTests/Sources/UserFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class UserFlowTests: XCTestCase {

// Cancel the upload flow
tapOnButton("Cancel")

sleep(2) // Wait for dismissal
}

private func checkRoomCreation() {
Expand All @@ -90,7 +92,7 @@ class UserFlowTests: XCTestCase {

tapOnButton("Cancel")

sleep(1)
sleep(2) // Wait for dismissal
}

private func checkTimelineItemActionMenu() {
Expand All @@ -114,9 +116,9 @@ class UserFlowTests: XCTestCase {
// Open the room member details
tapOnButton(A11yIdentifiers.roomDetailsScreen.people)

// Open the first member's details
// Open the first member's details. Loading members for big rooms can take a while.
let firstRoomMember = app.scrollViews.buttons.firstMatch
XCTAssertTrue(firstRoomMember.waitForExistence(timeout: 10.0))
XCTAssertTrue(firstRoomMember.waitForExistence(timeout: 300.0))
firstRoomMember.tap()

// Go back to the room member details
Expand All @@ -133,6 +135,10 @@ class UserFlowTests: XCTestCase {
}

private func checkSettings() {
// On first login when multiple sheets get presented the profile button is not hittable
// Moving the scroll fixed it for some obscure reason
app.swipeDown()

let profileButton = app.buttons[A11yIdentifiers.homeScreen.userAvatar]

// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
Expand Down