import { config } from '@vue/test-utils';
import { vi } from 'vitest';
// Make Math.random deterministic for stable snapshots (e.g., IDs in components)
vi.spyOn(Math, 'random').mockReturnValue(0.123456789);
// Stub SVG component imports to avoid verbose path data in snapshots
const SvgStub = {
template: '',
};
vi.mock('@/assets/images/logo-header.svg?component', () => ({
default: SvgStub,
}));
vi.mock('@/assets/images/login-company-logo.svg?component', () => ({
default: SvgStub,
}));
vi.mock('@/assets/images/built-on-openbmc-logo.svg?component', () => ({
default: SvgStub,
}));
// Mock vue-router - provide a minimal API for tests that import it
vi.mock('vue-router', () => ({
createRouter: () => ({}),
createMemoryHistory: () => ({}),
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
}),
useRoute: () => ({
params: {},
query: {},
meta: { title: '' },
}),
}));
// Use the real i18n instance - Vite's import.meta.glob works natively
import i18n from '@/i18n';
// Provide default global mocks/stubs
config.global.mocks = {
$t: (k) => k,
$route: { meta: { title: '' } },
$eventBus: {
on: () => {},
off: () => {},
emit: () => {},
$on: () => {},
$off: () => {},
$emit: () => {},
},
};
// Stubs with single root elements to properly inherit attributes like data-test-id
config.global.stubs = {
'router-link': { template: '