]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
test(ui-web): drain dynamic imports globally for async components (#1893)
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 13 Jun 2026 23:46:21 +0000 (01:46 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jun 2026 23:46:21 +0000 (01:46 +0200)
Add vi.dynamicImportSettled() to the global afterEach hook so pending
dynamic imports (defineAsyncComponent loaders, lazy routes) settle
before Vitest tears down the test environment. Prevents
EnvironmentTeardownError on transitive .vue import chains observed
under filtered runs (e.g. -t "should open authorize dialog").

Covers App.vue, ModernLayout.vue, and any future component using
defineAsyncComponent or lazy-loaded routes.

ui/web/tests/setup.ts
ui/web/tests/unit/skins/modern/ModernLayout.test.ts

index b1a7c7104e48c84df482dd4f0215769cca2f089a..b3585e3534da79b321684b3e76f754d83de076eb 100644 (file)
@@ -26,6 +26,7 @@ vi.mock('vue-toast-notification', () => ({
   useToast: () => toastMock,
 }))
 
-afterEach(() => {
+afterEach(async () => {
   localStorage.clear()
+  await vi.dynamicImportSettled()
 })
index fab7a24135effa1845d620e76ed3a219fdaeb354..dc9ed509cabcebc3b22e9d5223e3559adfe61956 100644 (file)
@@ -364,6 +364,8 @@ describe('ModernLayout', () => {
     await flushPromises()
     // Verify dialog components exist (stubbed to true = rendered when dialog state is set)
     expect(wrapper.findComponent({ name: 'AuthorizeDialog' }).exists()).toBe(true)
+    expect(wrapper.findComponent({ name: 'SetSupervisionUrlDialog' }).exists()).toBe(true)
+    expect(wrapper.findComponent({ name: 'StartTransactionDialog' }).exists()).toBe(true)
     wrapper.unmount()
   })
 })