From 251213b69c4b7d0e9322f33e55456f17e6d6cc24 Mon Sep 17 00:00:00 2001 From: Nick Krantz <125900171+nick-livefront@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:58:34 -0600 Subject: [PATCH] remove check for `SHOW_AUTOFILL_BUTTON` (#11971) --- .../vault-v2/view-v2/view-v2.component.spec.ts | 13 ++++++++++++- .../vault-v2/view-v2/view-v2.component.ts | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.spec.ts b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.spec.ts index b173c36d25..36343d3a66 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.spec.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.spec.ts @@ -5,6 +5,7 @@ import { Subject } from "rxjs"; import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; +import { AUTOFILL_ID } from "@bitwarden/common/autofill/constants"; import { EventType } from "@bitwarden/common/enums"; import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; @@ -33,6 +34,7 @@ describe("ViewV2Component", () => { const params$ = new Subject(); const mockNavigate = jest.fn(); const collect = jest.fn().mockResolvedValue(null); + const doAutofill = jest.fn(); const mockCipher = { id: "122-333-444", @@ -41,7 +43,7 @@ describe("ViewV2Component", () => { }; const mockVaultPopupAutofillService = { - doAutofill: jest.fn(), + doAutofill, }; const mockUserId = Utils.newGuid() as UserId; const accountService: FakeAccountService = mockAccountServiceWith(mockUserId); @@ -54,6 +56,7 @@ describe("ViewV2Component", () => { beforeEach(async () => { mockNavigate.mockClear(); collect.mockClear(); + doAutofill.mockClear(); await TestBed.configureTestingModule({ imports: [ViewV2Component], @@ -148,5 +151,13 @@ describe("ViewV2Component", () => { undefined, ); })); + + it('invokes `doAutofill` when action="AUTOFILL_ID"', fakeAsync(() => { + params$.next({ action: AUTOFILL_ID }); + + flush(); // Resolve all promises + + expect(doAutofill).toHaveBeenCalledOnce(); + })); }); }); diff --git a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts index b1cbe8bc3e..8242fd8747 100644 --- a/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts +++ b/apps/browser/src/vault/popup/components/vault-v2/view-v2/view-v2.component.ts @@ -100,7 +100,7 @@ export class ViewV2Component { switchMap(async (cipher) => { this.cipher = cipher; this.headerText = this.setHeader(cipher.type); - if (this.loadAction === AUTOFILL_ID || this.loadAction === SHOW_AUTOFILL_BUTTON) { + if (this.loadAction === AUTOFILL_ID) { await this.vaultPopupAutofillService.doAutofill(this.cipher); }