diff --git a/apps/browser/src/_locales/en/messages.json b/apps/browser/src/_locales/en/messages.json index b428576dfdf..9cc974eccd1 100644 --- a/apps/browser/src/_locales/en/messages.json +++ b/apps/browser/src/_locales/en/messages.json @@ -7078,12 +7078,13 @@ } } }, - "appUri": { - "message": "App (URI)" + "desktopApp": { + "message": "Desktop app", + "description": "Label for a field that shows an application installed on the computer that the item is paired with." }, - "appUriCount": { - "message": "App (URI) $COUNT$", - "description": "Label for an input field that contains an app URI. The input field is part of a list of fields, and the count indicates the position of the field in the list.", + "desktopAppCount": { + "message": "Desktop app $COUNT$", + "description": "Label for a field that shows an application installed on the computer that the item is paired with. The field is part of a list of fields, and the count indicates the position of the field in the list.", "placeholders": { "count": { "content": "$1", diff --git a/apps/desktop/src/locales/en/messages.json b/apps/desktop/src/locales/en/messages.json index 543bffe1f9e..de468c641cc 100644 --- a/apps/desktop/src/locales/en/messages.json +++ b/apps/desktop/src/locales/en/messages.json @@ -974,12 +974,13 @@ } } }, - "appUri": { - "message": "App (URI)" + "desktopApp": { + "message": "Desktop app", + "description": "Label for a field that shows an application installed on the computer that the item is paired with." }, - "appUriCount": { - "message": "App (URI) $COUNT$", - "description": "Label for an input field that contains an app URI. The input field is part of a list of fields, and the count indicates the position of the field in the list.", + "desktopAppCount": { + "message": "Desktop app $COUNT$", + "description": "Label for a field that shows an application installed on the computer that the item is paired with. The field is part of a list of fields, and the count indicates the position of the field in the list.", "placeholders": { "count": { "content": "$1", diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index fc1ee245846..a5fa508d013 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -649,12 +649,13 @@ } } }, - "appUri": { - "message": "App (URI)" + "desktopApp": { + "message": "Desktop app", + "description": "Label for a field that shows an application installed on the computer that the item is paired with." }, - "appUriCount": { - "message": "App (URI) $COUNT$", - "description": "Label for an input field that contains an app URI. The input field is part of a list of fields, and the count indicates the position of the field in the list.", + "desktopAppCount": { + "message": "Desktop app $COUNT$", + "description": "Label for a field that shows an application installed on the computer that the item is paired with. The field is part of a list of fields, and the count indicates the position of the field in the list.", "placeholders": { "count": { "content": "$1", diff --git a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts index ae52be5e32e..be5b1b8064f 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.spec.ts @@ -226,23 +226,49 @@ describe("UriOptionComponent", () => { expect(component["uriLabel"]).toBe("websiteUriCount 2"); }); - it("returns 'appUri' for a desktopapp:// URI at index 0 when showAppLabel is true", () => { + it("returns 'desktopApp' for a desktopapp:// URI at index 0 when showAppLabel is true", () => { component.writeValue({ uri: DESKTOP_APP_URI_PREFIX, matchDetection: null }); component.index = 0; fixture.componentRef.setInput("showAppLabel", true); - expect(component["uriLabel"]).toBe("appUri"); + expect(component["uriLabel"]).toBe("desktopApp"); }); - it("returns 'appUriCount' for a desktopapp:// URI at index greater than 0 when showAppLabel is true", () => { + it("returns 'desktopAppCount' for a desktopapp:// URI at index greater than 0 when showAppLabel is true", () => { component.writeValue({ uri: DESKTOP_APP_URI_PREFIX, matchDetection: null }); component.index = 1; fixture.componentRef.setInput("showAppLabel", true); - expect(component["uriLabel"]).toBe("appUriCount 2"); + expect(component["uriLabel"]).toBe("desktopAppCount 2"); }); }); + describe("isAppUri", () => { + it("returns true for a desktopapp:// URI when showAppLabel is true", () => { + component.writeValue({ uri: DESKTOP_APP_URI_PREFIX, matchDetection: null }); + fixture.componentRef.setInput("showAppLabel", true); + + expect(component["isAppUri"]).toBe(true); + }); + + it("returns false for a desktopapp:// URI when showAppLabel is false", () => { + component.writeValue({ uri: DESKTOP_APP_URI_PREFIX, matchDetection: null }); + fixture.componentRef.setInput("showAppLabel", false); + + expect(component["isAppUri"]).toBe(false); + }); + + it.each(["https://example.com", ""])( + "returns false for the non desktop app URI %p when showAppLabel is true", + (uri) => { + component.writeValue({ uri, matchDetection: null }); + fixture.componentRef.setInput("showAppLabel", true); + + expect(component["isAppUri"]).toBe(false); + }, + ); + }); + describe("advanced match strategy dialog", () => { function testDialogAction(action: "onContinue" | "onCancel", expected: number) { const openSpy = jest diff --git a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts index 255434f57d2..4c821803f5b 100644 --- a/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts +++ b/libs/vault/src/cipher-form/components/autofill-options/uri-option.component.ts @@ -143,7 +143,7 @@ export class UriOptionComponent implements ControlValueAccessor { @Input({ required: true }) index: number; /** - * When true, URIs prefixed with the desktop app scheme will display the "App (URI)" label + * When true, URIs prefixed with the desktop app scheme will display the "Desktop app" label * instead of "Website (URI)". Should only be true when the WindowsDesktopAutotypeGA feature * flag is enabled. */ @@ -176,15 +176,19 @@ export class UriOptionComponent implements ControlValueAccessor { } } - protected get uriLabel() { - const isAppUri = + /** Returns true if this URI is a desktop app pairing */ + protected get isAppUri(): boolean { + return ( this.showAppLabel() && - (this.uriForm.controls.uri.value?.startsWith(DESKTOP_APP_URI_PREFIX) ?? false); + (this.uriForm.controls.uri.value?.startsWith(DESKTOP_APP_URI_PREFIX) ?? false) + ); + } - if (isAppUri) { + protected get uriLabel() { + if (this.isAppUri) { return this.index === 0 - ? this.i18nService.t("appUri") - : this.i18nService.t("appUriCount", this.index + 1); + ? this.i18nService.t("desktopApp") + : this.i18nService.t("desktopAppCount", this.index + 1); } return this.index === 0