import { afterEach, expect, it, vi } from "vitest"; import { mount, flushPromises } from "@vue/test-utils"; import { defineComponent, h, nextTick } from "vue"; const demos = import.meta.glob( "../apps/docs/demos/{alert-dialog,drawer}-*.vue", ); const wrappers: ReturnType[] = []; afterEach(async () => { wrappers.splice(0).forEach((w) => w.unmount()); await flushPromises(); vi.restoreAllMocks(); document.body.innerHTML = ""; }); it("all 23 overlay demos coexist in one Vue app without duplicate IDs or warnings", async () => { const entries = await Promise.all( Object.values(demos).map( async (load) => ((await load()) as { default: Parameters[0] }).default, ), ); expect(entries).toHaveLength(23); const warnings = vi.spyOn(console, "warn").mockImplementation(() => {}); const wrapper = mount( defineComponent({ render: () => h( "main", entries.map((demo, i) => h("section", { "data-demo": i }, [h(demo)])), ), }), { attachTo: document.body }, ); wrappers.push(wrapper); await flushPromises(); await nextTick(); expect(wrapper.findAll("section[data-demo]")).toHaveLength(23); expect(wrapper.findAll("button").length).toBeGreaterThan(23); const ids = [...document.querySelectorAll("[id]")].map((el) => el.id); expect(new Set(ids).size).toBe(ids.length); expect(warnings).not.toHaveBeenCalled(); });