diff --git a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift index bfdb60c70c41..0902a4c17bd0 100644 --- a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift +++ b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift @@ -108,11 +108,9 @@ class AlertViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() + view.accessibilityIdentifier = presentation.accessibilityIdentifier ?? .alertContainerView view.backgroundColor = .black.withAlphaComponent(0.5) - let accessibilityIdentifier = presentation.accessibilityIdentifier ?? .alertContainerView - view.accessibilityIdentifier = accessibilityIdentifier - setContent() setConstraints() } diff --git a/ios/MullvadVPNUITests/AccountTests.swift b/ios/MullvadVPNUITests/AccountTests.swift index e12152291b01..b3b47dc858ff 100644 --- a/ios/MullvadVPNUITests/AccountTests.swift +++ b/ios/MullvadVPNUITests/AccountTests.swift @@ -72,4 +72,21 @@ class AccountTests: LoggedOutUITestCase { .verifyFailIconShown() .waitForPageToBeShown() // Verify still on login page } + + func testLogOut() throws { + let newAccountNumber = try MullvadAPIWrapper().createAccount() + login(accountNumber: newAccountNumber) + XCTAssertEqual(try MullvadAPIWrapper().getDevices(newAccountNumber).count, 1) + + HeaderBar(app) + .tapAccountButton() + + AccountPage(app) + .tapLogOutButton() + + LoginPage(app) + + XCTAssertEqual(try MullvadAPIWrapper().getDevices(newAccountNumber).count, 0) + try MullvadAPIWrapper().deleteAccount(newAccountNumber) + } } diff --git a/ios/MullvadVPNUITests/MullvadApi.swift b/ios/MullvadVPNUITests/MullvadApi.swift index a1a22b5c4031..6f84ac1976b6 100644 --- a/ios/MullvadVPNUITests/MullvadApi.swift +++ b/ios/MullvadVPNUITests/MullvadApi.swift @@ -32,6 +32,16 @@ struct InitMutableBufferError: Error { let description = "Failed to allocate memory for mutable buffer" } +struct Device { + let name: String + let id: UUID + + init(device_struct: MullvadApiDevice) { + name = String(cString: device_struct.name_ptr) + id = UUID(uuid: device_struct.id) + } +} + /// - Warning: Do not change the `apiAddress` or the `hostname` after the time `MullvadApi.init` has been invoked /// The Mullvad API crate is using a global static variable to store those. They will be initialized only once. /// @@ -113,16 +123,6 @@ class MullvadApi { mullvad_api_client_drop(clientContext) } - struct Device { - let name: String - let id: UUID - - init(device_struct: MullvadApiDevice) { - name = String(cString: device_struct.name_ptr) - id = UUID(uuid: device_struct.id) - } - } - class DeviceIterator { private let backingIter: MullvadApiDeviceIterator diff --git a/ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift b/ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift index ba870b0ba7b8..b3d7332cedfa 100644 --- a/ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift +++ b/ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift @@ -95,4 +95,12 @@ class MullvadAPIWrapper { throw MullvadAPIError.requestError } } + + func getDevices(_ account: String) throws -> [Device] { + do { + return try mullvadAPI.listDevices(forAccount: account) + } catch { + throw MullvadAPIError.requestError + } + } }