Switch UI tests to iPhone 15, fix the broken ones

This commit is contained in:
Stefan Ceriu
2024-03-19 15:15:11 +02:00
parent 70d591ea00
commit 72061ce4f9
6 changed files with 105 additions and 77 deletions

View File

@@ -0,0 +1,28 @@
//
// Copyright 2024 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import XCTest
extension XCUIElement {
func forceTap() {
if isHittable {
tap()
} else {
let coordinate: XCUICoordinate = coordinate(withNormalizedOffset: .init(dx: 0.5, dy: 0.5))
coordinate.tap()
}
}
}

View File

@@ -56,7 +56,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenOtherSessionsMoreMenuButtonSelected_moreMenuIsCorrect() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.all.title)
app.buttons["More"].tap()
app.buttons["More"].forceTap()
XCTAssertTrue(app.buttons["Select sessions"].exists)
XCTAssertTrue(app.buttons["Sign out of 6 sessions"].exists)
}
@@ -64,7 +64,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenOtherSessionsSelectSessionsSelected_navBarContainsCorrectButtons() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.all.title)
app.buttons["More"].tap()
app.buttons["More"].forceTap()
app.buttons["Select sessions"].tap()
let signOutButton = app.buttons["Sign out"]
XCTAssertTrue(signOutButton.exists)
@@ -76,7 +76,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenOtherSessionsSelectAllSelected_navBarContainsCorrectButtons() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.all.title)
app.buttons["More"].tap()
app.buttons["More"].forceTap()
app.buttons["Select sessions"].tap()
app.buttons["Select All"].tap()
XCTAssertTrue(app.buttons["Deselect All"].exists)
@@ -85,7 +85,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenAllOtherSessionsAreSelected_navBarContainsCorrectButtons() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.all.title)
app.buttons["More"].tap()
app.buttons["More"].forceTap()
app.buttons["Select sessions"].tap()
for i in 0...MockUserOtherSessionsScreenState.all.allSessions().count - 1 {
app.buttons["UserSessionListItem_\(i)"].tap()
@@ -95,7 +95,7 @@ class UserOtherSessionsUITests: MockScreenTestCase {
func test_whenChangingSessionSelection_signOutButtonChangesItState() {
app.goToScreenWithIdentifier(MockUserOtherSessionsScreenState.all.title)
app.buttons["More"].tap()
app.buttons["More"].forceTap()
app.buttons["Select sessions"].tap()
let signOutButton = app.buttons["Sign out"]
XCTAssertTrue(signOutButton.exists)

View File

@@ -80,35 +80,33 @@ struct UserOtherSessionsToolbar: ToolbarContent {
}
private func optionsMenu() -> some View {
Button { } label: {
Menu {
if showDeviceLogout { // As you can only sign out the selected sessions, we don't allow selection when you're unable to sign out devices.
Button {
isEditModeEnabled = true
} label: {
Label(VectorL10n.userOtherSessionMenuSelectSessions, systemImage: "checkmark.circle")
}
.disabled(sessionCount == 0)
}
Menu {
if showDeviceLogout { // As you can only sign out the selected sessions, we don't allow selection when you're unable to sign out devices.
Button {
isShowLocationEnabled.toggle()
isEditModeEnabled = true
} label: {
Label(showLocationInfo: isShowLocationEnabled)
Label(VectorL10n.userOtherSessionMenuSelectSessions, systemImage: "checkmark.circle")
}
if sessionCount > 0, showDeviceLogout {
DestructiveButton {
onSignOut()
} label: {
Label(VectorL10n.userOtherSessionMenuSignOutSessions(String(sessionCount)), systemImage: "rectangle.portrait.and.arrow.forward.fill")
}
}
} label: {
Image(systemName: "ellipsis")
.padding(.horizontal, 4)
.padding(.vertical, 12)
.disabled(sessionCount == 0)
}
Button {
isShowLocationEnabled.toggle()
} label: {
Label(showLocationInfo: isShowLocationEnabled)
}
if sessionCount > 0, showDeviceLogout {
DestructiveButton {
onSignOut()
} label: {
Label(VectorL10n.userOtherSessionMenuSignOutSessions(String(sessionCount)), systemImage: "rectangle.portrait.and.arrow.forward.fill")
}
}
} label: {
Image(systemName: "ellipsis")
.padding(.horizontal, 4)
.padding(.vertical, 12)
}
.accessibilityIdentifier("More")
}

View File

@@ -67,7 +67,7 @@ class UserSessionOverviewUITests: MockScreenTestCase {
let navTitle = VectorL10n.userSessionOverviewSessionTitle
let barButton = app.navigationBars[navTitle].buttons["Menu"]
XCTAssertTrue(barButton.exists)
barButton.tap()
barButton.forceTap()
XCTAssertTrue(app.buttons[VectorL10n.signOut].exists)
XCTAssertTrue(app.buttons[VectorL10n.manageSessionRename].exists)
}