@@ -468,20 +468,34 @@ class AccountSecurityProcessorTests: BitwardenTestCase { // swiftlint:disable:th
468
468
}
469
469
470
470
/// `receive(_:)` with `.toggleUnlockWithPINCode` displays an alert and updates the state when submit has been
471
- /// pressed.
472
- func test_receive_toggleUnlockWithPINCode_toggleOn ( ) async throws {
471
+ /// pressed and the user has entered in a pin .
472
+ func test_receive_toggleUnlockWithPINCode_toggleOn_withPIN ( ) async throws {
473
473
stateService. activeAccount = . fixture( )
474
474
subject. state. isUnlockWithPINCodeOn = false
475
475
subject. receive ( . toggleUnlockWithPINCode( true ) )
476
476
477
477
var alert = try XCTUnwrap ( coordinator. alertShown. last)
478
+ try alert. setText ( " 1234 " , forTextFieldWithId: " pin " )
478
479
try await alert. tapAction ( title: Localizations . submit)
479
480
480
481
alert = try XCTUnwrap ( coordinator. alertShown. last)
481
482
try await alert. tapAction ( title: Localizations . yes)
482
483
XCTAssertTrue ( subject. state. isUnlockWithPINCodeOn)
483
484
}
484
485
486
+ /// `receive(_:)` with `.toggleUnlockWithPINCode` displays an alert and updates the state when submit has been
487
+ /// pressed but an empty pin was passed.
488
+ func test_receive_toggleUnlockWithPINCode_toggleOn_withEmptyPIN( ) async throws {
489
+ stateService. activeAccount = . fixture( )
490
+ subject. state. isUnlockWithPINCodeOn = false
491
+ subject. receive ( . toggleUnlockWithPINCode( true ) )
492
+
493
+ let alert = try XCTUnwrap ( coordinator. alertShown. last)
494
+ try await alert. tapAction ( title: Localizations . submit)
495
+
496
+ XCTAssertFalse ( subject. state. isUnlockWithPINCodeOn)
497
+ }
498
+
485
499
/// `receive(_:)` with `.toggleUnlockWithPINCode` displays an error if one occurs while setting
486
500
/// the user's pin.
487
501
func test_receive_toggleUnlockWithPINCode_toggleOn_error( ) async throws {
@@ -492,6 +506,7 @@ class AccountSecurityProcessorTests: BitwardenTestCase { // swiftlint:disable:th
492
506
subject. receive ( . toggleUnlockWithPINCode( true ) )
493
507
494
508
let enterPinAlert = try XCTUnwrap ( coordinator. alertShown. last)
509
+ try enterPinAlert. setText ( " 1234 " , forTextFieldWithId: " pin " )
495
510
try await enterPinAlert. tapAction ( title: Localizations . submit)
496
511
497
512
let requireMasterPasswordAlert = try XCTUnwrap ( coordinator. alertShown. last)
@@ -511,6 +526,7 @@ class AccountSecurityProcessorTests: BitwardenTestCase { // swiftlint:disable:th
511
526
subject. receive ( . toggleUnlockWithPINCode( true ) )
512
527
513
528
let alert = try XCTUnwrap ( coordinator. alertShown. last)
529
+ try alert. setText ( " 1234 " , forTextFieldWithId: " pin " )
514
530
try await alert. tapAction ( title: Localizations . submit)
515
531
516
532
XCTAssertTrue ( subject. state. isUnlockWithPINCodeOn)
@@ -539,6 +555,7 @@ class AccountSecurityProcessorTests: BitwardenTestCase { // swiftlint:disable:th
539
555
subject. receive ( . toggleUnlockWithPINCode( true ) )
540
556
541
557
let enterPinAlert = try XCTUnwrap ( coordinator. alertShown. last)
558
+ try enterPinAlert. setText ( " 1234 " , forTextFieldWithId: " pin " )
542
559
try await enterPinAlert. tapAction ( title: Localizations . submit)
543
560
544
561
let errorAlert = try XCTUnwrap ( coordinator. alertShown. last)
0 commit comments