Skip to content

Commit

Permalink
Merge branch 'test-logging-out-ios-436'
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Mar 14, 2024
2 parents 4dae9a8 + a8603cd commit 187f52f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
17 changes: 17 additions & 0 deletions ios/MullvadVPNUITests/AccountTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
20 changes: 10 additions & 10 deletions ios/MullvadVPNUITests/MullvadApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions ios/MullvadVPNUITests/Networking/MullvadAPIWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit 187f52f

Please sign in to comment.