1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-10 05:13:29 +00:00

[PM-24313] remove PM9111ExtensionPersistAddEditForm flag (#15929)

* remove the PM9111ExtensionPersistAddEditForm flag and associated logic
This commit is contained in:
Jason Ng
2025-08-11 15:15:51 -04:00
committed by GitHub
parent 943cdc2fbd
commit 6b4c702def
4 changed files with 1 additions and 69 deletions

View File

@@ -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,

View File

@@ -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<CipherForm>({});

View File

@@ -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<CipherView | null>(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();
});
});
});

View File

@@ -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();
}
}