mirror of
https://github.com/EKKOLearnAI/hermes-web-ui.git
synced 2026-05-26 22:10:15 +00:00
076a7c2a38
- Set up Vitest with jsdom for client tests, node for server tests - Add tests for auth service, proxy handler, API client, and profiles store - Strip Authorization header in proxy to prevent web-ui token leaking to gateway - Distinguish local BFF vs proxied gateway 401s to avoid false logouts - Remove unused hero.png asset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import { vi } from 'vitest'
|
|
|
|
// Client-only setup (window/localStorage only exist in jsdom)
|
|
if (typeof window !== 'undefined') {
|
|
// Mock window.matchMedia
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: vi.fn().mockImplementation((query: string) => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: vi.fn(),
|
|
removeListener: vi.fn(),
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
dispatchEvent: vi.fn(),
|
|
})),
|
|
})
|
|
|
|
// Mock localStorage
|
|
const store: Record<string, string> = {}
|
|
Object.defineProperty(window, 'localStorage', {
|
|
value: {
|
|
getItem: vi.fn((key: string) => store[key] ?? null),
|
|
setItem: vi.fn((key: string, value: string) => { store[key] = value }),
|
|
removeItem: vi.fn((key: string) => { delete store[key] }),
|
|
clear: vi.fn(() => { for (const k of Object.keys(store)) delete store[k] }),
|
|
get length() { return Object.keys(store).length },
|
|
key: vi.fn((i: number) => Object.keys(store)[i] ?? null),
|
|
},
|
|
})
|
|
}
|