Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add end to end connection tests for multihop ios 778 #6914

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 18 additions & 13 deletions ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ class ConnectionPanelView: UIView {
}

private let collapseView: ConnectionPanelCollapseView = {
let button = ConnectionPanelCollapseView()
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 @@ -294,24 +298,25 @@ class ConnectionPanelCollapseView: UIStackView {
}()

private(set) var imageView: UIImageView = {
return UIImageView()
let imageView = UIImageView()
imageView.contentMode = .scaleAspectFit
return imageView
}()

override init(frame: CGRect) {
super.init(frame: frame)

let imageContainer = UIStackView()
imageContainer.axis = .vertical
imageContainer.addArrangedSubview(imageView)
imageContainer.addArrangedSubview(UIView()) // Pushes content up.

addArrangedSubview(title)
addArrangedSubview(imageContainer)
addArrangedSubview(imageView)

title.setContentHuggingPriority(.defaultLow, for: .horizontal)
title.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)

imageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
imageView.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
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
Loading