generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PM-14547: Remove soft logged out account (#1150)
Co-authored-by: Ezimet Ozkhan <[email protected]>
- Loading branch information
1 parent
74baaeb
commit 361cc87
Showing
10 changed files
with
439 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,14 @@ import XCTest | |
@testable import BitwardenShared | ||
|
||
class AlertAuthTests: BitwardenTestCase { | ||
/// `accountOptions(_:lockAction:logoutAction:)` | ||
func test_accountOptions() { | ||
/// `accountOptions(_:lockAction:logoutAction:removeAccountAction:)` | ||
func test_accountOptions() async throws { | ||
var actions = [String]() | ||
let subject = Alert.accountOptions( | ||
.fixture(email: "[email protected]", isUnlocked: true, webVault: "secureVault.example.com"), | ||
lockAction: {}, | ||
logoutAction: {} | ||
lockAction: { actions.append(Localizations.lock) }, | ||
logoutAction: { actions.append(Localizations.logOut) }, | ||
removeAccountAction: { actions.append(Localizations.removeAccount) } | ||
) | ||
|
||
XCTAssertEqual(subject.title, "[email protected]\nsecureVault.example.com") | ||
|
@@ -18,6 +20,43 @@ class AlertAuthTests: BitwardenTestCase { | |
XCTAssertEqual(subject.alertActions[0].title, Localizations.lock) | ||
XCTAssertEqual(subject.alertActions[1].title, Localizations.logOut) | ||
XCTAssertEqual(subject.alertActions[2].title, Localizations.cancel) | ||
|
||
try await subject.tapAction(title: Localizations.lock) | ||
XCTAssertEqual(actions, [Localizations.lock]) | ||
actions.removeAll() | ||
|
||
try await subject.tapAction(title: Localizations.logOut) | ||
XCTAssertEqual(actions, [Localizations.logOut]) | ||
actions.removeAll() | ||
|
||
try await subject.tapAction(title: Localizations.cancel) | ||
XCTAssertTrue(actions.isEmpty) | ||
} | ||
|
||
/// `accountOptions(_:lockAction:logoutAction:removeAccountAction:)` shows the account options | ||
/// for a logged out account. | ||
func test_accountOptions_loggedOut() async throws { | ||
var actions = [String]() | ||
let subject = Alert.accountOptions( | ||
.fixture(email: "[email protected]", isLoggedOut: true, webVault: "secureVault.example.com"), | ||
lockAction: { actions.append(Localizations.lock) }, | ||
logoutAction: { actions.append(Localizations.logOut) }, | ||
removeAccountAction: { actions.append(Localizations.removeAccount) } | ||
) | ||
|
||
XCTAssertEqual(subject.title, "[email protected]\nsecureVault.example.com") | ||
XCTAssertNil(subject.message) | ||
XCTAssertEqual(subject.preferredStyle, .actionSheet) | ||
XCTAssertEqual(subject.alertActions.count, 2) | ||
XCTAssertEqual(subject.alertActions[0].title, Localizations.removeAccount) | ||
XCTAssertEqual(subject.alertActions[1].title, Localizations.cancel) | ||
|
||
try await subject.tapAction(title: Localizations.removeAccount) | ||
XCTAssertEqual(actions, [Localizations.removeAccount]) | ||
actions.removeAll() | ||
|
||
try await subject.tapAction(title: Localizations.cancel) | ||
XCTAssertTrue(actions.isEmpty) | ||
} | ||
|
||
/// `accountOptions(_:lockAction:logoutAction:)` shows the account options for can not be locked account. | ||
|
@@ -31,7 +70,8 @@ class AlertAuthTests: BitwardenTestCase { | |
webVault: "secureVault.example.com" | ||
), | ||
lockAction: {}, | ||
logoutAction: {} | ||
logoutAction: {}, | ||
removeAccountAction: {} | ||
) | ||
|
||
XCTAssertEqual(subject.title, "[email protected]\nsecureVault.example.com") | ||
|
@@ -187,6 +227,31 @@ class AlertAuthTests: BitwardenTestCase { | |
await fulfillment(of: [expectation], timeout: 3) | ||
} | ||
|
||
/// `removeAccountConfirmation(action:)` constructs an `Alert` used to confirm that the user | ||
/// wants to remove the account. | ||
func test_removeAccountConfirmation() async throws { | ||
var actionCalled = false | ||
let subject = Alert.removeAccountConfirmation(.fixture(email: "[email protected]")) { | ||
actionCalled = true | ||
} | ||
|
||
XCTAssertEqual(subject.title, Localizations.removeAccount) | ||
XCTAssertEqual( | ||
subject.message, | ||
Localizations.removeAccountConfirmation + "\n\n" + "[email protected]\nvault.bitwarden.com" | ||
) | ||
XCTAssertEqual(subject.preferredStyle, .alert) | ||
XCTAssertEqual(subject.alertActions.count, 2) | ||
XCTAssertEqual(subject.alertActions[0].title, Localizations.yes) | ||
XCTAssertEqual(subject.alertActions[1].title, Localizations.cancel) | ||
|
||
try await subject.tapAction(title: Localizations.cancel) | ||
XCTAssertFalse(actionCalled) | ||
|
||
try await subject.tapAction(title: Localizations.yes) | ||
XCTAssertTrue(actionCalled) | ||
} | ||
|
||
/// `setUpAutoFillLater(action:)` builds an `Alert` for setting up autofill later. | ||
func test_setUpAutoFillLater() async throws { | ||
var actionCalled = false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.