summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPNUITests/Pages/SettingsPage.swift
blob: 38aed4face973fcbed1818eb5a8d0fc09fed820d (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
//  SettingsPage.swift
//  MullvadVPNUITests
//
//  Created by Niklas Berglund on 2024-01-12.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import Foundation
import XCTest

class SettingsPage: Page {
    @discardableResult override init(_ app: XCUIApplication) {
        super.init(app)

        self.pageElement = app.otherElements[.settingsContainerView]
        waitForPageToBeShown()
    }

    @discardableResult func tapDoneButton() -> Self {
        app.buttons[AccessibilityIdentifier.settingsDoneButton]
            .tap()

        return self
    }

    @discardableResult func tapAPIAccessCell() -> Self {
        app
            .cells[AccessibilityIdentifier.apiAccessCell]
            .tap()

        return self
    }

    @discardableResult func tapDAITACell() -> Self {
        app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.daitaCell]
            .tap()

        return self
    }

    @discardableResult func verifyDAITAOn() -> Self {
        let textElement = app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.daitaCell]
            .staticTexts["On"]

        XCTAssertTrue(textElement.exists)

        return self
    }

    @discardableResult func verifyDAITAOff() -> Self {
        let textElement = app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.daitaCell]
            .staticTexts["Off"]

        XCTAssertTrue(textElement.exists)

        return self
    }

    @discardableResult func tapMultihopCell() -> Self {
        app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.multihopCell]
            .tap()

        return self
    }

    @discardableResult func verifyMultihopOn() -> Self {
        let textElement = app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.multihopCell]
            .staticTexts["On"]

        XCTAssertTrue(textElement.exists)

        return self
    }

    @discardableResult func verifyMultihopOff() -> Self {
        let textElement = app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.multihopCell]
            .staticTexts["Off"]

        XCTAssertTrue(textElement.exists)

        return self
    }

    @discardableResult func tapVPNSettingsCell() -> Self {
        app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.vpnSettingsCell]
            .tap()

        return self
    }

    @discardableResult func tapReportAProblemCell() -> Self {
        app.tables[AccessibilityIdentifier.settingsTableView]
            .cells[AccessibilityIdentifier.problemReportCell]
            .tap()

        return self
    }
}