Skip to content

Commit

Permalink
Add end-to-end test for multihop
Browse files Browse the repository at this point in the history
  • Loading branch information
mojganii authored and buggmagnet committed Oct 8, 2024
1 parent ecd76bc commit 8b1e180
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 21 deletions.
8 changes: 0 additions & 8 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2361,13 +2361,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */ = {
isa = PBXGroup;
children = (
);
path = EncryptedDnsProxy;
sourceTree = "<group>";
};
062B45A228FD4C0F00746E77 /* Assets */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4191,7 +4184,6 @@
F0DC77A02B2223290087F09D /* Transport */ = {
isa = PBXGroup;
children = (
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */,
F0164ED02B4F2DCB0020268D /* AccessMethodIterator.swift */,
F0DC77A32B2315800087F09D /* Direct */,
F0E5B2F62C9C689C0007F78C /* EncryptedDNS */,
Expand Down
1 change: 0 additions & 1 deletion ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public enum AccessibilityIdentifier: String {
case appLogsShareButton
case applyButton
case cancelButton
case connectionPanelButton
case continueWithLoginButton
case collapseButton
case expandButton
Expand Down
17 changes: 8 additions & 9 deletions ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ class ConnectionPanelView: UIView {
}

private let collapseView: ConnectionPanelCollapseView = {
let button = ConnectionPanelCollapseView()
button.axis = .horizontal
button.alignment = .top
button.distribution = .fill
button.translatesAutoresizingMaskIntoConstraints = false
button.tintColor = .white
return button
let collapseView = ConnectionPanelCollapseView()
collapseView.axis = .horizontal
collapseView.alignment = .top
collapseView.distribution = .fill
collapseView.translatesAutoresizingMaskIntoConstraints = false
collapseView.tintColor = .white
collapseView.isAccessibilityElement = false
return collapseView
}()

private let inAddressRow = ConnectionPanelAddressRow()
Expand Down Expand Up @@ -316,8 +317,6 @@ class ConnectionPanelCollapseView: UIStackView {
addArrangedSubview(UIView()) // Pushes content left.

updateImage()

accessibilityIdentifier = .connectionPanelButton
}

required init(coder: NSCoder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class TunnelControlView: UIView {
private let locationContainerView: UIStackView = {
let view = UIStackView()
view.translatesAutoresizingMaskIntoConstraints = false
view.isAccessibilityElement = true
view.isAccessibilityElement = false
view.accessibilityTraits = .summaryElement
view.axis = .vertical
view.spacing = 8
Expand Down
11 changes: 9 additions & 2 deletions ios/MullvadVPNUITests/Pages/TunnelControlPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class TunnelControlPage: Page {
}

@discardableResult func tapRelayStatusExpandCollapseButton() -> Self {
app.buttons[AccessibilityIdentifier.relayStatusCollapseButton].tap()
app.otherElements[AccessibilityIdentifier.relayStatusCollapseButton].press(forDuration: .leastNonzeroMagnitude)
return self
}

Expand Down Expand Up @@ -202,6 +202,13 @@ class TunnelControlPage: Page {
return self
}

/// Verify that the app attempts to connect over Multihop.
@discardableResult func verifyConnectingOverMultihop() -> Self {
let relayName = getCurrentRelayName().lowercased()
XCTAssertTrue(relayName.contains("via"))
return self
}

func getInIPAddressFromConnectionStatus() -> String {
let inAddressRow = app.otherElements[AccessibilityIdentifier.connectionPanelInAddressRow]

Expand All @@ -215,7 +222,7 @@ class TunnelControlPage: Page {
}

func getCurrentRelayName() -> String {
let relayExpandButton = app.buttons[.relayStatusCollapseButton]
let relayExpandButton = app.otherElements[.relayStatusCollapseButton]

guard let relayName = relayExpandButton.value as? String else {
XCTFail("Failed to read relay name from tunnel control page")
Expand Down
18 changes: 18 additions & 0 deletions ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,22 @@ class VPNSettingsPage: Page {
XCTAssertEqual(switchValue, "1")
return self
}

@discardableResult func tapDaitaSwitchIfOn() -> Self {
let switchElement = app.cells[.daitaSwitch].switches[AccessibilityIdentifier.customSwitch]

if switchElement.value as? String == "1" {
tapDaitaSwitch()
}
return self
}

@discardableResult func tapMultihopSwitchIfOn() -> Self {
let switchElement = app.cells[.multihopSwitch].switches[AccessibilityIdentifier.customSwitch]

if switchElement.value as? String == "1" {
tapMultihopSwitch()
}
return self
}
}
37 changes: 37 additions & 0 deletions ios/MullvadVPNUITests/RelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,43 @@ class RelayTests: LoggedInWithTimeUITestCase {
.tapDisconnectButton()
}

func testMultihopSettings() throws {
// Undo enabling Multihop in teardown
addTeardownBlock {
HeaderBar(self.app)
.tapSettingsButton()

SettingsPage(self.app)
.tapVPNSettingsCell()

VPNSettingsPage(self.app)
.tapMultihopSwitchIfOn()
}

HeaderBar(app)
.tapSettingsButton()

SettingsPage(app)
.tapVPNSettingsCell()

VPNSettingsPage(app)
.tapMultihopSwitch()
.tapBackButton()

SettingsPage(app)
.tapDoneButton()

TunnelControlPage(app)
.tapSecureConnectionButton()

allowAddVPNConfigurationsIfAsked()

TunnelControlPage(app)
.waitForSecureConnectionLabel()
.verifyConnectingOverMultihop()
.tapDisconnectButton()
}

/// Connect to a relay in the default country and city, get name and IP address of the relay the app successfully connects to. Assumes user is logged on and at tunnel control page.
private func getDefaultRelayInfo() -> RelayInfo {
TunnelControlPage(app)
Expand Down

0 comments on commit 8b1e180

Please sign in to comment.