diff --git a/src/components/MiniWidgetInstantiator.vue b/src/components/MiniWidgetInstantiator.vue index 028363dd8..a1a936dde 100644 --- a/src/components/MiniWidgetInstantiator.vue +++ b/src/components/MiniWidgetInstantiator.vue @@ -1,63 +1,11 @@ diff --git a/src/tests/libs/widgets-loader.test.ts b/src/tests/libs/widgets-loader.test.ts index cdcf83c59..a15671ee1 100644 --- a/src/tests/libs/widgets-loader.test.ts +++ b/src/tests/libs/widgets-loader.test.ts @@ -1,10 +1,25 @@ import { expect, test } from 'vitest' +import { MiniWidgetType } from '@/types/miniWidgets' import { WidgetType } from '@/types/widgets' test('Test widgets exist', async () => { + await enum_to_files_checker(WidgetType, '@/components/widgets/${name}.vue') +}) + +test('Test mini-widgets exist', async () => { + await enum_to_files_checker(MiniWidgetType, '@/components/mini-widgets/${name}.vue') +}) + +/** + * Test helper to verify if all enums names matches with a file list in a path + * @param {T} enum_type Enum type with values as filenames + * @param {string} path_template Path template as string, where name should be used as filename + */ +async function enum_to_files_checker(enum_type: T, path_template: string): Promise { const loader = await Promise.allSettled( - Object.values(WidgetType).map((name) => import(`@/components/widgets/${name}.vue`)) + /* eslint-disable @typescript-eslint/no-unused-vars */ + Object.values(enum_type).map((name) => import(eval('`' + path_template + '`'))) // Please, have marcy of my soul ) const found_all_files = loader.every((file) => { if (file.status == 'fulfilled') { @@ -17,4 +32,4 @@ test('Test widgets exist', async () => { return !failed_to_find }) expect(found_all_files).toBe(true) -}) +}