From 6b4c702def264193e64489ba3fa0ae25911d006d Mon Sep 17 00:00:00 2001 From: Jason Ng Date: Mon, 11 Aug 2025 15:15:51 -0400 Subject: [PATCH] [PM-24313] remove PM9111ExtensionPersistAddEditForm flag (#15929) * remove the PM9111ExtensionPersistAddEditForm flag and associated logic --- libs/common/src/enums/feature-flag.enum.ts | 2 - .../components/cipher-form.component.ts | 2 - .../default-cipher-form-cache.service.spec.ts | 39 +------------------ .../default-cipher-form-cache.service.ts | 27 ------------- 4 files changed, 1 insertion(+), 69 deletions(-) diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index e992ac64d46..486389b3977 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -48,7 +48,6 @@ export enum FeatureFlag { /* Vault */ PM8851_BrowserOnboardingNudge = "pm-8851-browser-onboarding-nudge", - PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form", PM19941MigrateCipherDomainToSdk = "pm-19941-migrate-cipher-domain-to-sdk", PM22134SdkCipherListView = "pm-22134-sdk-cipher-list-view", PM22136_SdkCipherEncryption = "pm-22136-sdk-cipher-encryption", @@ -95,7 +94,6 @@ export const DefaultFeatureFlagValue = { /* Vault */ [FeatureFlag.PM8851_BrowserOnboardingNudge]: FALSE, - [FeatureFlag.PM9111ExtensionPersistAddEditForm]: FALSE, [FeatureFlag.CipherKeyEncryption]: FALSE, [FeatureFlag.EndUserNotifications]: FALSE, [FeatureFlag.PM19941MigrateCipherDomainToSdk]: FALSE, diff --git a/libs/vault/src/cipher-form/components/cipher-form.component.ts b/libs/vault/src/cipher-form/components/cipher-form.component.ts index 6b0f9929464..bc513a8f395 100644 --- a/libs/vault/src/cipher-form/components/cipher-form.component.ts +++ b/libs/vault/src/cipher-form/components/cipher-form.component.ts @@ -227,8 +227,6 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci // Force change detection so that all child components are destroyed and re-created this.changeDetectorRef.detectChanges(); - await this.cipherFormCacheService.init(); - this.updatedCipherView = new CipherView(); this.originalCipherView = null; this.cipherForm = this.formBuilder.group({}); diff --git a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.spec.ts b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.spec.ts index 0dec46e1b20..c4fbfe7640d 100644 --- a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.spec.ts +++ b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.spec.ts @@ -2,7 +2,6 @@ import { signal } from "@angular/core"; import { TestBed } from "@angular/core/testing"; import { ViewCacheService } from "@bitwarden/angular/platform/view-cache"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; import { CipherFormCacheService } from "./default-cipher-form-cache.service"; @@ -12,39 +11,30 @@ describe("CipherFormCacheService", () => { let testBed: TestBed; const cacheSignal = signal(null); const getCacheSignal = jest.fn().mockReturnValue(cacheSignal); - const getFeatureFlag = jest.fn().mockResolvedValue(false); const cacheSetMock = jest.spyOn(cacheSignal, "set"); beforeEach(() => { getCacheSignal.mockClear(); - getFeatureFlag.mockClear(); cacheSetMock.mockClear(); testBed = TestBed.configureTestingModule({ providers: [ { provide: ViewCacheService, useValue: { signal: getCacheSignal } }, - { provide: ConfigService, useValue: { getFeatureFlag } }, CipherFormCacheService, ], }); }); - describe("feature enabled", () => { - beforeEach(async () => { - getFeatureFlag.mockResolvedValue(true); - }); - + describe("Cache Service", () => { it("`getCachedCipherView` returns the cipher", async () => { cacheSignal.set({ id: "cipher-4" } as CipherView); service = testBed.inject(CipherFormCacheService); - await service.init(); expect(service.getCachedCipherView()).toEqual({ id: "cipher-4" }); }); it("updates the signal value", async () => { service = testBed.inject(CipherFormCacheService); - await service.init(); service.cacheCipherView({ id: "cipher-5" } as CipherView); @@ -55,7 +45,6 @@ describe("CipherFormCacheService", () => { it("sets `initializedWithValue` to true when there is a cached cipher", async () => { cacheSignal.set({ id: "cipher-3" } as CipherView); service = testBed.inject(CipherFormCacheService); - await service.init(); expect(service.initializedWithValue).toBe(true); }); @@ -63,35 +52,9 @@ describe("CipherFormCacheService", () => { it("sets `initializedWithValue` to false when there is not a cached cipher", async () => { cacheSignal.set(null); service = testBed.inject(CipherFormCacheService); - await service.init(); expect(service.initializedWithValue).toBe(false); }); }); }); - - describe("featured disabled", () => { - beforeEach(async () => { - cacheSignal.set({ id: "cipher-1" } as CipherView); - getFeatureFlag.mockResolvedValue(false); - cacheSetMock.mockClear(); - - service = testBed.inject(CipherFormCacheService); - await service.init(); - }); - - it("sets `initializedWithValue` to false", () => { - expect(service.initializedWithValue).toBe(false); - }); - - it("`getCachedCipherView` returns null", () => { - expect(service.getCachedCipherView()).toBeNull(); - }); - - it("does not update the signal value", () => { - service.cacheCipherView({ id: "cipher-2" } as CipherView); - - expect(cacheSignal.set).not.toHaveBeenCalled(); - }); - }); }); diff --git a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts index 521cc09f140..73ec6549756 100644 --- a/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts +++ b/libs/vault/src/cipher-form/services/default-cipher-form-cache.service.ts @@ -1,8 +1,6 @@ import { inject, Injectable } from "@angular/core"; import { ViewCacheService } from "@bitwarden/angular/platform/view-cache"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view"; const CIPHER_FORM_CACHE_KEY = "cipher-form-cache"; @@ -10,10 +8,6 @@ const CIPHER_FORM_CACHE_KEY = "cipher-form-cache"; @Injectable() export class CipherFormCacheService { private viewCacheService: ViewCacheService = inject(ViewCacheService); - private configService: ConfigService = inject(ConfigService); - - /** True when the `PM9111ExtensionPersistAddEditForm` flag is enabled */ - private featureEnabled: boolean = false; /** * When true the `CipherFormCacheService` a cipher was stored in cache when the service was initialized. @@ -34,27 +28,10 @@ export class CipherFormCacheService { this.initializedWithValue = !!this.cipherCache(); } - /** - * Must be called once before interacting with the cached cipher, otherwise methods will be noop. - */ - async init() { - this.featureEnabled = await this.configService.getFeatureFlag( - FeatureFlag.PM9111ExtensionPersistAddEditForm, - ); - - if (!this.featureEnabled) { - this.initializedWithValue = false; - } - } - /** * Update the cache with the new CipherView. */ cacheCipherView(cipherView: CipherView): void { - if (!this.featureEnabled) { - return; - } - // Create a new shallow reference to force the signal to update // By default, signals use `Object.is` to determine equality // Docs: https://angular.dev/guide/signals#signal-equality-functions @@ -65,10 +42,6 @@ export class CipherFormCacheService { * Returns the cached CipherView when available. */ getCachedCipherView(): CipherView | null { - if (!this.featureEnabled) { - return null; - } - return this.cipherCache(); } }