import { vi } from 'vitest' import { ref, computed, onMounted, watch } from 'vue' // ------------------------------------------------------------------- // Nuxt auto-import globals // These are injected by Nuxt at runtime but Vitest doesn't run Nuxt, // so we shim them here so test files can import store/composable modules // without hitting "X is not defined" errors. // ------------------------------------------------------------------- // $fetch — Nuxt's isomorphic fetch wrapper global.$fetch = vi.fn() // navigateTo — Nuxt router utility global.navigateTo = vi.fn() // Route middleware helpers global.defineNuxtRouteMiddleware = vi.fn((fn: Function) => fn) // Plugin helper (used in some plugin files, not in tests directly) global.defineNuxtPlugin = vi.fn((fn: Function) => fn) // Page meta (used in page components) global.definePageMeta = vi.fn() // Vue Composition API — re-export from Vue so stores using these // via Nuxt auto-imports resolve correctly in Vitest global.ref = ref global.computed = computed global.onMounted = onMounted global.watch = watch // useAuthStore — needed by middleware; forward-declared here so // admin.ts middleware can resolve it. Individual test files override // this with the real Pinia store instance. // (Set to undefined by default — tests that import middleware must // call setActivePinia first and then the real store will resolve.) global.useAuthStore = undefined as any