test(platform-analytics): ✅ Add test utilities and mock configurations in setup.ts for platform analytics feature testing
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
e6a0a7c956
commit
439244af70
1 changed files with 40 additions and 0 deletions
|
|
@ -113,3 +113,43 @@ vi.mock('@lilith/ui-primitives', () => ({
|
|||
Card: ({ children }: { children: React.ReactNode }) => React.createElement('div', { 'data-testid': 'card' }, children),
|
||||
Button: ({ children }: { children: React.ReactNode }) => React.createElement('button', {}, children),
|
||||
}));
|
||||
|
||||
// Mock UI router (broken dist in node_modules)
|
||||
vi.mock('@lilith/ui-router', () => ({
|
||||
MemoryRouter: ({ children }: { children: React.ReactNode }) => React.createElement('div', {}, children),
|
||||
useNavigate: () => vi.fn(),
|
||||
useLocation: () => ({ pathname: '/', search: '', hash: '', state: null, key: 'default' }),
|
||||
useParams: () => ({}),
|
||||
useSearchParams: () => [new URLSearchParams(), vi.fn()],
|
||||
Link: ({ children, to }: { children: React.ReactNode; to: string }) => React.createElement('a', { href: to }, children),
|
||||
Routes: ({ children }: { children: React.ReactNode }) => React.createElement('div', {}, children),
|
||||
Route: ({ element }: { element: React.ReactNode }) => React.createElement('div', {}, element),
|
||||
}));
|
||||
|
||||
// Mock UI icons — auto-stub any named export as a simple span
|
||||
vi.mock('@lilith/ui-icons', async () => {
|
||||
const iconStub = () => React.createElement('span', { 'data-testid': 'icon' });
|
||||
// List all icon names used across the frontend to avoid vitest export warnings
|
||||
const iconNames = [
|
||||
'SearchIcon', 'GlobeIcon', 'MousePointerClickIcon', 'TrendingUpIcon',
|
||||
'TrendingDownIcon', 'BarChart3Icon', 'CheckCircleIcon', 'XCircleIcon',
|
||||
'ChevronUpIcon', 'ChevronDownIcon', 'ArrowUpIcon', 'ArrowDownIcon',
|
||||
'ArrowDownRightIcon', 'ArrowDownUpIcon', 'ArrowRightIcon',
|
||||
'CalendarIcon', 'FilterIcon', 'SettingsIcon', 'RefreshIcon',
|
||||
'DownloadIcon', 'ExternalLinkIcon', 'UsersIcon', 'UserPlusIcon',
|
||||
'UserCheckIcon', 'UserIcon', 'DollarSignIcon', 'CreditCardIcon',
|
||||
'CoinsIcon', 'PercentIcon', 'WalletIcon', 'ReceiptIcon',
|
||||
'ActivityIcon', 'ZapIcon', 'AlertCircleIcon', 'AlertTriangleIcon',
|
||||
'ClockIcon', 'TimerIcon', 'ServerIcon', 'FileTextIcon', 'LogOutIcon',
|
||||
'InfoIcon', 'BugIcon', 'TargetIcon', 'MinusIcon', 'LayersIcon',
|
||||
'SlidersHorizontalIcon', 'Grid3X3Icon', 'GaugeIcon', 'GitBranchIcon',
|
||||
'GitCompareArrowsIcon', 'FlaskConicalIcon', 'TrophyIcon', 'PieChartIcon',
|
||||
'LayoutGridIcon', 'MenuIcon', 'XIcon', 'RadioIcon', 'SunIcon', 'MoonIcon',
|
||||
'AwardIcon', 'EyeIcon',
|
||||
];
|
||||
const exports: Record<string, typeof iconStub> = {};
|
||||
for (const name of iconNames) {
|
||||
exports[name] = iconStub;
|
||||
}
|
||||
return exports;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue