summaryrefslogtreecommitdiffhomepage
path: root/ios/MullvadVPNUITests/Pages/EditCustomListLocationsPage.swift
blob: f72eaa7dc5805b42f2e7d62bc8df0d539a5cf9a0 (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
//
//  EditCustomListLocationsPage.swift
//  MullvadVPNUITests
//
//  Created by Marco Nikic on 2024-04-19.
//  Copyright © 2025 Mullvad VPN AB. All rights reserved.
//

import XCTest

class EditCustomListLocationsPage: Page {
    enum Action {
        case add, edit
    }

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

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

    @discardableResult func scrollToLocationWith(identifier: String) -> Self {
        let tableView = app.tables[.editCustomListEditLocationsTableView]
        tableView.cells[identifier].tap()
        return self
    }

    @discardableResult func toggleLocationCheckmarkWith(identifier: String) -> Self {
        let locationCell = app.tables[.editCustomListEditLocationsTableView].cells[identifier]
        locationCell.buttons[.customListLocationCheckmarkButton].tap()
        return self
    }

    @discardableResult func unfoldLocationwith(identifier: String) -> Self {
        let locationCell = app.tables[.editCustomListEditLocationsTableView].cells[identifier]
        let expandCellButton = locationCell.buttons["expandButton"]
        if expandCellButton.exists {
            expandCellButton.tap()
        }
        return self
    }

    @discardableResult func collapseLocationwith(identifier: String) -> Self {
        let locationCell = app.tables[.editCustomListEditLocationsTableView].cells[identifier]
        let collapseCellButton = locationCell.buttons["collapseButton"]
        if collapseCellButton.exists {
            collapseCellButton.tap()
        }
        return self
    }

    @discardableResult func tapBackButton() -> Self {
        app.navigationBars["Locations"].buttons.firstMatch.tap()
        return self
    }
}