import { vi } from "vitest"; import { config } from "@vue/test-utils"; import createDOMPurify from "dompurify"; // Initialize DOMPurify with the jsdom window let DOMPurify; try { if (typeof createDOMPurify === "function") { DOMPurify = createDOMPurify(window); } else if (createDOMPurify && typeof createDOMPurify.default === "function") { DOMPurify = createDOMPurify.default(window); } else { DOMPurify = createDOMPurify; } } catch (e) { console.error("Failed to initialize DOMPurify:", e); } // Global mocks if (DOMPurify) { global.DOMPurify = DOMPurify; window.DOMPurify = DOMPurify; } global.performance.mark = vi.fn(); global.performance.measure = vi.fn(); global.performance.getEntriesByName = vi.fn(() => []); global.performance.clearMarks = vi.fn(); global.performance.clearMeasures = vi.fn(); // Mock window.api by default to prevent TypeErrors global.api = { get: vi.fn().mockResolvedValue({ data: {} }), post: vi.fn().mockResolvedValue({ data: {} }), put: vi.fn().mockResolvedValue({ data: {} }), patch: vi.fn().mockResolvedValue({ data: {} }), delete: vi.fn().mockResolvedValue({ data: {} }), isCancel: vi.fn().mockReturnValue(false), }; window.api = global.api; // Stub all Vuetify components to avoid warnings and CSS issues config.global.stubs = { MaterialDesignIcon: { template: '