Skip to content

Commit faea2de

Browse files
committed
Fix UI Tests and run on PRs
- Add missing screen states. - Detect the bottom of the screen list and stop scrolling if screen state wasn't found. - Remove unimplemented tests to speed up the run. - Remove failed button checks in MatrixItemChooserUITests
1 parent 3184280 commit faea2de

File tree

17 files changed

+149
-83
lines changed

17 files changed

+149
-83
lines changed

.github/workflows/ci-ui-tests.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: UI Tests CI
2+
3+
on:
4+
# Triggers the workflow on any pull request
5+
pull_request:
6+
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
env:
11+
# Make the git branch for a PR available to our Fastfile
12+
MX_GIT_BRANCH: ${{ github.event.pull_request.head.ref }}
13+
14+
jobs:
15+
tests:
16+
name: UI Tests
17+
runs-on: macos-11
18+
19+
concurrency:
20+
# Only allow a single run of this workflow on each branch, automatically cancelling older runs.
21+
group: ui-tests-${{ github.head_ref }}
22+
cancel-in-progress: true
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
27+
# Common cache
28+
# Note: GH actions do not support yaml anchor yet. We need to duplicate this for every job
29+
- uses: actions/cache@v2
30+
with:
31+
path: Pods
32+
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-pods-
35+
- uses: actions/cache@v2
36+
with:
37+
path: vendor/bundle
38+
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-gems-
41+
42+
# Make sure we use the latest version of MatrixSDK
43+
- name: Reset MatrixSDK pod
44+
run: rm -rf Pods/MatrixSDK
45+
46+
# Common setup
47+
# Note: GH actions do not support yaml anchor yet. We need to duplicate this for every job
48+
- name: Bundle install
49+
run: |
50+
bundle config path vendor/bundle
51+
bundle install --jobs 4 --retry 3
52+
- name: Use right MatrixSDK versions
53+
run: bundle exec fastlane point_dependencies_to_related_branches
54+
55+
# Main step
56+
- name: Unit tests
57+
run: bundle exec fastlane uitest

.github/workflows/release-alpha.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
if: "${{ env.P12_KEY != '' || env.P12_PASSWORD_KEY != '' }}"
2626
run: echo "::set-output name=defined::true"
2727
build:
28-
# Run job if secrets are avilable (not avaiable for forks).
28+
# Run job if secrets are available (not available for forks).
2929
needs: [check-secret]
3030
if: needs.check-secret.outputs.out-key == 'true'
3131
name: Release
@@ -84,7 +84,7 @@ jobs:
8484
- name: Build Ad-hoc release and send it to Diawi
8585
run: bundle exec fastlane alpha
8686
env:
87-
# Automaticaly bypass 2FA upgrade if possible on Apple account.
87+
# Automatically bypass 2FA upgrade if possible on Apple account.
8888
SPACESHIP_SKIP_2FA_UPGRADE: true
8989
APPLE_ID: ${{ secrets.FASTLANE_USER }}
9090
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}

Riot/Generated/Strings.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8106,15 +8106,18 @@ public class VectorL10n: NSObject {
81068106

81078107
extension VectorL10n {
81088108
static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
8109-
let format = NSLocalizedString(key, tableName: table, bundle: Bundle.app, comment: "")
8110-
let locale: Locale
8111-
if let providedLocale = LocaleProvider.locale {
8112-
locale = providedLocale
8113-
} else {
8114-
locale = Locale.current
8115-
}
8116-
8117-
return String(format: format, locale: locale, arguments: args)
8109+
let format = NSLocalizedString(key, tableName: table, bundle: bundle, comment: "")
8110+
let locale = LocaleProvider.locale ?? Locale.current
8111+
return String(format: format, locale: locale, arguments: args)
8112+
}
8113+
/// The bundle to load strings from. This will be the app's bundle unless running
8114+
/// the UI tests target, in which case the strings are contained in the tests bundle.
8115+
static let bundle: Bundle = {
8116+
if ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil {
8117+
// The tests bundle is embedded inside a runner. Find the bundle for VectorL10n.
8118+
return Bundle(for: VectorL10n.self)
81188119
}
8120+
return Bundle.app
8121+
}()
81198122
}
81208123

