Files
Gandalf the Greybeard 9da27f4186 feat: scaffold starter template with TypeScript, CRD list view, CI, ArtifactHub
Adds full plugin starter template including:
- package.json with @kinvolk/headlamp-plugin devDependency and standard scripts
- tsconfig.json extending headlamp plugin config
- vitest.config.mts + vitest.setup.ts (jsdom, NODE_ENV=test, localStorage shim)
- src/index.tsx: registers sidebar entry and route for ResourceListPage
- src/components/ResourceListPage.tsx: placeholder CRD list view with TODO guide
- src/components/ResourceListPage.test.tsx: example tests using vi.mock pattern
- .github/workflows/ci.yaml: delegates to shared plugin-ci.yaml
- .github/workflows/release.yaml: delegates to shared plugin-release.yaml
- artifacthub-pkg.yml + artifacthub-repo.yml: ArtifactHub metadata with TODO markers
- renovate.json: Mend Renovate config for weekly dependency updates
- README.md: complete getting-started guide
- CONTRIBUTING.md: local dev, code style, testing, PR process
- LICENSE: Apache-2.0

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-21 03:45:12 +00:00

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,
});
}
}