Skip to content

Commit 3cd581a

Browse files
author
Jon Petersson
committed
Rewrite screenshot tests to use new syntax
1 parent 2211f28 commit 3cd581a

17 files changed

+278
-453
lines changed

ios/MullvadVPN.xcodeproj/project.pbxproj

+28-175
Large diffs are not rendered by default.

ios/MullvadVPN.xcodeproj/xcshareddata/xcschemes/MullvadVPNScreenshots.xcscheme

-81
This file was deleted.

ios/MullvadVPNScreenshots/Info.plist

-28
This file was deleted.

ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift

-154
This file was deleted.

ios/MullvadVPNUITests/CustomListsTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CustomListsTests: LoggedInWithTimeUITestCase {
6565
EditCustomListLocationsPage(app)
6666
.scrollToLocationWith(identifier: "se")
6767
.toggleLocationCheckmarkWith(identifier: "se")
68-
.pressBackButton()
68+
.tapBackButton(action: .edit)
6969

7070
CustomListPage(app)
7171
.tapSaveListButton()
@@ -96,7 +96,7 @@ class CustomListsTests: LoggedInWithTimeUITestCase {
9696
.unfoldLocationwith(identifier: "se")
9797
.unfoldLocationwith(identifier: "se-got")
9898
.toggleLocationCheckmarkWith(identifier: "se-got-wg-001")
99-
.pressBackButton()
99+
.tapBackButton(action: .edit)
100100

101101
CustomListPage(app)
102102
.tapSaveListButton()

ios/MullvadVPNUITests/Pages/CustomListPage.swift

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,12 @@ class CustomListPage: Page {
3939
editCustomListNameCell.tap()
4040
// Select the entire text with a triple tap
4141
editCustomListNameCell.tap(withNumberOfTaps: 3, numberOfTouches: 1)
42-
// Tap the "delete" key on the on-screen keyboard, the case is sensitive
43-
app.keys["delete"].tap()
42+
// Tap the "delete" key on the on-screen keyboard, the case is sensitive.
43+
// However, on a simulator the keyboard isn't visible by default, so we
44+
// need to take that into consideration.
45+
if app.keys["delete"].isHittable {
46+
app.keys["delete"].tap()
47+
}
4448
editCustomListNameCell.typeText(name)
4549
return self
4650
}

ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class DNSSettingsPage: Page {
3838

3939
@discardableResult func tapDNSContentBlockersHeaderExpandButton() -> Self {
4040
let headerView = app.otherElements[AccessibilityIdentifier.dnsContentBlockersHeaderView]
41-
let expandButton = headerView.buttons[AccessibilityIdentifier.collapseButton]
41+
let expandButton = headerView.buttons[AccessibilityIdentifier.expandButton]
4242
expandButton.tap()
4343

4444
return self

ios/MullvadVPNUITests/Pages/EditCustomListLocationsPage.swift

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
import XCTest
1010

1111
class EditCustomListLocationsPage: Page {
12+
enum Action {
13+
case add, edit
14+
}
15+
1216
@discardableResult override init(_ app: XCUIApplication) {
1317
super.init(app)
1418

@@ -46,8 +50,15 @@ class EditCustomListLocationsPage: Page {
4650
return self
4751
}
4852

49-
@discardableResult func pressBackButton() -> Self {
50-
app.navigationBars["Edit locations"].buttons.firstMatch.tap()
53+
@discardableResult func tapBackButton(action: Action) -> Self {
54+
let navigationBarName = switch action {
55+
case .add:
56+
"Add locations"
57+
case .edit:
58+
"Edit locations"
59+
}
60+
61+
app.navigationBars[navigationBarName].buttons.firstMatch.tap()
5162
return self
5263
}
5364
}

ios/MullvadVPNUITests/Pages/TunnelControlPage.swift

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class TunnelControlPage: Page {
1616
let protocolName: String
1717
}
1818

19+
var connectionIsSecured: Bool {
20+
app.staticTexts[AccessibilityIdentifier.connectionStatusConnectedLabel].exists
21+
}
22+
1923
/// Poll the "in address row" label for its updated values and output an array of ConnectionAttempt objects representing the connection attempts that have been communicated through the UI.
2024
/// - Parameters:
2125
/// - attemptsCount: number of connection attempts to look for

ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ class VPNSettingsPage: Page {
1414
super.init(app)
1515
}
1616

17-
private func cellExpandCollapseButton(_ cellAccessiblityIdentifier: AccessibilityIdentifier) -> XCUIElement {
17+
private func cellExpandButton(_ cellAccessiblityIdentifier: AccessibilityIdentifier) -> XCUIElement {
1818
let table = app.tables[AccessibilityIdentifier.vpnSettingsTableView]
1919
let matchingCells = table.otherElements.containing(.any, identifier: cellAccessiblityIdentifier.rawValue)
20-
let expandButton = matchingCells.buttons[AccessibilityIdentifier.collapseButton]
20+
let expandButton = matchingCells.buttons[AccessibilityIdentifier.expandButton]
2121

2222
return expandButton
2323
}
@@ -37,18 +37,18 @@ class VPNSettingsPage: Page {
3737
}
3838

3939
@discardableResult func tapWireGuardPortsExpandButton() -> Self {
40-
cellExpandCollapseButton(AccessibilityIdentifier.wireGuardPortsCell).tap()
40+
cellExpandButton(AccessibilityIdentifier.wireGuardPortsCell).tap()
4141
return self
4242
}
4343

4444
@discardableResult func tapWireGuardObfuscationExpandButton() -> Self {
45-
cellExpandCollapseButton(AccessibilityIdentifier.wireGuardObfuscationCell).tap()
45+
cellExpandButton(AccessibilityIdentifier.wireGuardObfuscationCell).tap()
4646

4747
return self
4848
}
4949

5050
@discardableResult func tapUDPOverTCPPortExpandButton() -> Self {
51-
cellExpandCollapseButton(AccessibilityIdentifier.udpOverTCPPortCell).tap()
51+
cellExpandButton(AccessibilityIdentifier.udpOverTCPPortCell).tap()
5252

5353
return self
5454
}
@@ -72,7 +72,7 @@ class VPNSettingsPage: Page {
7272
}
7373

7474
@discardableResult func tapQuantumResistantTunnelExpandButton() -> Self {
75-
cellExpandCollapseButton(AccessibilityIdentifier.quantumResistantTunnelCell).tap()
75+
cellExpandButton(AccessibilityIdentifier.quantumResistantTunnelCell).tap()
7676

7777
return self
7878
}

0 commit comments

Comments
 (0)