More integration test tweaks (#2321)

* Improve integration test timings and alert handing

* Add missing `receive(on: DispatchQueue.main` on the invites screen

* Wait for photo library to load

* Disable the preferForLoop swiftformat rule and fix a couple of new warnings

* Delay invites screen snapshotting after dispatch main queue addition
This commit is contained in:
Stefan Ceriu
2024-01-11 16:35:03 +02:00
committed by GitHub
parent ada75ab339
commit fcf78e93e0
7 changed files with 58 additions and 16 deletions
+46 -11
View File
@@ -36,7 +36,11 @@ class UserFlowTests: XCTestCase {
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
firstRoom.tap()
checkAttachmentsPicker()
checkPhotoSharing()
checkDocumentSharing()
checkLocationSharing()
checkTimelineItemActionMenu()
@@ -55,15 +59,7 @@ class UserFlowTests: XCTestCase {
tapOnBackButton("All Chats")
}
private func checkAttachmentsPicker() {
for identifier in [A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary,
A11yIdentifiers.roomScreen.attachmentPickerDocuments,
A11yIdentifiers.roomScreen.attachmentPickerLocation] {
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
tapOnButton(identifier)
tapOnButton("Cancel")
}
private func checkPhotoSharing() {
// Open attachments picker
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
@@ -71,7 +67,9 @@ class UserFlowTests: XCTestCase {
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
// Tap on the second image. First one is always broken on simulators.
app.scrollViews.images.element(boundBy: 1).tap()
let secondImage = app.scrollViews.images.element(boundBy: 1)
XCTAssertTrue(secondImage.waitForExistence(timeout: 10.0)) // Photo library takes a bit to load
secondImage.tap()
// Cancel the upload flow
tapOnButton("Cancel")
@@ -79,6 +77,43 @@ class UserFlowTests: XCTestCase {
sleep(2) // Wait for dismissal
}
private func checkDocumentSharing() {
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerDocuments)
tapOnButton("Cancel")
sleep(2) // Wait for dismissal
}
private func checkLocationSharing() {
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerLocation)
// The order of the alerts is a bit of a mistery so try twice
allowLocationPermissionOnce()
// Handle map loading errors (missing credentials)
let alertOkButton = app.alerts.firstMatch.buttons["OK"].firstMatch
if alertOkButton.waitForExistence(timeout: 10.0) {
alertOkButton.tap()
}
allowLocationPermissionOnce()
tapOnButton("Cancel")
sleep(2) // Wait for dismissal
}
private func allowLocationPermissionOnce() {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let notificationAlertAllowButton = springboard.buttons["Allow Once"].firstMatch
if notificationAlertAllowButton.waitForExistence(timeout: 10.0) {
notificationAlertAllowButton.tap()
}
}
private func checkRoomCreation() {
tapOnButton(A11yIdentifiers.homeScreen.startChat)