From f78415adb36b530183a550e131fa27bc737381f9 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 16:57:15 +0000 Subject: [PATCH 1/8] Need to auto import for e2e tests --- extensions/context.py | 1 + template/frontend/package.json.jinja | 3 ++- ...itest.config.ts => vitest.config.ts.jinja} | 21 ++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) rename template/frontend/{vitest.config.ts => vitest.config.ts.jinja} (86%) 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 86% rename from template/frontend/vitest.config.ts rename to template/frontend/vitest.config.ts.jinja index ffca794cb..b7e3414ea 100644 --- a/template/frontend/vitest.config.ts +++ b/template/frontend/vitest.config.ts.jinja @@ -2,7 +2,8 @@ import { fileURLToPath } from "node:url"; import { defineVitestProject } from "@nuxt/test-utils/config"; import { defineConfig, type TestProjectInlineConfiguration } from "vitest/config"; - +{% if is_circuit_python_driver %}import AutoImport from "unplugin-auto-import/vite"; +{% endif %} 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 const sharedDefine = { @@ -80,6 +81,24 @@ const e2eProject = { "@": appDir, }, }, +{% if is_circuit_python_driver %} + // 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 + }), + ], +{% endif %} test: { name: "e2e", include: ["tests/e2e/**/*.spec.ts"], From a734071c70c73e59f789eca61c6d8e9449deafdc Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:06:59 +0000 Subject: [PATCH 2/8] Pre commit --- template/frontend/vitest.config.ts.jinja | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index b7e3414ea..39a3ecfa3 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -1,9 +1,9 @@ import { fileURLToPath } from "node:url"; import { defineVitestProject } from "@nuxt/test-utils/config"; -import { defineConfig, type TestProjectInlineConfiguration } from "vitest/config"; {% if is_circuit_python_driver %}import AutoImport from "unplugin-auto-import/vite"; {% endif %} +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 const sharedDefine = { @@ -89,10 +89,7 @@ const e2eProject = { AutoImport({ imports: [ { - "@lab-sync/nuxt-common": [ - "useKiotaClient", - "_resetKiotaClientForTests", - ], + "@lab-sync/nuxt-common": ["useKiotaClient", "_resetKiotaClientForTests"], }, ], dts: false, // type-checking runs separately via pre-commit; no .d.ts needed here From eca6a9474a1618c2ef9fc440cfbfd0a5b85b9d18 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:09:10 +0000 Subject: [PATCH 3/8] Space --- template/frontend/vitest.config.ts.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index 39a3ecfa3..053003af6 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -4,6 +4,7 @@ import { defineVitestProject } from "@nuxt/test-utils/config"; {% if is_circuit_python_driver %}import AutoImport from "unplugin-auto-import/vite"; {% endif %} 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 const sharedDefine = { From fc19a0395fdc3178f69cefc5bb7d294bfd2426cc Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:23:12 +0000 Subject: [PATCH 4/8] use raw to avoid footguns --- template/frontend/vitest.config.ts.jinja | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index 053003af6..1ce7fffa3 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -1,8 +1,8 @@ -import { fileURLToPath } from "node:url"; +{% raw %}import { fileURLToPath } from "node:url"; import { defineVitestProject } from "@nuxt/test-utils/config"; -{% if is_circuit_python_driver %}import AutoImport from "unplugin-auto-import/vite"; -{% endif %} +{% 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 @@ -82,7 +82,7 @@ const e2eProject = { "@": appDir, }, }, -{% if is_circuit_python_driver %} +{% 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. @@ -96,7 +96,7 @@ const e2eProject = { dts: false, // type-checking runs separately via pre-commit; no .d.ts needed here }), ], -{% endif %} +{% endraw %}{% endif %}{% raw %} test: { name: "e2e", include: ["tests/e2e/**/*.spec.ts"], From ca4813d639dfa64be41fc4e9744aa2753751db86 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:30:22 +0000 Subject: [PATCH 5/8] =?UTF-8?q?End=20raw=20raw=20raw=20raw=20(=F0=9F=8E=B5?= =?UTF-8?q?=20lady=20gaga=20=F0=9F=8E=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/frontend/vitest.config.ts.jinja | 1 + 1 file changed, 1 insertion(+) diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index 1ce7fffa3..fa355fec6 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -128,3 +128,4 @@ export default defineConfig({ }, }, }); +{% endraw %} \ No newline at end of file From 3bc4bbcd0f547271f6d0957375b4b84342cf5e08 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:33:38 +0000 Subject: [PATCH 6/8] Ok this will do it --- template/frontend/vitest.config.ts.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index fa355fec6..301aedf0c 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -128,4 +128,4 @@ export default defineConfig({ }, }, }); -{% endraw %} \ No newline at end of file +{% endraw %} From e5a4c4c41c63e1a4112c1edcf837451ff9ba9228 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:39:37 +0000 Subject: [PATCH 7/8] Ok this maybe. Dont add extra line b/c ts doesn't want it --- .devcontainer/devcontainer.json | 2 +- .pre-commit-config.yaml | 1 + template/frontend/vitest.config.ts.jinja | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 19486cf02..ebb3e2318 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -65,5 +65,5 @@ "initializeCommand": "sh .devcontainer/initialize-command.sh", "onCreateCommand": "sh .devcontainer/on-create-command.sh", "postStartCommand": "sh .devcontainer/post-start-command.sh" - // Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 9adcea8e # spellchecker:disable-line + // Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 496df61a # spellchecker:disable-line } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa67917ff..e7b305ec7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,6 +72,7 @@ repos: .*tests/.*/__snapshots__/.*| .devcontainer/devcontainer-lock.json| .*\.copier-answers\.yml(\.jinja(-base)?)?| + .*vitest.config.ts\.jinja| .*\.xml| .*\.svg| .*/vendor_files/.*| diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index 301aedf0c..fa355fec6 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -128,4 +128,4 @@ export default defineConfig({ }, }, }); -{% endraw %} +{% endraw %} \ No newline at end of file From bc04f789a227da5ddb59b2a7181657ae327a1d76 Mon Sep 17 00:00:00 2001 From: zender Date: Fri, 22 May 2026 17:51:43 +0000 Subject: [PATCH 8/8] Real fix for end line --- .devcontainer/devcontainer.json | 2 +- .pre-commit-config.yaml | 1 - template/frontend/vitest.config.ts.jinja | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ebb3e2318..19486cf02 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -65,5 +65,5 @@ "initializeCommand": "sh .devcontainer/initialize-command.sh", "onCreateCommand": "sh .devcontainer/on-create-command.sh", "postStartCommand": "sh .devcontainer/post-start-command.sh" - // Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 496df61a # spellchecker:disable-line + // Devcontainer context hash (do not manually edit this, it's managed by a pre-commit hook): 9adcea8e # spellchecker:disable-line } diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7b305ec7..fa67917ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,7 +72,6 @@ repos: .*tests/.*/__snapshots__/.*| .devcontainer/devcontainer-lock.json| .*\.copier-answers\.yml(\.jinja(-base)?)?| - .*vitest.config.ts\.jinja| .*\.xml| .*\.svg| .*/vendor_files/.*| diff --git a/template/frontend/vitest.config.ts.jinja b/template/frontend/vitest.config.ts.jinja index fa355fec6..5bc03660d 100644 --- a/template/frontend/vitest.config.ts.jinja +++ b/template/frontend/vitest.config.ts.jinja @@ -127,5 +127,4 @@ export default defineConfig({ exclude: ["**/generated/**"], }, }, -}); -{% endraw %} \ No newline at end of file +});{% endraw %}