Skip to content

Commit 9f670e0

Browse files
committed
Add end to end test for multihop
1 parent 6ed7b05 commit 9f670e0

File tree

7 files changed

+70
-21
lines changed

7 files changed

+70
-21
lines changed

ios/MullvadVPN.xcodeproj/project.pbxproj

-8
Original file line numberDiff line numberDiff line change
@@ -2359,13 +2359,6 @@
23592359
/* End PBXFrameworksBuildPhase section */
23602360

23612361
/* Begin PBXGroup section */
2362-
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */ = {
2363-
isa = PBXGroup;
2364-
children = (
2365-
);
2366-
path = EncryptedDnsProxy;
2367-
sourceTree = "<group>";
2368-
};
23692362
062B45A228FD4C0F00746E77 /* Assets */ = {
23702363
isa = PBXGroup;
23712364
children = (
@@ -4188,7 +4181,6 @@
41884181
F0DC77A02B2223290087F09D /* Transport */ = {
41894182
isa = PBXGroup;
41904183
children = (
4191-
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */,
41924184
F0164ED02B4F2DCB0020268D /* AccessMethodIterator.swift */,
41934185
F0DC77A32B2315800087F09D /* Direct */,
41944186
F0E5B2F62C9C689C0007F78C /* EncryptedDNS */,

ios/MullvadVPN/Classes/AccessbilityIdentifier.swift

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public enum AccessibilityIdentifier: String {
2121
case appLogsShareButton
2222
case applyButton
2323
case cancelButton
24-
case connectionPanelButton
2524
case continueWithLoginButton
2625
case collapseButton
2726
case expandButton

ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift

+8-9
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ class ConnectionPanelView: UIView {
4848
}
4949

5050
private let collapseView: ConnectionPanelCollapseView = {
51-
let button = ConnectionPanelCollapseView()
52-
button.axis = .horizontal
53-
button.alignment = .top
54-
button.distribution = .fill
55-
button.translatesAutoresizingMaskIntoConstraints = false
56-
button.tintColor = .white
57-
return button
51+
let collapseView = ConnectionPanelCollapseView()
52+
collapseView.axis = .horizontal
53+
collapseView.alignment = .top
54+
collapseView.distribution = .fill
55+
collapseView.translatesAutoresizingMaskIntoConstraints = false
56+
collapseView.tintColor = .white
57+
collapseView.isAccessibilityElement = false
58+
return collapseView
5859
}()
5960

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

318319
updateImage()
319-
320-
accessibilityIdentifier = .connectionPanelButton
321320
}
322321

323322
required init(coder: NSCoder) {

ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class TunnelControlView: UIView {
4444
private let locationContainerView: UIStackView = {
4545
let view = UIStackView()
4646
view.translatesAutoresizingMaskIntoConstraints = false
47-
view.isAccessibilityElement = true
47+
view.isAccessibilityElement = false
4848
view.accessibilityTraits = .summaryElement
4949
view.axis = .vertical
5050
view.spacing = 8

ios/MullvadVPNUITests/Pages/TunnelControlPage.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class TunnelControlPage: Page {
121121
}
122122

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

@@ -202,6 +202,13 @@ class TunnelControlPage: Page {
202202
return self
203203
}
204204

205+
/// Verify that the app attempts to connect over Multihop.
206+
@discardableResult func verifyConnectingOverMultihop() -> Self {
207+
let relayName = getCurrentRelayName().lowercased()
208+
XCTAssertTrue(relayName.contains("via"))
209+
return self
210+
}
211+
205212
func getInIPAddressFromConnectionStatus() -> String {
206213
let inAddressRow = app.otherElements[AccessibilityIdentifier.connectionPanelInAddressRow]
207214

@@ -215,7 +222,7 @@ class TunnelControlPage: Page {
215222
}
216223

217224
func getCurrentRelayName() -> String {
218-
let relayExpandButton = app.buttons[.relayStatusCollapseButton]
225+
let relayExpandButton = app.otherElements[.relayStatusCollapseButton]
219226

220227
guard let relayName = relayExpandButton.value as? String else {
221228
XCTFail("Failed to read relay name from tunnel control page")

ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift

+18
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,22 @@ class VPNSettingsPage: Page {
205205
XCTAssertEqual(switchValue, "1")
206206
return self
207207
}
208+
209+
@discardableResult func tapDaitaSwitchIfOn() -> Self {
210+
let switchElement = app.cells[.daitaSwitch].switches[AccessibilityIdentifier.customSwitch]
211+
212+
if switchElement.value as? String == "1" {
213+
tapDaitaSwitch()
214+
}
215+
return self
216+
}
217+
218+
@discardableResult func tapMultihopSwitchIfOn() -> Self {
219+
let switchElement = app.cells[.multihopSwitch].switches[AccessibilityIdentifier.customSwitch]
220+
221+
if switchElement.value as? String == "1" {
222+
tapMultihopSwitch()
223+
}
224+
return self
225+
}
208226
}

ios/MullvadVPNUITests/RelayTests.swift

+34
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,40 @@ class RelayTests: LoggedInWithTimeUITestCase {
245245
.tapDisconnectButton()
246246
}
247247

248+
func testMultihopSettings() throws {
249+
// Undo enabling Multihop in teardown
250+
addTeardownBlock {
251+
HeaderBar(self.app)
252+
.tapSettingsButton()
253+
254+
SettingsPage(self.app)
255+
.tapVPNSettingsCell()
256+
257+
VPNSettingsPage(self.app)
258+
.tapMultihopSwitchIfOn()
259+
}
260+
261+
HeaderBar(app)
262+
.tapSettingsButton()
263+
264+
SettingsPage(app)
265+
.tapVPNSettingsCell()
266+
267+
VPNSettingsPage(app)
268+
.tapMultihopSwitch()
269+
.swipeDownToDismissModal()
270+
271+
TunnelControlPage(app)
272+
.tapSecureConnectionButton()
273+
274+
allowAddVPNConfigurationsIfAsked()
275+
276+
TunnelControlPage(app)
277+
.waitForSecureConnectionLabel()
278+
.verifyConnectingOverMultihop()
279+
.tapDisconnectButton()
280+
}
281+
248282
/// 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.
249283
private func getDefaultRelayInfo() -> RelayInfo {
250284
TunnelControlPage(app)

0 commit comments

Comments
 (0)