diff --git a/frontend/src/app/lib/registry.ts b/frontend/src/app/lib/registry.ts index 8f83ed8887..8930841cbc 100644 --- a/frontend/src/app/lib/registry.ts +++ b/frontend/src/app/lib/registry.ts @@ -6,7 +6,7 @@ */ import type { FeatureManifest } from '@shared/shell/features'; -const modules = import.meta.glob<{ default: FeatureManifest }>('../features/*/index.ts', { +const modules = import.meta.glob<{ default: FeatureManifest }>('../../features/*/index.ts', { eager: true, }); diff --git a/frontend/src/app/test/registry.test.ts b/frontend/src/app/test/registry.test.ts new file mode 100644 index 0000000000..cf8d92bb72 --- /dev/null +++ b/frontend/src/app/test/registry.test.ts @@ -0,0 +1,23 @@ +/* + * The registry must find every folder in src/features/. A glob that matches nothing is no error to + * Vite, so a wrong path would otherwise start the app with no pages and no navigation. + */ +import { describe, expect, it } from 'vitest'; + +import { discoverFeatures } from '../lib/registry'; + +// Every file of every feature, unloaded: only the paths are read. +const featureFiles = Object.keys(import.meta.glob('../../features/*/**')); + +describe('discoverFeatures', () => { + it('finds a manifest for every feature folder', () => { + const folders = [ + ...new Set(featureFiles.map(file => /features\/([^/]+)\//.exec(file)?.[1] ?? '')), + ].sort((a, b) => a.localeCompare(b)); + const ids = discoverFeatures() + .map(feature => feature.id) + .sort((a, b) => a.localeCompare(b)); + expect(folders.length).toBeGreaterThan(0); + expect(ids).toEqual(folders); + }); +});