186f9ef380
Fix getNamespaces() to skip cluster-scoped resources (Namespace: "") that caused Router.createRouteURL to throw TypeError on the Namespaces page. Add Playwright E2E smoke tests with Authentik OIDC auth for CI and K8s token fallback for local dev. Add Gitea Actions E2E workflow, vitest unit test infrastructure, and test-utils fixtures. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import '@testing-library/jest-dom';
|
|
|
|
// Node 22+ ships a minimal built-in `localStorage` global (property-bag only,
|
|
// no getItem/setItem/removeItem/clear) that shadows jsdom's Web Storage
|
|
// implementation. Provide a spec-compliant shim so code under test works.
|
|
if (typeof localStorage !== 'undefined' && typeof localStorage.getItem !== 'function') {
|
|
const store = new Map<string, string>();
|
|
|
|
const storage = {
|
|
getItem(key: string): string | null {
|
|
return store.get(key) ?? null;
|
|
},
|
|
setItem(key: string, value: string): void {
|
|
store.set(key, String(value));
|
|
},
|
|
removeItem(key: string): void {
|
|
store.delete(key);
|
|
},
|
|
clear(): void {
|
|
store.clear();
|
|
},
|
|
get length(): number {
|
|
return store.size;
|
|
},
|
|
key(index: number): string | null {
|
|
return [...store.keys()][index] ?? null;
|
|
},
|
|
};
|
|
|
|
Object.defineProperty(globalThis, 'localStorage', {
|
|
value: storage,
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
|
|
if (typeof window !== 'undefined') {
|
|
Object.defineProperty(window, 'localStorage', {
|
|
value: storage,
|
|
writable: true,
|
|
configurable: true,
|
|
});
|
|
}
|
|
}
|