Skip to content

Commit 834caa0

Browse files
[PM-29256] - add feature flag to vault spotlight (#17842)
* add feature flag to vault spotlight * fix spec
1 parent 7cba6f4 commit 834caa0

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

apps/browser/src/vault/popup/components/vault-v2/vault-v2.component.spec.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe("VaultV2Component", () => {
180180
const nudgesSvc = {
181181
showNudgeSpotlight$: jest.fn().mockImplementation((_type: NudgeType) => of(false)),
182182
dismissNudge: jest.fn().mockResolvedValue(undefined),
183-
} as Partial<NudgesService>;
183+
};
184184

185185
const dialogSvc = {} as Partial<DialogService>;
186186

@@ -209,6 +209,10 @@ describe("VaultV2Component", () => {
209209
.mockResolvedValue(new Date(Date.now() - 8 * 24 * 60 * 60 * 1000)), // 8 days ago
210210
};
211211

212+
const configSvc = {
213+
getFeatureFlag$: jest.fn().mockImplementation((_flag: string) => of(false)),
214+
};
215+
212216
beforeEach(async () => {
213217
jest.clearAllMocks();
214218
await TestBed.configureTestingModule({
@@ -256,9 +260,7 @@ describe("VaultV2Component", () => {
256260
{ provide: StateProvider, useValue: mock<StateProvider>() },
257261
{
258262
provide: ConfigService,
259-
useValue: {
260-
getFeatureFlag$: (_: string) => of(false),
261-
},
263+
useValue: configSvc,
262264
},
263265
{
264266
provide: SearchService,
@@ -453,7 +455,9 @@ describe("VaultV2Component", () => {
453455

454456
hasPremiumFromAnySource$.next(false);
455457

456-
(nudgesSvc.showNudgeSpotlight$ as jest.Mock).mockImplementation((type: NudgeType) =>
458+
configSvc.getFeatureFlag$.mockImplementation((_flag: string) => of(true));
459+
460+
nudgesSvc.showNudgeSpotlight$.mockImplementation((type: NudgeType) =>
457461
of(type === NudgeType.PremiumUpgrade),
458462
);
459463

@@ -482,9 +486,11 @@ describe("VaultV2Component", () => {
482486
}));
483487

484488
it("renders Empty-Vault spotlight when vaultState is Empty and nudge is on", fakeAsync(() => {
489+
configSvc.getFeatureFlag$.mockImplementation((_flag: string) => of(false));
490+
485491
itemsSvc.emptyVault$.next(true);
486492

487-
(nudgesSvc.showNudgeSpotlight$ as jest.Mock).mockImplementation((type: NudgeType) => {
493+
nudgesSvc.showNudgeSpotlight$.mockImplementation((type: NudgeType) => {
488494
return of(type === NudgeType.EmptyVaultNudge);
489495
});
490496

apps/browser/src/vault/popup/components/vault-v2/vault-v2.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
137137
FeatureFlag.VaultLoadingSkeletons,
138138
);
139139

140+
protected premiumSpotlightFeatureFlag$ = this.configService.getFeatureFlag$(
141+
FeatureFlag.BrowserPremiumSpotlight,
142+
);
143+
140144
private showPremiumNudgeSpotlight$ = this.activeUserId$.pipe(
141145
switchMap((userId) => this.nudgesService.showNudgeSpotlight$(NudgeType.PremiumUpgrade, userId)),
142146
);
@@ -164,15 +168,21 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
164168
);
165169

166170
protected showPremiumSpotlight$ = combineLatest([
171+
this.premiumSpotlightFeatureFlag$,
167172
this.showPremiumNudgeSpotlight$,
168173
this.showHasItemsVaultSpotlight$,
169174
this.hasPremium$,
170175
this.cipherCount$,
171176
this.accountAgeInDays$,
172177
]).pipe(
173178
map(
174-
([showPremiumNudge, showHasItemsNudge, hasPremium, count, age]) =>
175-
showPremiumNudge && !showHasItemsNudge && !hasPremium && count >= 5 && age >= 7,
179+
([featureFlagEnabled, showPremiumNudge, showHasItemsNudge, hasPremium, count, age]) =>
180+
featureFlagEnabled &&
181+
showPremiumNudge &&
182+
!showHasItemsNudge &&
183+
!hasPremium &&
184+
count >= 5 &&
185+
age >= 7,
176186
),
177187
shareReplay({ bufferSize: 1, refCount: true }),
178188
);

libs/common/src/enums/feature-flag.enum.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export enum FeatureFlag {
6262
AutofillConfirmation = "pm-25083-autofill-confirm-from-search",
6363
RiskInsightsForPremium = "pm-23904-risk-insights-for-premium",
6464
VaultLoadingSkeletons = "pm-25081-vault-skeleton-loaders",
65+
BrowserPremiumSpotlight = "pm-23384-browser-premium-spotlight",
6566

6667
/* Platform */
6768
IpcChannelFramework = "ipc-channel-framework",
@@ -119,6 +120,7 @@ export const DefaultFeatureFlagValue = {
119120
[FeatureFlag.AutofillConfirmation]: FALSE,
120121
[FeatureFlag.RiskInsightsForPremium]: FALSE,
121122
[FeatureFlag.VaultLoadingSkeletons]: FALSE,
123+
[FeatureFlag.BrowserPremiumSpotlight]: FALSE,
122124

123125
/* Auth */
124126
[FeatureFlag.PM23801_PrefetchPasswordPrelogin]: FALSE,

0 commit comments

Comments
 (0)