@@ -15,7 +15,9 @@ import com.x8bit.bitwarden.data.platform.manager.model.CoachMarkTourType
15
15
import com.x8bit.bitwarden.data.platform.manager.model.FirstTimeState
16
16
import com.x8bit.bitwarden.data.platform.manager.model.FlagKey
17
17
import com.x8bit.bitwarden.data.vault.datasource.disk.VaultDiskSource
18
+ import com.x8bit.bitwarden.data.vault.datasource.network.model.PolicyTypeJson
18
19
import com.x8bit.bitwarden.data.vault.datasource.network.model.SyncResponseJson
20
+ import com.x8bit.bitwarden.data.vault.datasource.network.model.createMockPolicy
19
21
import io.mockk.every
20
22
import io.mockk.mockk
21
23
import kotlinx.coroutines.flow.MutableStateFlow
@@ -425,21 +427,82 @@ class FirstTimeActionManagerTest {
425
427
@Test
426
428
fun `if there are login ciphers attached to an organization we should show coach marks` () =
427
429
runTest {
428
- val mockJsonWithNoLoginAndWithOrganizationId = mockk<SyncResponseJson .Cipher > {
430
+ val mockJsonWithLoginAndWithOrganizationId = mockk<SyncResponseJson .Cipher > {
429
431
every { login } returns mockk()
430
432
every { organizationId } returns " 1234"
431
433
}
432
434
fakeAuthDiskSource.userState = MOCK_USER_STATE
433
435
// Enable feature flag so flow emits updates from disk.
434
436
mutableOnboardingFeatureFlow.update { true }
435
437
mutableCiphersListFlow.update {
436
- listOf (mockJsonWithNoLoginAndWithOrganizationId )
438
+ listOf (mockJsonWithLoginAndWithOrganizationId )
437
439
}
438
440
firstTimeActionManager.shouldShowGeneratorCoachMarkFlow.test {
439
441
assertTrue(awaitItem())
440
442
}
441
443
}
442
444
445
+ @Test
446
+ fun `if a user has a org only policy with no login items we show coach marks` () =
447
+ runTest {
448
+ val userState = MOCK_USER_STATE
449
+ fakeAuthDiskSource.userState = userState
450
+ fakeAuthDiskSource.storePolicies(
451
+ userState.activeUserId,
452
+ listOf (
453
+ createMockPolicy(
454
+ isEnabled = true ,
455
+ number = 2 ,
456
+ organizationId = " 1234" ,
457
+ type = PolicyTypeJson .ONLY_ORG ,
458
+ ),
459
+ ),
460
+ )
461
+ // Enable feature flag so flow emits updates from disk.
462
+ mutableOnboardingFeatureFlow.update { true }
463
+
464
+ firstTimeActionManager.shouldShowGeneratorCoachMarkFlow.test {
465
+ assertTrue(awaitItem())
466
+ // Make sure when we change the disk source that we honor that value.
467
+ fakeSettingsDiskSource.storeShouldShowGeneratorCoachMark(shouldShow = false )
468
+ assertFalse(awaitItem())
469
+ }
470
+ }
471
+
472
+ @Test
473
+ fun `if a user has a org only policy with login items we show coach marks` () =
474
+ runTest {
475
+ val userState = MOCK_USER_STATE
476
+ fakeAuthDiskSource.userState = userState
477
+ fakeAuthDiskSource.storePolicies(
478
+ userState.activeUserId,
479
+ listOf (
480
+ createMockPolicy(
481
+ isEnabled = true ,
482
+ number = 2 ,
483
+ organizationId = " 1234" ,
484
+ type = PolicyTypeJson .ONLY_ORG ,
485
+ ),
486
+ ),
487
+ )
488
+ val mockJsonWithLoginAndWithOrganizationId = mockk<SyncResponseJson .Cipher > {
489
+ every { login } returns mockk()
490
+ every { organizationId } returns " 1234"
491
+ }
492
+ mutableCiphersListFlow.update {
493
+ listOf (mockJsonWithLoginAndWithOrganizationId)
494
+ }
495
+ // Enable feature flag so flow emits updates from disk.
496
+ mutableOnboardingFeatureFlow.update { true }
497
+
498
+ firstTimeActionManager.shouldShowGeneratorCoachMarkFlow.test {
499
+ assertTrue(awaitItem())
500
+ // Make sure when we change the disk source that we honor that value.
501
+ fakeSettingsDiskSource.storeShouldShowGeneratorCoachMark(shouldShow = false )
502
+ assertFalse(awaitItem())
503
+ }
504
+ }
505
+
443
506
@Suppress(" MaxLineLength" )
444
507
@Test
445
508
fun `markCoachMarkTourCompleted for the GENERATOR type sets the value to true in the disk source for should show generator coach mark` () {
0 commit comments