From c9624be37a15864fdcda0e0fae3c17884a251516 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:35:22 +0100 Subject: [PATCH 1/4] fix: addressing loading issue --- packages/frontend/src/lib/NavPage.svelte | 8 +++++++- .../table/model}/ModelColumnHW.svelte | 0 .../table/model}/ModelColumnLicense.svelte | 0 .../table/model}/ModelColumnName.svelte | 0 .../table/model}/ModelColumnPopularity.svelte | 0 .../table/model}/ModelColumnRegistry.svelte | 0 packages/frontend/src/pages/Model.svelte | 2 +- packages/frontend/src/pages/Models.svelte | 15 ++++++--------- packages/frontend/src/pages/RecipeModels.svelte | 12 ++++++------ 9 files changed, 20 insertions(+), 17 deletions(-) rename packages/frontend/src/{pages => lib/table/model}/ModelColumnHW.svelte (100%) rename packages/frontend/src/{pages => lib/table/model}/ModelColumnLicense.svelte (100%) rename packages/frontend/src/{pages => lib/table/model}/ModelColumnName.svelte (100%) rename packages/frontend/src/{pages => lib/table/model}/ModelColumnPopularity.svelte (100%) rename packages/frontend/src/{pages => lib/table/model}/ModelColumnRegistry.svelte (100%) diff --git a/packages/frontend/src/lib/NavPage.svelte b/packages/frontend/src/lib/NavPage.svelte index a799f104b..04a7a03dd 100644 --- a/packages/frontend/src/lib/NavPage.svelte +++ b/packages/frontend/src/lib/NavPage.svelte @@ -1,10 +1,12 @@ @@ -57,7 +59,11 @@ export let icon: IconDefinition | undefined = undefined;
- + {#if loading} + + {:else} + + {/if}
diff --git a/packages/frontend/src/pages/ModelColumnHW.svelte b/packages/frontend/src/lib/table/model/ModelColumnHW.svelte similarity index 100% rename from packages/frontend/src/pages/ModelColumnHW.svelte rename to packages/frontend/src/lib/table/model/ModelColumnHW.svelte diff --git a/packages/frontend/src/pages/ModelColumnLicense.svelte b/packages/frontend/src/lib/table/model/ModelColumnLicense.svelte similarity index 100% rename from packages/frontend/src/pages/ModelColumnLicense.svelte rename to packages/frontend/src/lib/table/model/ModelColumnLicense.svelte diff --git a/packages/frontend/src/pages/ModelColumnName.svelte b/packages/frontend/src/lib/table/model/ModelColumnName.svelte similarity index 100% rename from packages/frontend/src/pages/ModelColumnName.svelte rename to packages/frontend/src/lib/table/model/ModelColumnName.svelte diff --git a/packages/frontend/src/pages/ModelColumnPopularity.svelte b/packages/frontend/src/lib/table/model/ModelColumnPopularity.svelte similarity index 100% rename from packages/frontend/src/pages/ModelColumnPopularity.svelte rename to packages/frontend/src/lib/table/model/ModelColumnPopularity.svelte diff --git a/packages/frontend/src/pages/ModelColumnRegistry.svelte b/packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte similarity index 100% rename from packages/frontend/src/pages/ModelColumnRegistry.svelte rename to packages/frontend/src/lib/table/model/ModelColumnRegistry.svelte diff --git a/packages/frontend/src/pages/Model.svelte b/packages/frontend/src/pages/Model.svelte index 453a28890..008cdc825 100644 --- a/packages/frontend/src/pages/Model.svelte +++ b/packages/frontend/src/pages/Model.svelte @@ -16,7 +16,7 @@ onMount(async () => { }) - + diff --git a/packages/frontend/src/pages/Models.svelte b/packages/frontend/src/pages/Models.svelte index 613747562..63a69b44d 100644 --- a/packages/frontend/src/pages/Models.svelte +++ b/packages/frontend/src/pages/Models.svelte @@ -4,11 +4,11 @@ import NavPage from '../lib/NavPage.svelte'; import Table from '../lib/table/Table.svelte'; import { Column, Row } from '../lib/table/table'; import { localModels } from '../stores/local-models'; -import ModelColumnName from './ModelColumnName.svelte'; -import ModelColumnRegistry from './ModelColumnRegistry.svelte'; -import ModelColumnPopularity from './ModelColumnPopularity.svelte'; -import ModelColumnLicense from './ModelColumnLicense.svelte'; -import ModelColumnHw from './ModelColumnHW.svelte'; +import ModelColumnName from '../lib/table/model/ModelColumnName.svelte'; +import ModelColumnRegistry from '../lib/table/model/ModelColumnRegistry.svelte'; +import ModelColumnPopularity from '../lib/table/model/ModelColumnPopularity.svelte'; +import ModelColumnLicense from '../lib/table/model/ModelColumnLicense.svelte'; +import ModelColumnHw from '../lib/table/model/ModelColumnHW.svelte'; import { onDestroy, onMount } from 'svelte'; import { studioClient } from '/@/utils/client'; import type { Category } from '@shared/models/ICategory'; @@ -73,12 +73,9 @@ onDestroy(() => { - +
- {#if loading} - - {/if}
{#if !loading} {#if tasks.length > 0} diff --git a/packages/frontend/src/pages/RecipeModels.svelte b/packages/frontend/src/pages/RecipeModels.svelte index a4def8571..effd0e591 100644 --- a/packages/frontend/src/pages/RecipeModels.svelte +++ b/packages/frontend/src/pages/RecipeModels.svelte @@ -2,11 +2,11 @@ import type { ModelInfo } from '@shared/src/models/IModelInfo'; import Table from '../lib/table/Table.svelte'; import { Column, Row } from '../lib/table/table'; - import ModelColumnName from './ModelColumnName.svelte'; - import ModelColumnRegistry from './ModelColumnRegistry.svelte'; - import ModelColumnPopularity from './ModelColumnPopularity.svelte'; - import ModelColumnLicense from './ModelColumnLicense.svelte'; - import ModelColumnHw from './ModelColumnHW.svelte'; + import ModelColumnName from '../lib/table/model/ModelColumnName.svelte'; + import ModelColumnRegistry from '../lib/table/model/ModelColumnRegistry.svelte'; + import ModelColumnPopularity from '../lib/table/model/ModelColumnPopularity.svelte'; + import ModelColumnLicense from '../lib/table/model/ModelColumnLicense.svelte'; + import ModelColumnHw from '../lib/table/model/ModelColumnHW.svelte'; import { onMount } from 'svelte'; import { studioClient } from '../utils/client'; @@ -16,7 +16,7 @@ onMount(async () => { if (modelsIds && modelsIds.length > 0) { models = await studioClient.getModelsByIds(modelsIds); - } + } }) const columns: Column[] = [ From 9ec894d8a61bf08f15839b5e6965a070c7688e48 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:18:55 +0100 Subject: [PATCH 2/4] test: ensuring progress is displayed when loading is true --- packages/frontend/src/lib/NavPage.spec.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 packages/frontend/src/lib/NavPage.spec.ts diff --git a/packages/frontend/src/lib/NavPage.spec.ts b/packages/frontend/src/lib/NavPage.spec.ts new file mode 100644 index 000000000..dce409e37 --- /dev/null +++ b/packages/frontend/src/lib/NavPage.spec.ts @@ -0,0 +1,22 @@ +import '@testing-library/jest-dom/vitest'; +import { test, expect } from 'vitest'; +import { fireEvent, render, screen, within } from '@testing-library/svelte'; +import NavPage from '/@/lib/NavPage.svelte'; + +test('NavPage should have linear progress', async () => { + // render the component + render(NavPage, {loading: true, title: 'dummy'}); + + const content = await screen.findByLabelText('content'); + expect(content).toBeDefined(); + expect(content.firstChild?.nodeName).toBe('PROGRESS'); +}); + +test('NavPage should not have linear progress', async () => { + // render the component + render(NavPage, {title: 'dummy'},); + + const content = await screen.findByLabelText('content'); + expect(content).toBeDefined(); + expect(content.firstChild).toBeNull(); // no slot content provided +}); From 3b5db7b04f4d32825f90841fd42a53e3497cf447 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:21:04 +0100 Subject: [PATCH 3/4] fix: linter --- packages/frontend/src/lib/NavPage.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/lib/NavPage.spec.ts b/packages/frontend/src/lib/NavPage.spec.ts index dce409e37..4ac765b9e 100644 --- a/packages/frontend/src/lib/NavPage.spec.ts +++ b/packages/frontend/src/lib/NavPage.spec.ts @@ -1,6 +1,6 @@ import '@testing-library/jest-dom/vitest'; import { test, expect } from 'vitest'; -import { fireEvent, render, screen, within } from '@testing-library/svelte'; +import { render, screen } from '@testing-library/svelte'; import NavPage from '/@/lib/NavPage.svelte'; test('NavPage should have linear progress', async () => { @@ -14,7 +14,7 @@ test('NavPage should have linear progress', async () => { test('NavPage should not have linear progress', async () => { // render the component - render(NavPage, {title: 'dummy'},); + render(NavPage, {title: 'dummy'}); const content = await screen.findByLabelText('content'); expect(content).toBeDefined(); From a2b2b84a27d2a24d757ddb49becde3ab30376567 Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:26:34 +0100 Subject: [PATCH 4/4] fix: prettier --- packages/frontend/src/lib/NavPage.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/lib/NavPage.spec.ts b/packages/frontend/src/lib/NavPage.spec.ts index 4ac765b9e..fde5d0da0 100644 --- a/packages/frontend/src/lib/NavPage.spec.ts +++ b/packages/frontend/src/lib/NavPage.spec.ts @@ -5,7 +5,7 @@ import NavPage from '/@/lib/NavPage.svelte'; test('NavPage should have linear progress', async () => { // render the component - render(NavPage, {loading: true, title: 'dummy'}); + render(NavPage, { loading: true, title: 'dummy' }); const content = await screen.findByLabelText('content'); expect(content).toBeDefined(); @@ -14,7 +14,7 @@ test('NavPage should have linear progress', async () => { test('NavPage should not have linear progress', async () => { // render the component - render(NavPage, {title: 'dummy'}); + render(NavPage, { title: 'dummy' }); const content = await screen.findByLabelText('content'); expect(content).toBeDefined();