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

Moar integration test tweaks #2321

Merged
merged 5 commits into from
Jan 11, 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
1 change: 1 addition & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

--disable wrapMultiLineStatementBraces
--disable hoistPatternLet
--disable preferForLoop

--commas inline
--ifdef no-indent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class NavigationSplitCoordinator: CoordinatorProtocol, ObservableObject, CustomS
case .insert:
break
case .remove(_, let module, _):
self.processCompactLayoutStackModuleRemoval(module)
processCompactLayoutStackModuleRemoval(module)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class InvitesScreenViewModel: InvitesScreenViewModelType, InvitesScreenViewModel

inviteSummaryProvider.roomListPublisher
.removeDuplicates()
.receive(on: DispatchQueue.main)
.sink { [weak self] roomSummaries in
guard let self else { return }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct InvitesScreen_Previews: PreviewProvider, TestablePreview {
NavigationView {
InvitesScreen(context: InvitesScreenViewModel.someInvite.context)
}
.snapshot(delay: 1.0)
.previewDisplayName("Some Invite")
}
}
Expand Down
1 change: 1 addition & 0 deletions ElementX/Sources/Services/Emojis/EmojiCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

import Foundation

struct EmojiCategory: Equatable, Identifiable {
let id: String
let emojis: [EmojiItem]
Expand Down
11 changes: 7 additions & 4 deletions IntegrationTests/Sources/Common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ extension XCUIApplication {
XCTAssertTrue(getStartedButton.waitForExistence(timeout: 10.0))
getStartedButton.tap()

// Get started is network bound, wait for the change homeserver button for longer
let changeHomeserverButton = buttons[A11yIdentifiers.serverConfirmationScreen.changeServer]
XCTAssertTrue(changeHomeserverButton.waitForExistence(timeout: 10.0))
XCTAssertTrue(changeHomeserverButton.waitForExistence(timeout: 30.0))
changeHomeserverButton.tap()

let homeserverTextField = textFields[A11yIdentifiers.changeServerScreen.server]
Expand All @@ -36,7 +37,11 @@ extension XCUIApplication {
XCTAssertTrue(confirmButton.waitForExistence(timeout: 10.0))
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]
XCTAssertTrue(continueButton.waitForExistence(timeout: 30.0))
continueButton.tap()
Expand All @@ -58,7 +63,6 @@ extension XCUIApplication {
nextButton.tap()

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

Expand Down Expand Up @@ -93,7 +97,6 @@ extension XCUIApplication {
let message = staticTexts[A11yIdentifiers.migrationScreen.message]

if message.waitForExistence(timeout: 10.0) {
let doesNotExistPredicate = NSPredicate(format: "exists == 0")
currentTestCase.expectation(for: doesNotExistPredicate, evaluatedWith: message)
currentTestCase.waitForExpectations(timeout: 300.0)
}
Expand Down
57 changes: 46 additions & 11 deletions IntegrationTests/Sources/UserFlowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class UserFlowTests: XCTestCase {
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
firstRoom.tap()

checkAttachmentsPicker()
checkPhotoSharing()

checkDocumentSharing()

checkLocationSharing()

checkTimelineItemActionMenu()

Expand All @@ -55,30 +59,61 @@ 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)

// Open photo library picker
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")

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)

Expand Down
Loading