blob: 77726e9bf03756c3ba16a7efe8062cc046d71c90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
//
// EditAccessMethodPage.swift
// MullvadVPNUITests
//
// Created by Niklas Berglund on 2024-04-10.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
import XCTest
class EditAccessMethodPage: Page {
enum TestStatus {
case reachable, unreachable, testing
}
override init(_ app: XCUIApplication) {
super.init(app)
self.pageElement = app.tables[.editAccessMethodView]
waitForPageToBeShown()
}
@discardableResult func tapEnableMethodSwitch() -> Self {
app.switches[AccessibilityIdentifier.accessMethodEnableSwitch].tap()
return self
}
@discardableResult func tapEnableMethodSwitchIfOff() -> Self {
let enableMethodSwitch = app.switches[AccessibilityIdentifier.accessMethodEnableSwitch]
if enableMethodSwitch.value as? String == "0" {
tapEnableMethodSwitch()
}
return self
}
@discardableResult func verifyTestStatus(_ status: TestStatus) -> Self {
switch status {
case .reachable:
XCTAssertTrue(app.staticTexts["API reachable"].waitForExistence(timeout: BaseUITestCase.longTimeout))
case .unreachable:
XCTAssertTrue(app.staticTexts["API unreachable"].waitForExistence(timeout: BaseUITestCase.longTimeout))
case .testing:
XCTAssertTrue(app.staticTexts["Testing..."].waitForExistence(timeout: BaseUITestCase.longTimeout))
}
return self
}
@discardableResult func tapTestMethodButton() -> Self {
app.buttons[AccessibilityIdentifier.accessMethodTestButton].tap()
return self
}
@discardableResult func tapBackButton() -> Self {
// Workaround due to the way automatically managed back buttons work. Back button needs to be nil for the automatic back button behaviour in iOS, and since its nil we cannot set accessibilityIdentifier for it
let backButton = app.navigationBars.firstMatch.buttons.firstMatch
backButton.tap()
return self
}
@discardableResult func verifySwitchDisabled() -> Self {
XCTAssertFalse(app.switches[AccessibilityIdentifier.accessMethodEnableSwitch].isEnabled)
return self
}
@discardableResult func tapDeleteButton() -> Self {
app.buttons[AccessibilityIdentifier.deleteButton].tap()
return self
}
func confirmAccessMethodDeletion() {
app.buttons[.accessMethodConfirmDeleteButton].tap()
}
}
|