diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2024-03-14 08:30:48 +0100 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-03-14 08:30:48 +0100 |
| commit | 187f52fe4b2b3d67ef168ab0664b6ea770c054b2 (patch) | |
| tree | 5749158cca7e08f6cf11ddfdc7c4e38930be6187 | |
| parent | 4dae9a8e3e7251865098c466865d9563c1884f2d (diff) | |
| parent | a8603cd230a85422f2a0beb5c05c53f9138dade4 (diff) | |
| download | mullvadvpn-187f52fe4b2b3d67ef168ab0664b6ea770c054b2.tar.xz mullvadvpn-187f52fe4b2b3d67ef168ab0664b6ea770c054b2.zip | |
Merge branch 'test-logging-out-ios-436'
4 files changed, 36 insertions, 13 deletions
diff --git a/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift b/ios/MullvadVPN/View controllers/Alert/AlertViewController.swift index bfdb60c70c..0902a4c17b 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 e12152291b..b3b47dc858 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 a1a22b5c40..6f84ac1976 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 ba870b0ba7..b3d7332ced 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 + } + } } |
