mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 13:37:11 +00:00
Check more screens in the integration tests. Refactor flows
This commit is contained in:
parent
7becf6d0af
commit
569620c52f
@ -35,6 +35,7 @@ struct A11yIdentifiers {
|
|||||||
static let roomMemberDetailsScreen = RoomMemberDetailsScreen()
|
static let roomMemberDetailsScreen = RoomMemberDetailsScreen()
|
||||||
static let createRoomScreen = CreateRoomScreen()
|
static let createRoomScreen = CreateRoomScreen()
|
||||||
static let invitesScreen = InvitesScreen()
|
static let invitesScreen = InvitesScreen()
|
||||||
|
static let inviteUsersScreen = InviteUsersScreen()
|
||||||
static let welcomeScreen = WelcomeScreen()
|
static let welcomeScreen = WelcomeScreen()
|
||||||
static let migrationScreen = MigrationScreen()
|
static let migrationScreen = MigrationScreen()
|
||||||
static let notificationSettingsScreen = NotificationSettingsScreen()
|
static let notificationSettingsScreen = NotificationSettingsScreen()
|
||||||
@ -66,6 +67,8 @@ struct A11yIdentifiers {
|
|||||||
let settings = "home_screen-settings"
|
let settings = "home_screen-settings"
|
||||||
let signOut = "home_screen-sign_out"
|
let signOut = "home_screen-sign_out"
|
||||||
let verificationBannerContinue = "home_screen-verification_continue"
|
let verificationBannerContinue = "home_screen-verification_continue"
|
||||||
|
let invites = "home_screen-invites"
|
||||||
|
let startChat = "home_screen-start_chat"
|
||||||
|
|
||||||
let roomNamePrefix = "home_screen-room_name"
|
let roomNamePrefix = "home_screen-room_name"
|
||||||
func roomName(_ name: String) -> String {
|
func roomName(_ name: String) -> String {
|
||||||
@ -79,6 +82,10 @@ struct A11yIdentifiers {
|
|||||||
let decline = "invites-decline"
|
let decline = "invites-decline"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InviteUsersScreen {
|
||||||
|
let proceed = "invite_users-proceed"
|
||||||
|
}
|
||||||
|
|
||||||
struct LoginScreen {
|
struct LoginScreen {
|
||||||
let emailUsername = "login-email_username"
|
let emailUsername = "login-email_username"
|
||||||
let password = "login-password"
|
let password = "login-password"
|
||||||
@ -99,6 +106,10 @@ struct A11yIdentifiers {
|
|||||||
let name = "room-name"
|
let name = "room-name"
|
||||||
let avatar = "room-avatar"
|
let avatar = "room-avatar"
|
||||||
let attachmentPicker = "room-attachment_picker"
|
let attachmentPicker = "room-attachment_picker"
|
||||||
|
let attachmentPickerPhotoLibrary = "room-attachment_picker_photo_library"
|
||||||
|
let attachmentPickerDocuments = "room-attachment_picker_documents"
|
||||||
|
let attachmentPickerCamera = "room-attachment_picker_camera"
|
||||||
|
let attachmentPickerLocation = "room-attachment_picker_location"
|
||||||
let timelineItemActionMenu = "room-timeline_item_action_menu"
|
let timelineItemActionMenu = "room-timeline_item_action_menu"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +147,13 @@ struct A11yIdentifiers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct SettingsScreen {
|
struct SettingsScreen {
|
||||||
|
let done = "settings-done"
|
||||||
|
let account = "settings-account"
|
||||||
|
let notifications = "settings-notifications"
|
||||||
|
let analytics = "settings-analytics"
|
||||||
|
let reportBug = "settings-report_bug"
|
||||||
|
let about = "settings_about"
|
||||||
|
let developerOptions = "settings_developer-options"
|
||||||
let logout = "settings-logout"
|
let logout = "settings-logout"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,6 +171,7 @@ struct A11yIdentifiers {
|
|||||||
|
|
||||||
struct StartChatScreen {
|
struct StartChatScreen {
|
||||||
let closeStartChat = "start_chat-close"
|
let closeStartChat = "start_chat-close"
|
||||||
|
let createRoom = "start_chat-create_room"
|
||||||
let inviteFriends = "start_chat-invite_friends"
|
let inviteFriends = "start_chat-invite_friends"
|
||||||
let searchNoResults = "start_chat-search_no_results"
|
let searchNoResults = "start_chat-search_no_results"
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ struct RoomAttachmentPicker: View {
|
|||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceGallery, icon: Image(systemName: "photo.fill"))
|
PickerLabel(title: L10n.screenRoomAttachmentSourceGallery, icon: Image(systemName: "photo.fill"))
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
context.showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
@ -46,6 +47,7 @@ struct RoomAttachmentPicker: View {
|
|||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceFiles, icon: Image(systemName: "paperclip"))
|
PickerLabel(title: L10n.screenRoomAttachmentSourceFiles, icon: Image(systemName: "paperclip"))
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.roomScreen.attachmentPickerDocuments)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
context.showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
@ -53,6 +55,7 @@ struct RoomAttachmentPicker: View {
|
|||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceCamera, icon: Image(systemName: "camera.fill"))
|
PickerLabel(title: L10n.screenRoomAttachmentSourceCamera, icon: Image(systemName: "camera.fill"))
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.roomScreen.attachmentPickerCamera)
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
context.showAttachmentPopover = false
|
context.showAttachmentPopover = false
|
||||||
@ -60,6 +63,7 @@ struct RoomAttachmentPicker: View {
|
|||||||
} label: {
|
} label: {
|
||||||
PickerLabel(title: L10n.screenRoomAttachmentSourceLocation, icon: Image(asset: Asset.Images.locationPin))
|
PickerLabel(title: L10n.screenRoomAttachmentSourceLocation, icon: Image(asset: Asset.Images.locationPin))
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.roomScreen.attachmentPickerLocation)
|
||||||
}
|
}
|
||||||
.padding(.top, isPresented ? 20 : 0)
|
.padding(.top, isPresented ? 20 : 0)
|
||||||
.background {
|
.background {
|
||||||
|
@ -119,6 +119,7 @@ struct HomeScreen: View {
|
|||||||
HomeScreenInvitesButton(title: L10n.actionInvitesList, hasBadge: context.viewState.hasUnreadPendingInvitations) {
|
HomeScreenInvitesButton(title: L10n.actionInvitesList, hasBadge: context.viewState.hasUnreadPendingInvitations) {
|
||||||
context.send(viewAction: .selectInvites)
|
context.send(viewAction: .selectInvites)
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.homeScreen.invites)
|
||||||
.frame(maxWidth: .infinity, alignment: .trailing)
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
||||||
.padding(.vertical, -8.0)
|
.padding(.vertical, -8.0)
|
||||||
}
|
}
|
||||||
@ -178,6 +179,7 @@ struct HomeScreen: View {
|
|||||||
} label: {
|
} label: {
|
||||||
Image(systemName: "square.and.pencil")
|
Image(systemName: "square.and.pencil")
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.homeScreen.startChat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Often times the scroll view's content size isn't correct yet when this method is called e.g. when cancelling a search
|
/// Often times the scroll view's content size isn't correct yet when this method is called e.g. when cancelling a search
|
||||||
|
@ -29,6 +29,7 @@ struct HomeScreenUserMenuButton: View {
|
|||||||
} label: {
|
} label: {
|
||||||
Label(L10n.commonSettings, systemImage: "gearshape")
|
Label(L10n.commonSettings, systemImage: "gearshape")
|
||||||
}
|
}
|
||||||
|
.accessibilityLabel(A11yIdentifiers.homeScreen.settings)
|
||||||
}
|
}
|
||||||
Section {
|
Section {
|
||||||
MatrixUserShareLink(userID: context.viewState.userID) {
|
MatrixUserShareLink(userID: context.viewState.userID) {
|
||||||
|
@ -130,6 +130,7 @@ struct InviteUsersScreen: View {
|
|||||||
Button(context.viewState.actionText) {
|
Button(context.viewState.actionText) {
|
||||||
context.send(viewAction: .proceed)
|
context.send(viewAction: .proceed)
|
||||||
}
|
}
|
||||||
|
.accessibilityIdentifier(A11yIdentifiers.inviteUsersScreen.proceed)
|
||||||
.disabled(context.viewState.isActionDisabled)
|
.disabled(context.viewState.isActionDisabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .navigationLink {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .developerOptions)
|
context.send(viewAction: .developerOptions)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("developerOptionsButton")
|
.accessibilityLabel(A11yIdentifiers.settingsScreen.developerOptions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .button {
|
kind: .button {
|
||||||
context.send(viewAction: .account)
|
context.send(viewAction: .account)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("notificationsButton")
|
.accessibilityLabel(A11yIdentifiers.settingsScreen.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message layout
|
// Message layout
|
||||||
@ -130,7 +130,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .navigationLink {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .notifications)
|
context.send(viewAction: .notifications)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("notificationsButton")
|
.accessibilityLabel(A11yIdentifiers.settingsScreen.notifications)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analytics
|
// Analytics
|
||||||
@ -139,7 +139,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .navigationLink {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .analytics)
|
context.send(viewAction: .analytics)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("analyticsButton")
|
.accessibilityLabel(A11yIdentifiers.settingsScreen.analytics)
|
||||||
|
|
||||||
// Report Bug
|
// Report Bug
|
||||||
ListRow(label: .default(title: L10n.commonReportABug,
|
ListRow(label: .default(title: L10n.commonReportABug,
|
||||||
@ -147,7 +147,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .navigationLink {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .reportBug)
|
context.send(viewAction: .reportBug)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("reportBugButton")
|
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.reportBug)
|
||||||
|
|
||||||
// About
|
// About
|
||||||
ListRow(label: .default(title: L10n.commonAbout,
|
ListRow(label: .default(title: L10n.commonAbout,
|
||||||
@ -155,7 +155,7 @@ struct SettingsScreen: View {
|
|||||||
kind: .navigationLink {
|
kind: .navigationLink {
|
||||||
context.send(viewAction: .about)
|
context.send(viewAction: .about)
|
||||||
})
|
})
|
||||||
.accessibilityIdentifier("aboutButton")
|
.accessibilityIdentifier(A11yIdentifiers.settingsScreen.about)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,6 +191,7 @@ struct SettingsScreen: View {
|
|||||||
|
|
||||||
private var doneButton: some View {
|
private var doneButton: some View {
|
||||||
Button(L10n.actionDone, action: close)
|
Button(L10n.actionDone, action: close)
|
||||||
|
.accessibilityLabel(A11yIdentifiers.settingsScreen.done)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func close() {
|
private func close() {
|
||||||
|
@ -72,6 +72,7 @@ struct StartChatScreen: View {
|
|||||||
.imageScale(.small)
|
.imageScale(.small)
|
||||||
}
|
}
|
||||||
.buttonStyle(FormButtonStyle(accessory: .navigationLink))
|
.buttonStyle(FormButtonStyle(accessory: .navigationLink))
|
||||||
|
.accessibilityLabel(A11yIdentifiers.startChatScreen.createRoom)
|
||||||
}
|
}
|
||||||
.compoundFormSection()
|
.compoundFormSection()
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ extension XCUIApplication {
|
|||||||
profileButton.forceTap()
|
profileButton.forceTap()
|
||||||
|
|
||||||
// Open the settings
|
// Open the settings
|
||||||
let settingsButton = buttons["Settings"]
|
let settingsButton = buttons[A11yIdentifiers.homeScreen.settings]
|
||||||
XCTAssertTrue(settingsButton.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(settingsButton.waitForExistence(timeout: 10.0))
|
||||||
settingsButton.tap()
|
settingsButton.tap()
|
||||||
|
|
||||||
|
@ -17,16 +17,84 @@
|
|||||||
import XCTest
|
import XCTest
|
||||||
|
|
||||||
class UserFlowTests: XCTestCase {
|
class UserFlowTests: XCTestCase {
|
||||||
func testUserFlow() {
|
private var app: XCUIApplication!
|
||||||
let app = Application.launch()
|
|
||||||
|
override func setUp() {
|
||||||
|
app = Application.launch()
|
||||||
app.login(currentTestCase: self)
|
app.login(currentTestCase: self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUserFlow() {
|
||||||
|
checkSettings()
|
||||||
|
|
||||||
|
checkInvites()
|
||||||
|
|
||||||
|
checkRoomCreation()
|
||||||
|
|
||||||
// Open the first room in the list.
|
// Open the first room in the list.
|
||||||
let firstRoom = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix)).firstMatch
|
let firstRoom = app.buttons.matching(NSPredicate(format: "identifier BEGINSWITH %@", A11yIdentifiers.homeScreen.roomNamePrefix)).firstMatch
|
||||||
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(firstRoom.waitForExistence(timeout: 10.0))
|
||||||
firstRoom.tap()
|
firstRoom.tap()
|
||||||
|
|
||||||
|
checkAttachmentsPicker()
|
||||||
|
|
||||||
|
checkTimelineItemActionMenu()
|
||||||
|
|
||||||
|
checkRoomDetails()
|
||||||
|
|
||||||
|
app.logout()
|
||||||
|
}
|
||||||
|
|
||||||
|
private func checkInvites() {
|
||||||
|
// Open invites
|
||||||
|
let invitesButton = app.buttons[A11yIdentifiers.homeScreen.invites]
|
||||||
|
XCTAssertTrue(invitesButton.waitForExistence(timeout: 10.0))
|
||||||
|
invitesButton.tap()
|
||||||
|
|
||||||
|
// Go back to the room list
|
||||||
|
tapOnButton("All Chats")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func checkAttachmentsPicker() {
|
||||||
|
for identifier in [A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary,
|
||||||
|
A11yIdentifiers.roomScreen.attachmentPickerDocuments,
|
||||||
|
A11yIdentifiers.roomScreen.attachmentPickerCamera,
|
||||||
|
A11yIdentifiers.roomScreen.attachmentPickerLocation] {
|
||||||
|
tapOnButton(A11yIdentifiers.roomScreen.attachmentPicker)
|
||||||
|
tapOnButton(identifier)
|
||||||
|
tapOnButton("Cancel")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open attachments picker
|
||||||
|
tapOnButton(A11yIdentifiers.roomScreen.attachmentPicker)
|
||||||
|
|
||||||
|
// Open photo library picker
|
||||||
|
tapOnButton(A11yIdentifiers.roomScreen.attachmentPickerPhotoLibrary)
|
||||||
|
|
||||||
|
// Tap on the first image
|
||||||
|
app.scrollViews.images.firstMatch.tap()
|
||||||
|
|
||||||
|
// Cancel the upload flow
|
||||||
|
tapOnButton("Cancel")
|
||||||
|
}
|
||||||
|
|
||||||
|
private func checkRoomCreation() {
|
||||||
|
tapOnButton(A11yIdentifiers.homeScreen.startChat)
|
||||||
|
|
||||||
|
tapOnButton(A11yIdentifiers.startChatScreen.createRoom)
|
||||||
|
|
||||||
|
tapOnButton(A11yIdentifiers.inviteUsersScreen.proceed)
|
||||||
|
|
||||||
|
tapOnButton("Invite people")
|
||||||
|
|
||||||
|
tapOnButton("Start chat")
|
||||||
|
|
||||||
|
tapOnButton("Cancel")
|
||||||
|
|
||||||
|
sleep(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func checkTimelineItemActionMenu() {
|
||||||
// Long press on the last message
|
// Long press on the last message
|
||||||
let lastMessage = app.cells.firstMatch
|
let lastMessage = app.cells.firstMatch
|
||||||
XCTAssertTrue(lastMessage.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(lastMessage.waitForExistence(timeout: 10.0))
|
||||||
@ -36,16 +104,16 @@ class UserFlowTests: XCTestCase {
|
|||||||
let timelineItemActionMenu = app.otherElements[A11yIdentifiers.roomScreen.timelineItemActionMenu].firstMatch
|
let timelineItemActionMenu = app.otherElements[A11yIdentifiers.roomScreen.timelineItemActionMenu].firstMatch
|
||||||
XCTAssertTrue(timelineItemActionMenu.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(timelineItemActionMenu.waitForExistence(timeout: 10.0))
|
||||||
timelineItemActionMenu.swipeDown(velocity: .fast)
|
timelineItemActionMenu.swipeDown(velocity: .fast)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func checkRoomDetails() {
|
||||||
// Open the room details
|
// Open the room details
|
||||||
let roomHeader = app.staticTexts["room-name"]
|
let roomHeader = app.staticTexts[A11yIdentifiers.roomScreen.name]
|
||||||
XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0))
|
XCTAssertTrue(roomHeader.waitForExistence(timeout: 10.0))
|
||||||
roomHeader.tap()
|
roomHeader.tap()
|
||||||
|
|
||||||
// Open the room member details
|
// Open the room member details
|
||||||
let roomMembers = app.buttons["room_details-people"]
|
tapOnButton(A11yIdentifiers.roomDetailsScreen.people)
|
||||||
XCTAssertTrue(roomMembers.waitForExistence(timeout: 10.0))
|
|
||||||
roomMembers.tap()
|
|
||||||
|
|
||||||
// Open the first member's details
|
// Open the first member's details
|
||||||
let firstRoomMember = app.scrollViews.buttons.firstMatch
|
let firstRoomMember = app.scrollViews.buttons.firstMatch
|
||||||
@ -53,25 +121,52 @@ class UserFlowTests: XCTestCase {
|
|||||||
firstRoomMember.tap()
|
firstRoomMember.tap()
|
||||||
|
|
||||||
// Go back to the room member details
|
// Go back to the room member details
|
||||||
var backButton = app.buttons["People"]
|
tapOnButton("People")
|
||||||
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
|
|
||||||
backButton.tap()
|
|
||||||
|
|
||||||
// Go back to the room details
|
// Go back to the room details
|
||||||
backButton = app.buttons["Back"]
|
tapOnButton("Back")
|
||||||
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
|
|
||||||
backButton.tap()
|
|
||||||
|
|
||||||
// Go back to the room
|
// Go back to the room
|
||||||
backButton = app.buttons["Back"]
|
tapOnButton("Back")
|
||||||
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
|
|
||||||
backButton.tap()
|
|
||||||
|
|
||||||
// Go back to the room list
|
// Go back to the room list
|
||||||
backButton = app.navigationBars.firstMatch.buttons["All Chats"]
|
tapOnButton("All Chats")
|
||||||
XCTAssertTrue(backButton.waitForExistence(timeout: 10.0))
|
}
|
||||||
backButton.tap()
|
|
||||||
|
private func checkSettings() {
|
||||||
|
let profileButton = app.buttons[A11yIdentifiers.homeScreen.userAvatar]
|
||||||
|
|
||||||
app.logout()
|
// `Failed to scroll to visible (by AX action) Button` https://stackoverflow.com/a/33534187/730924
|
||||||
|
profileButton.forceTap()
|
||||||
|
|
||||||
|
// Open the settings
|
||||||
|
tapOnButton(A11yIdentifiers.homeScreen.settings)
|
||||||
|
|
||||||
|
// Open analytics
|
||||||
|
tapOnButton(A11yIdentifiers.settingsScreen.analytics)
|
||||||
|
|
||||||
|
// Go back to settings
|
||||||
|
tapOnButton("Settings")
|
||||||
|
|
||||||
|
// Open report a bug
|
||||||
|
tapOnButton(A11yIdentifiers.settingsScreen.reportBug)
|
||||||
|
|
||||||
|
// Go back to settings
|
||||||
|
tapOnButton("Settings")
|
||||||
|
|
||||||
|
// Open about
|
||||||
|
tapOnButton(A11yIdentifiers.settingsScreen.about)
|
||||||
|
|
||||||
|
// Go back to settings
|
||||||
|
tapOnButton("Settings")
|
||||||
|
|
||||||
|
// Close the settings
|
||||||
|
tapOnButton(A11yIdentifiers.settingsScreen.done)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func tapOnButton(_ identifier: String) {
|
||||||
|
let button = app.buttons[identifier]
|
||||||
|
XCTAssertTrue(button.waitForExistence(timeout: 10.0))
|
||||||
|
button.tap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user