mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 20:09:04 +00:00
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:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
--disable wrapMultiLineStatementBraces
|
--disable wrapMultiLineStatementBraces
|
||||||
--disable hoistPatternLet
|
--disable hoistPatternLet
|
||||||
|
--disable preferForLoop
|
||||||
|
|
||||||
--commas inline
|
--commas inline
|
||||||
--ifdef no-indent
|
--ifdef no-indent
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
|
|||||||
case .insert:
|
case .insert:
|
||||||
break
|
break
|
||||||
case .remove(_, let module, _):
|
case .remove(_, let module, _):
|
||||||
self.processCompactLayoutStackModuleRemoval(module)
|
processCompactLayoutStackModuleRemoval(module)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ class InvitesScreenViewModel: InvitesScreenViewModelType, InvitesScreenViewModel
|
|||||||
|
|
||||||
inviteSummaryProvider.roomListPublisher
|
inviteSummaryProvider.roomListPublisher
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak self] roomSummaries in
|
.sink { [weak self] roomSummaries in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ struct InvitesScreen_Previews: PreviewProvider, TestablePreview {
|
|||||||
NavigationView {
|
NavigationView {
|
||||||
InvitesScreen(context: InvitesScreenViewModel.someInvite.context)
|
InvitesScreen(context: InvitesScreenViewModel.someInvite.context)
|
||||||
}
|
}
|
||||||
|
.snapshot(delay: 1.0)
|
||||||
.previewDisplayName("Some Invite")
|
.previewDisplayName("Some Invite")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
struct EmojiCategory: Equatable, Identifiable {
|
struct EmojiCategory: Equatable, Identifiable {
|
||||||
let id: String
|
let id: String
|
||||||
let emojis: [EmojiItem]
|
let emojis: [EmojiItem]
|
||||||
|
|||||||
@@ -23,8 +23,9 @@ extension XCUIApplication {
|
|||||||
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
|
||||||
getStartedButton.tap()
|
getStartedButton.tap()
|
||||||
|
|
||||||
|
// Get started is network bound, wait for the change homeserver button for longer
|
||||||
let changeHomeserverButton = buttons[A11yIdentifiers.serverConfirmationScreen.changeServer]
|
let changeHomeserverButton = buttons[A11yIdentifiers.serverConfirmationScreen.changeServer]
|
||||||
XCTAssertTrue(changeHomeserverButton.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(changeHomeserverButton.waitForExistence(timeout: 30.0))
|
||||||
changeHomeserverButton.tap()
|
changeHomeserverButton.tap()
|
||||||
|
|
||||||
let homeserverTextField = textFields[A11yIdentifiers.changeServerScreen.server]
|
let homeserverTextField = textFields[A11yIdentifiers.changeServerScreen.server]
|
||||||
@@ -36,7 +37,11 @@ extension XCUIApplication {
|
|||||||
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
|
||||||
confirmButton.tap()
|
confirmButton.tap()
|
||||||
|
|
||||||
// Server cofirmation is network bound and might take a while
|
// Wait for server confirmation to finish
|
||||||
|
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
|
||||||
|
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: confirmButton)
|
||||||
|
currentTestCase.waitForExpectations(timeout: 300.0)
|
||||||
|
|
||||||
let continueButton = buttons[A11yIdentifiers.serverConfirmationScreen.continue]
|
let continueButton = buttons[A11yIdentifiers.serverConfirmationScreen.continue]
|
||||||
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
|
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
|
||||||
continueButton.tap()
|
continueButton.tap()
|
||||||
@@ -58,7 +63,6 @@ extension XCUIApplication {
|
|||||||
nextButton.tap()
|
nextButton.tap()
|
||||||
|
|
||||||
// Wait for login to finish
|
// Wait for login to finish
|
||||||
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
|
|
||||||
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: usernameTextField)
|
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: usernameTextField)
|
||||||
currentTestCase.waitForExpectations(timeout: 300.0)
|
currentTestCase.waitForExpectations(timeout: 300.0)
|
||||||
|
|
||||||
@@ -93,7 +97,6 @@ extension XCUIApplication {
|
|||||||
let message = staticTexts[A11yIdentifiers.migrationScreen.message]
|
let message = staticTexts[A11yIdentifiers.migrationScreen.message]
|
||||||
|
|
||||||
if message.waitForExistence(timeout: 10.0) {
|
if message.waitForExistence(timeout: 10.0) {
|
||||||
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
|
|
||||||
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: message)
|
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: message)
|
||||||
currentTestCase.waitForExpectations(timeout: 300.0)
|
currentTestCase.waitForExpectations(timeout: 300.0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,11 @@ class UserFlowTests: XCTestCase {
|
|||||||
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
|
||||||
firstRoom.tap()
|
firstRoom.tap()
|
||||||
|
|
||||||
checkAttachmentsPicker()
|
checkPhotoSharing()
|
||||||
|
|
||||||
|
checkDocumentSharing()
|
||||||
|
|
||||||
|
checkLocationSharing()
|
||||||
|
|
||||||
checkTimelineItemActionMenu()
|
checkTimelineItemActionMenu()
|
||||||
|
|
||||||
@@ -55,15 +59,7 @@ class UserFlowTests: XCTestCase {
|
|||||||
tapOnBackButton("All Chats")
|
tapOnBackButton("All Chats")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func checkAttachmentsPicker() {
|
private func checkPhotoSharing() {
|
||||||
for identifier in [A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary,
|
|
||||||
A11yIdentifiers.roomScreen.attachmentPickerDocuments,
|
|
||||||
A11yIdentifiers.roomScreen.attachmentPickerLocation] {
|
|
||||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
|
||||||
tapOnButton(identifier)
|
|
||||||
tapOnButton("Cancel")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open attachments picker
|
// Open attachments picker
|
||||||
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
tapOnMenu(A11yIdentifiers.roomScreen.composerToolbar.openComposeOptions)
|
||||||
|
|
||||||
@@ -71,7 +67,9 @@ class UserFlowTests: XCTestCase {
|
|||||||
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
|
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
|
||||||
|
|
||||||
// Tap on the second image. First one is always broken on simulators.
|
// 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
|
// Cancel the upload flow
|
||||||
tapOnButton("Cancel")
|
tapOnButton("Cancel")
|
||||||
@@ -79,6 +77,43 @@ class UserFlowTests: XCTestCase {
|
|||||||
sleep(2) // Wait for dismissal
|
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() {
|
private func checkRoomCreation() {
|
||||||
tapOnButton(A11yIdentifiers.homeScreen.startChat)
|
tapOnButton(A11yIdentifiers.homeScreen.startChat)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user