summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPNUITests/Pages/MultihopPage.swift
blob: 8004c8d1cd2d598816504554d6d233f26d22e805 (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
//
//  MultihopPage.swift
//  MullvadVPN
//
//  Created by Jon Petersson on 2024-11-25.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import XCTest

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

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

    @discardableResult func tapBackButton() -> Self {
        // Workaround for setting accessibility identifier on navigation bar button being non-trivial
        app.buttons.matching(identifier: "Settings").allElementsBoundByIndex.last?.tap()
        return self
    }

    @discardableResult func verifyOnePage() -> Self {
        XCTAssertEqual(app.pageIndicators.firstMatch.value as? String, "page 1 of 1")
        return self
    }

    @discardableResult func tapEnableSwitch() -> Self {
        app.switches[AccessibilityIdentifier.multihopSwitch].tap()
        return self
    }

    @discardableResult func tapEnableSwitchIfOn() -> Self {
        let switchElement = app.switches[AccessibilityIdentifier.multihopSwitch]

        if switchElement.value as? String == "1" {
            tapEnableSwitch()
        }
        return self
    }
}