diff --git a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.html b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.html index 085354d3db..09327a145f 100644 --- a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.html +++ b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.html @@ -67,7 +67,7 @@ bitIconButton="bwi-minus-circle" buttonType="danger" bitSuffix - *ngIf="loginDetailsForm.enabled" + *ngIf="loginDetailsForm.enabled && viewHiddenFields" [bitAction]="removePasskey" data-testid="remove-passkey-button" [appA11yTitle]="'removePasskey' | i18n" diff --git a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.spec.ts b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.spec.ts index 0fe4b128d3..31a0bb8ab5 100644 --- a/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.spec.ts +++ b/libs/vault/src/cipher-form/components/login-details-section/login-details-section.component.spec.ts @@ -452,6 +452,8 @@ describe("LoginDetailsSectionComponent", () => { fixture = TestBed.createComponent(LoginDetailsSectionComponent); component = fixture.componentInstance; + + jest.spyOn(component, "viewHiddenFields", "get").mockReturnValue(true); }); it("renders the passkey field when available", () => { @@ -469,7 +471,7 @@ describe("LoginDetailsSectionComponent", () => { it("renders the passkey remove button when editable", () => { fixture.detectChanges(); - expect(getRemovePasskeyBtn).not.toBeNull(); + expect(getRemovePasskeyBtn()).not.toBeNull(); }); it("does not render the passkey remove button when not editable", () => { @@ -480,6 +482,14 @@ describe("LoginDetailsSectionComponent", () => { expect(getRemovePasskeyBtn()).toBeNull(); }); + it("does not render the passkey remove button when viewHiddenFields is false", () => { + jest.spyOn(component, "viewHiddenFields", "get").mockReturnValue(false); + + fixture.detectChanges(); + + expect(getRemovePasskeyBtn()).toBeNull(); + }); + it("hides the passkey field when missing a passkey", () => { (cipherFormContainer.originalCipherView as CipherView).login.fido2Credentials = [];