Skip to content

Commit

Permalink
Switch UI tests to iPhone 15, fix the broken ones
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Mar 19, 2024
1 parent b1c6ac4 commit 608f760
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 77 deletions.
92 changes: 47 additions & 45 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ GIT
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
CFPropertyList (3.0.7)
base64
nkf
rexml
activesupport (7.1.2)
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand All @@ -19,32 +21,32 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.15)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.859.0)
aws-sdk-core (3.188.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (1.899.0)
aws-sdk-core (3.191.4)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.5)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.73.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-kms (1.78.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.140.0)
aws-sdk-core (~> 3, >= 3.188.0)
aws-sdk-s3 (1.146.0)
aws-sdk-core (~> 3, >= 3.191.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.6)
aws-sigv4 (1.7.0)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
bigdecimal (3.1.4)
bigdecimal (3.1.7)
claide (1.1.0)
clamp (1.3.2)
cocoapods (1.14.3)
Expand Down Expand Up @@ -88,20 +90,19 @@ GEM
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
declarative (0.0.20)
digest-crc (0.6.5)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20231109)
domain_name (0.6.20240107)
dotenv (2.8.1)
drb (2.2.0)
ruby2_keywords
drb (2.2.1)
emoji_regex (3.2.3)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
excon (0.104.0)
excon (0.110.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -130,8 +131,8 @@ GEM
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.7)
fastlane (2.217.0)
fastimage (2.3.0)
fastlane (2.219.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand All @@ -150,6 +151,7 @@ GEM
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.0.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
Expand All @@ -158,7 +160,7 @@ GEM
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (~> 0.1.1)
optparse (>= 0.1.1)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.3)
Expand All @@ -172,7 +174,7 @@ GEM
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-brew (0.1.1)
fastlane-plugin-sentry (1.16.0)
fastlane-plugin-sentry (1.20.0)
os (~> 1.1, >= 1.1.4)
fastlane-plugin-versioning (0.5.2)
fastlane-plugin-xcodegen (1.1.0)
Expand All @@ -181,34 +183,33 @@ GEM
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.53.0)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.2)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.29.0)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-core (1.7.0)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.3.1)
google-cloud-storage (1.45.0)
google-cloud-errors (1.4.0)
google-cloud-storage (1.47.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.29.0)
google-apis-storage_v1 (~> 0.31.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
Expand All @@ -222,29 +223,31 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.1)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
jmespath (1.6.2)
json (2.6.3)
jwt (2.7.1)
json (2.7.1)
jwt (2.8.1)
base64
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest (5.22.3)
molinillo (0.8.0)
multi_json (1.15.0)
multipart-post (2.3.0)
multipart-post (2.4.0)
mutex_m (0.2.0)
nanaimo (0.3.0)
nap (1.1.0)
naturally (2.2.1)
netrc (0.11.0)
nokogiri (1.15.5)
nkf (0.2.0)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
optparse (0.1.1)
optparse (0.4.0)
os (1.1.4)
plist (3.7.0)
plist (3.7.1)
public_suffix (4.0.7)
racc (1.7.3)
rake (13.1.0)
Expand All @@ -259,7 +262,7 @@ GEM
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.18.0)
signet (0.19.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
Expand All @@ -278,7 +281,7 @@ GEM
unicode-display_width (>= 1.1.1, < 3)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-screen (0.8.1)
tty-screen (0.8.2)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
typhoeus (1.4.1)
Expand All @@ -287,12 +290,11 @@ GEM
concurrent-ruby (~> 1.0)
uber (0.1.0)
unicode-display_width (2.5.0)
webrick (1.8.1)
word_wrap (1.0.0)
xcode-install (2.8.1)
claide (>= 0.9.1)
fastlane (>= 2.1.0, < 3.0.0)
xcodeproj (1.23.0)
xcodeproj (1.24.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
Expand Down
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: c87b532985dd755b373732f841e3bcfe616f4e4f

COCOAPODS: 1.14.3
COCOAPODS: 1.15.2
28 changes: 28 additions & 0 deletions RiotSwiftUI/Modules/Common/Test/UI/XCUIElement.swift
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ 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)
}

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)
Expand All @@ -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)
Expand All @@ -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()
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

if sessionCount > 0, showDeviceLogout {
DestructiveButton {
onSignOut()
} label: {
Label(VectorL10n.userOtherSessionMenuSignOutSessions(String(sessionCount)), systemImage: "rectangle.portrait.and.arrow.forward.fill")
}
Label(VectorL10n.userOtherSessionMenuSelectSessions, systemImage: "checkmark.circle")
}
.disabled(sessionCount == 0)
}

Button {
isShowLocationEnabled.toggle()
} label: {
Image(systemName: "ellipsis")
.padding(.horizontal, 4)
.padding(.vertical, 12)
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")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ platform :ios do
run_tests(
workspace: "Riot.xcworkspace",
scheme: "RiotSwiftUITests",
device: "iPhone 14",
device: "iPhone 15",
code_coverage: true,
# Test result configuration
result_bundle: true,
Expand Down

0 comments on commit 608f760

Please sign in to comment.