mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Integration test improvements (#3330)
* Send a message from integration tests and check that it doesn't show up in the app logs * Increase photo library timeout * Wait for image tapping to process * Send a message using the rich text editor too * Wait for the various pickers to finish loading * Set all logs to `trace` in integration tests * Close formatting options after sending the second message * Make sure logs are actually sent to tracing and get redirected to the right file * Switch from using a custom `trace` log configuration to the lowest level `TracingConfiguration` we support
This commit is contained in:
@@ -8,6 +8,9 @@
|
||||
import XCTest
|
||||
|
||||
class UserFlowTests: XCTestCase {
|
||||
private static let integrationTestsRoomName = "Element X iOS Integration Tests"
|
||||
private static let integrationTestsMessage = "Go down in flames!"
|
||||
|
||||
private var app: XCUIApplication!
|
||||
|
||||
override func setUp() {
|
||||
@@ -16,15 +19,28 @@ class UserFlowTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testUserFlow() {
|
||||
checkRoomFlows()
|
||||
|
||||
checkSettings()
|
||||
|
||||
checkRoomCreation()
|
||||
|
||||
// Open the first room in the list.
|
||||
let firstRoom = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix)).firstMatch
|
||||
app.logout()
|
||||
}
|
||||
|
||||
// Assumes app is on the home screen
|
||||
private func checkRoomFlows() {
|
||||
// Search for the special test room
|
||||
let searchField = app.searchFields.firstMatch
|
||||
searchField.clearAndTypeText(Self.integrationTestsRoomName)
|
||||
|
||||
// And open it
|
||||
let firstRoom = app.buttons.matching(NSPredicate(format: "identifier CONTAINS %@", Self.integrationTestsRoomName)).firstMatch
|
||||
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
|
||||
firstRoom.tap()
|
||||
|
||||
sendMessages()
|
||||
|
||||
checkPhotoSharing()
|
||||
|
||||
checkDocumentSharing()
|
||||
@@ -35,21 +51,58 @@ class UserFlowTests: XCTestCase {
|
||||
|
||||
checkRoomDetails()
|
||||
|
||||
app.logout()
|
||||
// Go back to the room list
|
||||
tapOnBackButton("Chats")
|
||||
|
||||
// Cancel initial the room search
|
||||
let searchCancelButton = app.buttons["Cancel"].firstMatch
|
||||
XCTAssertTrue(searchCancelButton.waitForExistence(timeout: 10.0))
|
||||
searchCancelButton.forceTap()
|
||||
}
|
||||
|
||||
private func sendMessages() {
|
||||
var composerTextField = app.textViews[A11yIdentifiers.roomScreen.messageComposer].firstMatch
|
||||
XCTAssertTrue(composerTextField.waitForExistence(timeout: 10.0))
|
||||
composerTextField.clearAndTypeText(Self.integrationTestsMessage)
|
||||
|
||||
var sendButton = app.buttons[A11yIdentifiers.roomScreen.sendButton].firstMatch
|
||||
XCTAssertTrue(sendButton.waitForExistence(timeout: 10.0))
|
||||
sendButton.tap()
|
||||
|
||||
sleep(10) // Wait for the message to be sent
|
||||
|
||||
// Switch to the rich text editor
|
||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
||||
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerTextFormatting)
|
||||
|
||||
composerTextField = app.textViews[A11yIdentifiers.roomScreen.messageComposer].firstMatch
|
||||
XCTAssertTrue(composerTextField.waitForExistence(timeout: 10.0))
|
||||
composerTextField.clearAndTypeText(Self.integrationTestsMessage)
|
||||
|
||||
sendButton = app.buttons[A11yIdentifiers.roomScreen.sendButton].firstMatch
|
||||
XCTAssertTrue(sendButton.waitForExistence(timeout: 10.0))
|
||||
sendButton.tap()
|
||||
|
||||
sleep(5) // Wait for the message to be sent
|
||||
|
||||
// Close the formatting options
|
||||
app.buttons[A11yIdentifiers.roomScreen.composerToolbar.closeFormattingOptions].tap()
|
||||
}
|
||||
|
||||
private func checkPhotoSharing() {
|
||||
// Open attachments picker
|
||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
||||
|
||||
// Open photo library picker
|
||||
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
|
||||
|
||||
sleep(10) // Wait for the picker to load
|
||||
|
||||
// Tap on the second image. First one is always broken on simulators.
|
||||
let secondImage = app.scrollViews.images.element(boundBy: 1)
|
||||
XCTAssertTrue(secondImage.waitForExistence(timeout: 10.0)) // Photo library takes a bit to load
|
||||
XCTAssertTrue(secondImage.waitForExistence(timeout: 20.0)) // Photo library takes a bit to load
|
||||
secondImage.tap()
|
||||
|
||||
// Wait for the image to be processed and the new screen to appear
|
||||
sleep(10)
|
||||
|
||||
// Cancel the upload flow
|
||||
tapOnButton("Cancel", waitForDisappearance: true)
|
||||
}
|
||||
@@ -58,6 +111,8 @@ class UserFlowTests: XCTestCase {
|
||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
||||
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerDocuments)
|
||||
|
||||
sleep(10) // Wait for the picker to load
|
||||
|
||||
tapOnButton("Cancel", waitForDisappearance: true)
|
||||
}
|
||||
|
||||
@@ -65,6 +120,8 @@ class UserFlowTests: XCTestCase {
|
||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
||||
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerLocation)
|
||||
|
||||
sleep(10) // Wait for the picker to load
|
||||
|
||||
// The order of the alerts is a bit of a mistery so try twice
|
||||
|
||||
allowLocationPermissionOnce()
|
||||
@@ -139,9 +196,6 @@ class UserFlowTests: XCTestCase {
|
||||
|
||||
// Go back to the room
|
||||
tapOnBackButton("Chat")
|
||||
|
||||
// Go back to the room list
|
||||
tapOnBackButton("Chats")
|
||||
}
|
||||
|
||||
private func checkSettings() {
|
||||
|
||||
Reference in New Issue
Block a user