diff --git a/src/features/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap b/src/features/preferences/__snapshots__/navigation-to-application-preferences.test.tsx.snap similarity index 54% rename from src/features/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap rename to src/features/preferences/__snapshots__/navigation-to-application-preferences.test.tsx.snap index fc951ae75a..de9a302163 100644 --- a/src/features/preferences/__snapshots__/navigation-to-application-preferences.test.ts.snap +++ b/src/features/preferences/__snapshots__/navigation-to-application-preferences.test.tsx.snap @@ -1,5 +1,1414 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`preferences - navigation to application preferences given in preferences, when rendered renders 1`] = ` +
+
+
+
+
+ + + home + + +
+
+
+ + + arrow_back + + +
+
+
+ + + arrow_forward + + +
+
+
+
+
+
+
+ +
+
+
+

+ Application +

+
+
+
+ Theme + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ Extension Install Registry + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+

+ This setting is to change the registry URL for installing extensions by name. + If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your + + .npmrc + + file or in the input below. +

+
+ +
+
+
+
+
+
+
+
+ Start-up + +
+ +
+
+
+
+
+
+ Update Channel + +
+
+ + +
+
+
+ Stable +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ Locale Timezone + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+ + + close + + +
+ +
+
+
+
+
+
+
+
+
+ + + arrow_left + + +
+
+ 0 +
+
+ + + arrow_right + + +
+
+
+
+
+
+
+
+
+`; + +exports[`preferences - navigation to application preferences given in preferences, when rendered when extension with application preference items gets enabled renders 1`] = ` +
+
+
+
+
+ + + home + + +
+
+
+ + + arrow_back + + +
+
+
+ + + arrow_forward + + +
+
+
+
+
+
+
+ +
+
+
+

+ Application +

+
+
+
+ Some application-preference item + +
+
+
+
+
+
+
+
+
+
+
+
+ Theme + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ Extension Install Registry + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+

+ This setting is to change the registry URL for installing extensions by name. + If you are unable to access the default registry (https://registry.npmjs.org) you can change it in your + + .npmrc + + file or in the input below. +

+
+ +
+
+
+
+
+
+
+
+ Start-up + +
+ +
+
+
+
+
+
+ Update Channel + +
+
+ + +
+
+
+ Stable +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+ Locale Timezone + +
+
+ + +
+
+
+ Select... +
+
+ +
+
+
+ + +
+
+
+
+
+
+
+
+
+
+
+ + + close + + +
+ +
+
+
+
+
+
+
+
+
+ + + arrow_left + + +
+
+ 0 +
+
+ + + arrow_right + + +
+
+
+
+
+
+
+
+
+`; + exports[`preferences - navigation to application preferences given in some child page of preferences, when rendered renders 1`] = `
{ let builder: ApplicationBuilder; @@ -16,6 +18,53 @@ describe("preferences - navigation to application preferences", () => { builder = getApplicationBuilder(); }); + describe("given in preferences, when rendered", () => { + let rendered: RenderResult; + let discover: Discover; + + beforeEach(async () => { + builder.beforeWindowStart(() => { + builder.preferences.navigate(); + }); + + rendered = await builder.render(); + + discover = discoverFor(() => rendered); + }); + + it("renders", () => { + expect(rendered.container).toMatchSnapshot(); + }); + + it("shows application preferences", () => { + const { discovered } = discover.querySingleElement( + "preference-page", + "application-page", + ); + + expect(discovered).not.toBeNull(); + }); + + describe("when extension with application preference items gets enabled", () => { + beforeEach(() => { + builder.extensions.enable( + extensionStubWithApplicationPreferenceItems, + ); + }); + + it("renders", () => { + expect(rendered.container).toMatchSnapshot(); + }); + + it("shows preference items of the extension", () => { + const { attributeValues } = + discover.queryAllElements("preference-item"); + + expect(attributeValues).toContain("preference-item-for-extension-some-test-extension-name-item-some-application-preference-item-id"); + }); + }); + }); + describe("given in some child page of preferences, when rendered", () => { let rendered: RenderResult; let discover: Discover; @@ -85,3 +134,22 @@ describe("preferences - navigation to application preferences", () => { }); }); +const extensionStubWithApplicationPreferenceItems: FakeExtensionOptions = { + id: "some-test-extension-id", + name: "some-test-extension-name", + + rendererOptions: { + appPreferences: [ + { + title: "Some application-preference item", + id: "some-application-preference-item-id", + showInPreferencesTab: "application", + + components: { + Hint: () =>
, + Input: () =>
, + }, + }, + ], + }, +}; diff --git a/src/features/preferences/renderer/compliance-for-legacy-extension-api/registrator-for-preference-items.injectable.tsx b/src/features/preferences/renderer/compliance-for-legacy-extension-api/registrator-for-preference-items.injectable.tsx index 6a79f96c37..351fc7a893 100644 --- a/src/features/preferences/renderer/compliance-for-legacy-extension-api/registrator-for-preference-items.injectable.tsx +++ b/src/features/preferences/renderer/compliance-for-legacy-extension-api/registrator-for-preference-items.injectable.tsx @@ -120,10 +120,10 @@ const registratorForPreferenceItemsInjectable = getInjectable({ kind: "block" as const, id: itemId, - // Note: Legacy extensions considered telemetry as magic string, and so does this code + // Note: Legacy extensions considered telemetry and application as magic strings, and so does this code parentId: registration.showInPreferencesTab - ? registration.showInPreferencesTab === "telemetry" - ? "telemetry-page" + ? ["telemetry", "application"].includes(registration.showInPreferencesTab) + ? `${registration.showInPreferencesTab}-page` : `${commonId}-additional-page-${registration.showInPreferencesTab}` : primaryPageId,