diff --git a/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.spec.ts b/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.spec.ts index fb8c7e9d837ce..e42d258d10055 100644 --- a/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.spec.ts +++ b/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.spec.ts @@ -20,7 +20,7 @@ import '@testing-library/jest-dom'; import { test, expect, vi } from 'vitest'; -import { render, screen } from '@testing-library/svelte'; +import { render, screen, waitForElementToBeRemoved } from '@testing-library/svelte'; import PreferencesExtensionRendering from './PreferencesExtensionRendering.svelte'; import { extensionInfos } from '../../stores/extensions'; @@ -113,4 +113,27 @@ describe('PreferencesExtensionRendering', () => { expect(remove).toBeInTheDocument(); expect(remove).toBeDisabled(); }); + + test('Expect empty screen if there is no matching extension (could be during providerInfos is loading)', async () => { + // clear store + extensionInfos.set([]); + + // start without extension in the stores, should be empty + render(PreferencesExtensionRendering, { extensionId: 'test' }); + + // check empty page is displayed if we do not have matching of the extension + const emptyHeading = screen.getByRole('heading', { name: 'Extension not found', level: 1 }); + expect(emptyHeading).toBeInTheDocument(); + + // now register the extension in the store + setup('started'); + + // wait empty page disappear + await waitForElementToBeRemoved(() => screen.queryByRole('heading', { name: 'Extension not found', level: 1 })); + + // now check disable button is displayed as extension is started + const start = screen.getByRole('button', { name: 'Disable' }); + expect(start).toBeInTheDocument(); + expect(start).toBeEnabled(); + }); }); diff --git a/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.svelte b/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.svelte index eecd30da66f6c..a8f3526ca4bc9 100644 --- a/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.svelte +++ b/packages/renderer/src/lib/preferences/PreferencesExtensionRendering.svelte @@ -5,12 +5,14 @@ import type { ExtensionInfo } from '../../../../main/src/plugin/api/extension-in import SettingsPage from './SettingsPage.svelte'; import ExtensionStatus from '../ui/ExtensionStatus.svelte'; import Button from '../ui/Button.svelte'; -import { faPlay, faStop, faTrash } from '@fortawesome/free-solid-svg-icons'; +import { faPlay, faPuzzlePiece, faStop, faTrash } from '@fortawesome/free-solid-svg-icons'; import { router } from 'tinro'; +import EmptyScreen from '../ui/EmptyScreen.svelte'; export let extensionId: string = undefined; let extensionInfo: ExtensionInfo; + $: extensionInfo = $extensionInfos.find(extension => extension.id === extensionId); $: hideOnboardingButton = true; $: hasOnboarding(extensionId).then(value => (hideOnboardingButton = value)); @@ -32,72 +34,76 @@ async function hasOnboarding(extensionId: string): Promise { } - - - {extensionInfo.description} - -
- {#if extensionInfo} - - -
-
Status
- -
- -
- -
- -
- - -
- +{#if !extensionInfo} + +{:else} + + + {extensionInfo.description} + +
+ {#if extensionInfo} + + +
+
Status
+
- - {#if extensionInfo.removable} +
+
- {:else} -
Default extension, cannot be removed
- {/if} -
-
- -
- {#if extensionInfo.error} -
-
Extension error: {extensionInfo.error.message}
- {#if extensionInfo.error.stack} -
Stack trace
-
{extensionInfo.error.stack}
+ +
+ +
+ + + {#if extensionInfo.removable} +
+ +
+ {:else} +
Default extension, cannot be removed
{/if}
- {/if} -
- {/if} -
+ +
+ +
+ {#if extensionInfo.error} +
+
Extension error: {extensionInfo.error.message}
+ {#if extensionInfo.error.stack} +
Stack trace
+
{extensionInfo.error.stack}
+ {/if} +
+ {/if} + + {/if} +
+{/if}