Skip to content

Commit 15205fd

Browse files
committed
Add end to end test for multihop
1 parent 98a539c commit 15205fd

File tree

7 files changed

+79
-14
lines changed

7 files changed

+79
-14
lines changed

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/SelectLocationPage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SelectLocationPage: Page {
1313
@discardableResult override init(_ app: XCUIApplication) {
1414
super.init(app)
1515

16-
self.pageElement = app.otherElements[.selectLocationView]
16+
self.pageElement = app.otherElements[.selectLocationViewWrapper]
1717
waitForPageToBeShown()
1818
}
1919

ios/MullvadVPNUITests/Pages/TunnelControlPage.swift

+17-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,21 @@ class TunnelControlPage: Page {
202202
return self
203203
}
204204

205+
/// Verify that the app attempts to connect over Diata.
206+
@discardableResult func verifyConnectingOverDaita() -> Self {
207+
let relayName = getCurrentRelayName().lowercased()
208+
let elements = relayName.components(separatedBy: .whitespacesAndNewlines)
209+
XCTAssertTrue(elements.contains("daita"))
210+
return self
211+
}
212+
213+
/// Verify that the app attempts to connect over Diata.
214+
@discardableResult func verifyConnectingOverMultihop() -> Self {
215+
let relayName = getCurrentRelayName().lowercased()
216+
XCTAssertTrue(relayName.contains("via"))
217+
return self
218+
}
219+
205220
func getInIPAddressFromConnectionStatus() -> String {
206221
let inAddressRow = app.otherElements[AccessibilityIdentifier.connectionPanelInAddressRow]
207222

@@ -215,7 +230,7 @@ class TunnelControlPage: Page {
215230
}
216231

217232
func getCurrentRelayName() -> String {
218-
let relayExpandButton = app.buttons[.relayStatusCollapseButton]
233+
let relayExpandButton = app.otherElements[.relayStatusCollapseButton]
219234

220235
guard let relayName = relayExpandButton.value as? String else {
221236
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)