blob: 361b23f37c613b1640f273a2bc51b82591f6fba2 (
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
|
//
// DeviceManagementPage.swift
// MullvadVPNUITests
//
// Created by Niklas Berglund on 2024-03-27.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import XCTest
/// Page class for the "too many devices" page shown when logging on to an account with too many devices
class DeviceManagementPage: Page {
override init(_ app: XCUIApplication) {
super.init(app)
self.pageElement =
app
.descendants(matching: .any)
.matching(
identifier: AccessibilityIdentifier.deviceManagementView.asString
).element
waitForPageToBeShown()
}
@discardableResult func waitForNoLoading() -> Self {
XCTAssertTrue(
app.otherElements[.deviceRemovalProgressView]
.waitForNonExistence(timeout: BaseUITestCase.longTimeout)
)
return self
}
@discardableResult func waitForDeviceList() -> Self {
XCTAssertTrue(
app
.collectionViews[AccessibilityIdentifier.deviceManagementView]
.waitForExistence(timeout: BaseUITestCase.longTimeout)
)
return self
}
@discardableResult func tapRemoveDeviceButton(cellIndex: Int) -> Self {
app
.cells.element(boundBy: cellIndex)
.buttons[AccessibilityIdentifier.deviceCellRemoveButton]
.tap()
return self
}
@discardableResult func tapContinueWithLoginButton() -> Self {
app.buttons[AccessibilityIdentifier.continueWithLoginButton].tap()
return self
}
@discardableResult public func verifyCurrentDeviceExists() -> Self {
XCTAssertTrue(
app.staticTexts["Current device"]
.waitForExistence(timeout: BaseUITestCase.defaultTimeout)
)
return self
}
@discardableResult public func verifyCurrentDeviceCannotBeRemoved() -> Self {
let cells = app.cells
let buttons = cells.buttons
// Button count should equal the amount of cells, except for the cell that cannot
// be removed and the information text cell at the top of the page.
XCTAssertEqual(buttons.count, cells.count - 2)
return self
}
@discardableResult public func verifyRemovableDeviceCount(_ expectedCount: Int) -> Self {
XCTAssertEqual(
app.buttons.matching(
identifier: AccessibilityIdentifier.deviceCellRemoveButton.asString
)
.count,
expectedCount
)
return self
}
}
/// Confirmation alert displayed when removing a device
class DeviceManagementLogOutDeviceConfirmationAlert: Page {
override init(_ app: XCUIApplication) {
super.init(app)
self.pageElement = app.otherElements[.alertContainerView]
waitForPageToBeShown()
}
@discardableResult func tapYesLogOutDeviceButton() -> Self {
app.buttons[AccessibilityIdentifier.logOutDeviceConfirmButton]
.tap()
return self
}
}
|