@@ -2490,11 +2490,58 @@ class VaultItemViewModelTest : BaseViewModelTest() {
2490
2490
2491
2491
@Suppress(" MaxLineLength" )
2492
2492
@Test
2493
- fun `on PrivateKeyVisibilityClick should show password dialog when re-prompt is required` () =
2493
+ fun `on PrivateKeyVisibilityClick should show private key when re-prompt is not required` () =
2494
2494
runTest {
2495
2495
val sshKeyViewState = createViewState(
2496
2496
common = DEFAULT_COMMON .copy(requiresReprompt = false ),
2497
+ type = DEFAULT_SSH_KEY_TYPE ,
2497
2498
)
2499
+ val sshKeyState = DEFAULT_STATE .copy(viewState = sshKeyViewState)
2500
+ every {
2501
+ mockCipherView.toViewState(
2502
+ previousState = null ,
2503
+ isPremiumUser = true ,
2504
+ hasMasterPassword = true ,
2505
+ totpCodeItemData = null ,
2506
+ canDelete = true ,
2507
+ canAssignToCollections = true ,
2508
+ )
2509
+ } returns sshKeyViewState
2510
+ mutableVaultItemFlow.value = DataState .Loaded (data = mockCipherView)
2511
+ mutableAuthCodeItemFlow.value = DataState .Loaded (data = null )
2512
+ mutableCollectionsStateFlow.value = DataState .Loaded (emptyList())
2513
+
2514
+ assertEquals(sshKeyState, viewModel.stateFlow.value)
2515
+ viewModel.trySendAction(
2516
+ VaultItemAction .ItemType .SshKey .PrivateKeyVisibilityClicked (
2517
+ isVisible = true ,
2518
+ ),
2519
+ )
2520
+ assertEquals(
2521
+ sshKeyState.copy(
2522
+ viewState = sshKeyViewState.copy(
2523
+ common = DEFAULT_COMMON .copy(requiresReprompt = false ),
2524
+ type = DEFAULT_SSH_KEY_TYPE .copy(showPrivateKey = true ),
2525
+ ),
2526
+ ),
2527
+ viewModel.stateFlow.value,
2528
+ )
2529
+ verify(exactly = 1 ) {
2530
+ mockCipherView.toViewState(
2531
+ previousState = null ,
2532
+ isPremiumUser = true ,
2533
+ hasMasterPassword = true ,
2534
+ totpCodeItemData = null ,
2535
+ canDelete = true ,
2536
+ canAssignToCollections = true ,
2537
+ )
2538
+ }
2539
+ }
2540
+
2541
+ @Suppress(" MaxLineLength" )
2542
+ @Test
2543
+ fun `on PrivateKeyVisibilityClick should show password dialog when re-prompt is required` () =
2544
+ runTest {
2498
2545
val sshKeyState = DEFAULT_STATE .copy(viewState = SSH_KEY_VIEW_STATE )
2499
2546
every {
2500
2547
mockCipherView.toViewState(
@@ -2518,15 +2565,22 @@ class VaultItemViewModelTest : BaseViewModelTest() {
2518
2565
)
2519
2566
assertEquals(
2520
2567
sshKeyState.copy(
2521
- viewState = sshKeyViewState.copy(
2522
- common = DEFAULT_COMMON ,
2523
- type = DEFAULT_SSH_KEY_TYPE .copy(
2524
- showPrivateKey = true ,
2525
- ),
2568
+ dialog = VaultItemState .DialogState .MasterPasswordDialog (
2569
+ PasswordRepromptAction .ViewPrivateKeyClicked (isVisible = true ),
2526
2570
),
2527
2571
),
2528
2572
viewModel.stateFlow.value,
2529
2573
)
2574
+ verify(exactly = 1 ) {
2575
+ mockCipherView.toViewState(
2576
+ previousState = null ,
2577
+ isPremiumUser = true ,
2578
+ hasMasterPassword = true ,
2579
+ totpCodeItemData = null ,
2580
+ canDelete = true ,
2581
+ canAssignToCollections = true ,
2582
+ )
2583
+ }
2530
2584
}
2531
2585
2532
2586
@Test
0 commit comments