diff --git a/extensions/context.py b/extensions/context.py index 358cacf2f..dbd2a8b8c 100644 --- a/extensions/context.py +++ b/extensions/context.py @@ -88,6 +88,7 @@ def hook( # noqa: PLR0915 # yes, this is a lot of statements, but it's all just context["node_kiota_bundle_version"] = "1.0.0-preview.100" context["labsync_nuxt_common_version"] = "^0.1.0" context["tanstack_vue_table_version"] = "^8.21.3" + context["unplugin_auto_import_version"] = "^21.0.0" context["gha_checkout"] = "v6.0.2" context["gha_setup_python"] = "v6.2.0" diff --git a/template/frontend/package.json.jinja b/template/frontend/package.json.jinja index 5b47dea32..b366ed47e 100644 --- a/template/frontend/package.json.jinja +++ b/template/frontend/package.json.jinja @@ -75,7 +75,8 @@ "playwright-core": "{% endraw %}{{ playwright_version }}{% raw %}", "postcss": "^8.5.14", "tailwindcss": "{% endraw %}{{ tailwindcss_version }}{% raw %}", - "typescript": "{% endraw %}{{ typescript_version }}{% raw %}", + "typescript": "{% endraw %}{{ typescript_version }}{% raw %}",{% endraw %}{% if is_circuit_python_driver %}{% raw %} + "unplugin-auto-import": "{% endraw %}{{ unplugin_auto_import_version }}{% raw %}",{% endraw %}{% endif %}{% raw %} "vitest": "{% endraw %}{{ vitest_version }}{% raw %}", "vue-eslint-parser": "{% endraw %}{{ vue_eslint_parser_version }}{% raw %}", "vue-tsc": "{% endraw %}{{ vue_tsc_version }}{% raw %}" diff --git a/template/frontend/vitest.config.ts b/template/frontend/vitest.config.ts.jinja similarity index 85% rename from template/frontend/vitest.config.ts rename to template/frontend/vitest.config.ts.jinja index ffca794cb..5bc03660d 100644 --- a/template/frontend/vitest.config.ts +++ b/template/frontend/vitest.config.ts.jinja @@ -1,6 +1,8 @@ -import { fileURLToPath } from "node:url"; +{% raw %}import { fileURLToPath } from "node:url"; import { defineVitestProject } from "@nuxt/test-utils/config"; +{% endraw %}{% if is_circuit_python_driver %}import AutoImport from "unplugin-auto-import/vite"; +{% endif %}{% raw %} import { defineConfig, type TestProjectInlineConfiguration } from "vitest/config"; const fakerSeed = Number(process.env.TEST_FAKER_SEED) || Math.floor(Math.random() * 1e9); // to use this, you'll need to create a setup.ts file and add it to the vitest `setupFiles` config @@ -80,6 +82,21 @@ const e2eProject = { "@": appDir, }, }, +{% endraw %}{% if is_circuit_python_driver %}{% raw %} + // Nuxt auto-imports (like `useKiotaClient`) are injected at build time by Nuxt's vite plugin + // chain, which is absent here. This plugin replicates that injection for the e2e test context + // so composables that rely on auto-imports (e.g. useBackendClient → useKiotaClient) resolve. + plugins: [ + AutoImport({ + imports: [ + { + "@lab-sync/nuxt-common": ["useKiotaClient", "_resetKiotaClientForTests"], + }, + ], + dts: false, // type-checking runs separately via pre-commit; no .d.ts needed here + }), + ], +{% endraw %}{% endif %}{% raw %} test: { name: "e2e", include: ["tests/e2e/**/*.spec.ts"], @@ -110,4 +127,4 @@ export default defineConfig({ exclude: ["**/generated/**"], }, }, -}); +});{% endraw %}