Skip to content

Commit 187f52f

Browse files
committed
Merge branch 'test-logging-out-ios-436'
2 parents 4dae9a8 + a8603cd commit 187f52f

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

ios/MullvadVPN/View controllers/Alert/AlertViewController.swift

+1-3
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,9 @@ class AlertViewController: UIViewController {
108108
override func viewDidLoad() {
109109
super.viewDidLoad()
110110

111+
view.accessibilityIdentifier = presentation.accessibilityIdentifier ?? .alertContainerView
111112
view.backgroundColor = .black.withAlphaComponent(0.5)
112113

113-
let accessibilityIdentifier = presentation.accessibilityIdentifier ?? .alertContainerView
114-
view.accessibilityIdentifier = accessibilityIdentifier
115-
116114
setContent()
117115
setConstraints()
118116
}

ios/MullvadVPNUITests/AccountTests.swift

+17
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,21 @@ class AccountTests: LoggedOutUITestCase {
7272
.verifyFailIconShown()
7373
.waitForPageToBeShown() // Verify still on login page
7474
}
75+
76+
func testLogOut() throws {
77+
let newAccountNumber = try MullvadAPIWrapper().createAccount()
78+
login(accountNumber: newAccountNumber)
79+
XCTAssertEqual(try MullvadAPIWrapper().getDevices(newAccountNumber).count, 1)
80+
81+
HeaderBar(app)
82+
.tapAccountButton()
83+
84+
AccountPage(app)
85+
.tapLogOutButton()
86+
87+
LoginPage(app)
88+
89+
XCTAssertEqual(try MullvadAPIWrapper().getDevices(newAccountNumber).count, 0)
90+
try MullvadAPIWrapper().deleteAccount(newAccountNumber)
91+
}
7592
}

ios/MullvadVPNUITests/MullvadApi.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ struct InitMutableBufferError: Error {
3232
let description = "Failed to allocate memory for mutable buffer"
3333
}
3434

35+
struct Device {
36+
let name: String
37+
let id: UUID
38+
39+
init(device_struct: MullvadApiDevice) {
40+
name = String(cString: device_struct.name_ptr)
41+
id = UUID(uuid: device_struct.id)
42+
}
43+
}
44+
3545
/// - Warning: Do not change the `apiAddress` or the `hostname` after the time `MullvadApi.init` has been invoked
3646
/// The Mullvad API crate is using a global static variable to store those. They will be initialized only once.
3747
///
@@ -113,16 +123,6 @@ class MullvadApi {
113123
mullvad_api_client_drop(clientContext)
114124
}
115125

116-
struct Device {
117-
let name: String
118-
let id: UUID
119-
120-
init(device_struct: MullvadApiDevice) {
121-
name = String(cString: device_struct.name_ptr)
122-
id = UUID(uuid: device_struct.id)
123-
}
124-
}
125-
126126
class DeviceIterator {
127127
private let backingIter: MullvadApiDeviceIterator
128128

ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift

+8
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,12 @@ class MullvadAPIWrapper {
9595
throw MullvadAPIError.requestError
9696
}
9797
}
98+
99+
func getDevices(_ account: String) throws -> [Device] {
100+
do {
101+
return try mullvadAPI.listDevices(forAccount: account)
102+
} catch {
103+
throw MullvadAPIError.requestError
104+
}
105+
}
98106
}

0 commit comments

Comments
 (0)