7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
test(client): make jsdom component tests run on any Node, no flags (#1670)
tashdroid981fa2d524df
diff --git a/client/vitest.config.ts b/client/vitest.config.tsindex f616214b..e23f2d1c 100644--- a/client/vitest.config.ts+++ b/client/vitest.config.ts@@ -38,5 +38,9 @@ export default defineConfig({esbuild: { jsx: 'automatic' },test: {include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],+ // jsdom 27 delegates Storage to Node's experimental webstorage, which is+ // undefined without --experimental-webstorage; the setup file installs a+ // memory Storage only where the native one is missing. See the file.+ setupFiles: ['./vitest.setup-storage.ts'],},})diff --git a/client/vitest.setup-storage.ts b/client/vitest.setup-storage.tsnew file mode 100644index 00000000..db2a96ff--- /dev/null+++ b/client/vitest.setup-storage.ts@@ -0,0 +1,60 @@+// jsdom 27 does not implement Storage itself: it delegates window.localStorage+// and window.sessionStorage to Node's internal webstorage implementation.+// That returns `undefined` unless Node runs with --experimental-webstorage+// (and a --localstorage-file backing), so on Node versions where the flag has+// no effect for jsdom, every component test that touches localStorage dies+// with "Cannot read properties of undefined (reading 'setItem')".+//+// Install a minimal spec-shaped Storage whenever the native one is missing.+// When the native one exists we leave it completely alone, so CI on Node 20/22+// exercises exactly what it always has.+class MemoryStorage implements Storage {+ private map = new Map<string, string>()++ get length(): number {+ return this.map.size+ }++ key(index: number): string | null {+ const keys = [...this.map.keys()]+ return index >= 0 && index < keys.length ? keys[index] : null+ }++ getItem(key: string): string | null {+ return this.map.has(key) ? this.map.get(key)! : null+ }++ setItem(key: string, value: string): void {+ this.map.set(key, String(value))+ }++ removeItem(key: string): void {+ this.map.delete(key)+ }++ clear(): void {+ this.map.clear()+ }+}++function nativeStorageAvailable(name: 'localStorage' | 'sessionStorage'): boolean {+ try {+ return typeof window[name] !== 'undefined' && window[name] !== null+ } catch {+ // jsdom throws SecurityError on opaque origins — treat as missing.+ return false+ }+}++// Plain node-environment files have no window at all — nothing to patch there.+if (typeof window !== 'undefined') {+ for (const name of ['localStorage', 'sessionStorage'] as const) {+ if (!nativeStorageAvailable(name)) {+ Object.defineProperty(window, name, {+ configurable: true,+ enumerable: true,+ value: new MemoryStorage(),+ })+ }+ }+}