Skip to content

Commit 26ecbf3

Browse files
committed
Update tests for DefaultStoresManager
1 parent 7741d18 commit 26ecbf3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

WooCommerce/WooCommerceTests/Yosemite/StoresManagerTests.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ final class StoresManagerTests: XCTestCase {
435435
XCTAssertNil(defaults[UserDefaults.Key.numberOfTimesWriteWithAITooltipIsShown])
436436
}
437437

438-
/// Verifies that user is logged out when application password regeneration fails
438+
/// Verifies that user is logged out when application password regeneration fails if authenticated with wporg
439439
///
440-
func test_it_deauthenticates_upon_receiving_application_password_generation_failure_notification() {
440+
func test_it_deauthenticates_upon_receiving_application_password_generation_failure_notification_when_authenticated_without_wpcom() {
441441
// Given
442442
let manager = DefaultStoresManager.testingInstance
443443
var isLoggedInValues = [Bool]()
@@ -455,6 +455,25 @@ final class StoresManagerTests: XCTestCase {
455455
XCTAssertEqual(isLoggedInValues, [false, true, false])
456456
}
457457

458+
/// Verifies that user is logged out when application password regeneration fails if authenticated with wpcom
459+
///
460+
func test_it_does_not_deauthenticate_upon_receiving_application_password_generation_failure_notification_when_authenticated_with_wpcom() {
461+
// Given
462+
let manager = DefaultStoresManager.testingInstance
463+
var isLoggedInValues = [Bool]()
464+
cancellable = manager.isLoggedInPublisher.sink { isLoggedIn in
465+
isLoggedInValues.append(isLoggedIn)
466+
}
467+
manager.authenticate(credentials: SessionSettings.wpcomCredentials)
468+
469+
// When
470+
let error = ApplicationPasswordUseCaseError.unauthorizedRequest
471+
MockNotificationCenter.testingInstance.post(name: .ApplicationPasswordsGenerationFailed, object: error, userInfo: nil)
472+
473+
// Assert
474+
XCTAssertTrue(manager.isAuthenticated)
475+
}
476+
458477
/// Verifies that user is logged out when WPCOM token expires
459478
///
460479
func test_it_deauthenticates_upon_receiving_invalid_token_error_notification() {

0 commit comments

Comments
 (0)