RiotSwiftUI/Modules/Common/Mock/MockAppScreens.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,15 @@ enum MockAppScreens {
2626
MockOnboardingCongratulationsScreenState.self,
2727
MockOnboardingUseCaseSelectionScreenState.self,
2828
MockOnboardingSplashScreenScreenState.self,
29+
MockStaticLocationViewingScreenState.self,
2930
MockLocationSharingScreenState.self,
3031
MockAnalyticsPromptScreenState.self,
3132
MockUserSuggestionScreenState.self,
3233
MockPollEditFormScreenState.self,
3334
MockSpaceCreationEmailInvitesScreenState.self,
35+
MockSpaceSettingsScreenState.self,
36+
MockRoomAccessTypeChooserScreenState.self,
37+
MockRoomUpgradeScreenState.self,
3438
MockMatrixItemChooserScreenState.self,
3539
MockSpaceCreationMenuScreenState.self,
3640
MockSpaceCreationRoomsScreenState.self,

RiotSwiftUI/Modules/Common/Mock/ScreenList.swift

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ struct ScreenList: View {
3030
var body: some View {
3131
NavigationView {
3232
List {
33-
ForEach(0..<allStates.count) { i in
34-
let state = allStates[i]
35-
NavigationLink(destination: state.view) {
36-
Text(state.screenTitle)
33+
SwiftUI.Section {
34+
ForEach(0..<allStates.count, id: \.self) { i in
35+
let state = allStates[i]
36+
NavigationLink(destination: state.view) {
37+
Text(state.screenTitle)
38+
}
3739
}
3840
}
41+
42+
SwiftUI.Section {
43+
Text("Last Item")
44+
.accessibilityIdentifier("lastItem")
45+
}
3946
}
4047
}
4148
.navigationTitle("Screen States")

RiotSwiftUI/Modules/Common/Test/UI/XCUIApplication+Riot.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ import XCTest
2020
extension XCUIApplication {
2121
func goToScreenWithIdentifier(_ identifier: String) {
2222
let button = self.buttons[identifier]
23+
let lastLabel = staticTexts["lastItem"]
2324

24-
while !button.isHittable {
25+
while !button.isHittable && !lastLabel.isHittable {
2526
self.tables.firstMatch.swipeUp()
2627
}
2728

RiotSwiftUI/Modules/Room/RoomAccess/RoomAccessTypeChooser/Test/UI/RoomAccessTypeChooserUITests.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,5 @@ import RiotSwiftUI
1919

2020
@available(iOS 14.0, *)
2121
class RoomAccessTypeChooserUITests: MockScreenTest {
22-
23-
override class var screenType: MockScreenState.Type {
24-
return MockRoomAccessTypeChooserScreenState.self
25-
}
26-
27-
override class func createTest() -> MockScreenTest {
28-
return RoomAccessTypeChooserUITests(selector: #selector(verifyRoomAccessTypeChooserScreen))
29-
}
30-
31-
func verifyRoomAccessTypeChooserScreen() throws {
32-
guard let screenState = screenState as? MockRoomAccessTypeChooserScreenState else { fatalError("no screen") }
33-
}
34-
22+
// Tests to be implemented.
3523
}

RiotSwiftUI/Modules/Room/RoomUpgrade/Test/UI/RoomUpgradeUITests.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,5 @@ import RiotSwiftUI
1919

2020
@available(iOS 14.0, *)
2121
class RoomUpgradeUITests: MockScreenTest {
22-
23-
override class var screenType: MockScreenState.Type {
24-
return MockRoomUpgradeScreenState.self
25-
}
26-
27-
override class func createTest() -> MockScreenTest {
28-
return RoomUpgradeUITests(selector: #selector(verifyRoomUpgradeScreen))
29-
}
30-
31-
func verifyRoomUpgradeScreen() throws {
32-
guard let screenState = screenState as? MockRoomUpgradeScreenState else { fatalError("no screen") }
33-
}
34-
22+
// Tests to be implemented.
3523
}

RiotSwiftUI/Modules/Room/StaticLocationSharingViewer/Test/UI/StaticLocationViewingUITests.swift

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,29 @@ import RiotSwiftUI
1919

2020
@available(iOS 14.0, *)
2121
class StaticLocationViewingUITests: MockScreenTest {
22-
23-
private var app: XCUIApplication!
2422

25-
override func setUp() {
26-
continueAfterFailure = false
27-
28-
app = XCUIApplication()
29-
app.launch()
23+
override class var screenType: MockScreenState.Type {
24+
return MockStaticLocationViewingScreenState.self
3025
}
31-
32-
func testInitialExistingLocation() {
33-
goToScreenWithIdentifier(MockStaticLocationViewingScreenState.showUserLocation.title)
26+
27+
override class func createTest() -> MockScreenTest {
28+
return StaticLocationViewingUITests(selector: #selector(verifyStaticLocationViewingScreen))
29+
}
30+
31+
func verifyStaticLocationViewingScreen() {
32+
guard let screenState = screenState as? MockStaticLocationViewingScreenState else { fatalError("no screen") }
3433

35-
XCTAssertTrue(app.buttons["Cancel"].exists)
36-
XCTAssertTrue(app.buttons["StaticLocationView.shareButton"].exists)
37-
XCTAssertTrue(app.otherElements["Map"].exists)
34+
switch screenState {
35+
case .showUserLocation:
36+
verifyInitialExistingLocation()
37+
case .showPinLocation:
38+
verifyInitialExistingLocation()
39+
}
40+
}
41+
42+
func verifyInitialExistingLocation() {
43+
XCTAssertTrue(app.buttons["Cancel"].exists, "The cancel button should exist.")
44+
XCTAssertTrue(app.buttons["shareButton"].exists, "The share button should exist.")
45+
XCTAssertTrue(app.otherElements["Map"].exists, "The map view should exist.")
3846
}
3947
}

RiotSwiftUI/Modules/Room/StaticLocationSharingViewer/View/StaticLocationView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ struct StaticLocationView: View {
6161
viewModel.send(viewAction: .share)
6262
} label: {
6363
Image(uiImage: Asset.Images.locationShareIcon.image)
64-
.accessibilityIdentifier("LocationSharingView.shareButton")
6564
}
6665
.disabled(!viewModel.viewState.shareButtonEnabled)
66+
.accessibilityIdentifier("shareButton")
6767
}
6868
}
6969
.navigationBarTitleDisplayMode(.inline)

0 commit comments

Comments
 (0)