Skip to content

Commit

Permalink
Rewrite screenshot tests to use new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Petersson committed May 30, 2024
1 parent 2211f28 commit 3cd581a
Show file tree
Hide file tree
Showing 17 changed files with 278 additions and 453 deletions.
203 changes: 28 additions & 175 deletions ios/MullvadVPN.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

This file was deleted.

28 changes: 0 additions & 28 deletions ios/MullvadVPNScreenshots/Info.plist

This file was deleted.

154 changes: 0 additions & 154 deletions ios/MullvadVPNScreenshots/MullvadVPNScreenshots.swift

This file was deleted.

4 changes: 2 additions & 2 deletions ios/MullvadVPNUITests/CustomListsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CustomListsTests: LoggedInWithTimeUITestCase {
EditCustomListLocationsPage(app)
.scrollToLocationWith(identifier: "se")
.toggleLocationCheckmarkWith(identifier: "se")
.pressBackButton()
.tapBackButton(action: .edit)

CustomListPage(app)
.tapSaveListButton()
Expand Down Expand Up @@ -96,7 +96,7 @@ class CustomListsTests: LoggedInWithTimeUITestCase {
.unfoldLocationwith(identifier: "se")
.unfoldLocationwith(identifier: "se-got")
.toggleLocationCheckmarkWith(identifier: "se-got-wg-001")
.pressBackButton()
.tapBackButton(action: .edit)

CustomListPage(app)
.tapSaveListButton()
Expand Down
8 changes: 6 additions & 2 deletions ios/MullvadVPNUITests/Pages/CustomListPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ class CustomListPage: Page {
editCustomListNameCell.tap()
// Select the entire text with a triple tap
editCustomListNameCell.tap(withNumberOfTaps: 3, numberOfTouches: 1)
// Tap the "delete" key on the on-screen keyboard, the case is sensitive
app.keys["delete"].tap()
// Tap the "delete" key on the on-screen keyboard, the case is sensitive.
// However, on a simulator the keyboard isn't visible by default, so we
// need to take that into consideration.
if app.keys["delete"].isHittable {
app.keys["delete"].tap()
}
editCustomListNameCell.typeText(name)
return self
}
Expand Down
2 changes: 1 addition & 1 deletion ios/MullvadVPNUITests/Pages/DNSSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DNSSettingsPage: Page {

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

return self
Expand Down
15 changes: 13 additions & 2 deletions ios/MullvadVPNUITests/Pages/EditCustomListLocationsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
import XCTest

class EditCustomListLocationsPage: Page {
enum Action {
case add, edit
}

@discardableResult override init(_ app: XCUIApplication) {
super.init(app)

Expand Down Expand Up @@ -46,8 +50,15 @@ class EditCustomListLocationsPage: Page {
return self
}

@discardableResult func pressBackButton() -> Self {
app.navigationBars["Edit locations"].buttons.firstMatch.tap()
@discardableResult func tapBackButton(action: Action) -> Self {
let navigationBarName = switch action {
case .add:
"Add locations"
case .edit:
"Edit locations"
}

app.navigationBars[navigationBarName].buttons.firstMatch.tap()
return self
}
}
4 changes: 4 additions & 0 deletions ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class TunnelControlPage: Page {
let protocolName: String
}

var connectionIsSecured: Bool {
app.staticTexts[AccessibilityIdentifier.connectionStatusConnectedLabel].exists
}

/// 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.
/// - Parameters:
/// - attemptsCount: number of connection attempts to look for
Expand Down
12 changes: 6 additions & 6 deletions ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class VPNSettingsPage: Page {
super.init(app)
}

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

return expandButton
}
Expand All @@ -37,18 +37,18 @@ class VPNSettingsPage: Page {
}

@discardableResult func tapWireGuardPortsExpandButton() -> Self {
cellExpandCollapseButton(AccessibilityIdentifier.wireGuardPortsCell).tap()
cellExpandButton(AccessibilityIdentifier.wireGuardPortsCell).tap()
return self
}

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

return self
}

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

return self
}
Expand All @@ -72,7 +72,7 @@ class VPNSettingsPage: Page {
}

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

return self
}
Expand Down
Loading

0 comments on commit 3cd581a

Please sign in to comment.