veza/apps/web/scripts/serve-storybook-static.cjs
senke 1efafe0cc5 test(storybook): Playwright suite for full Storybook + Spotify/Discord polish
- Add playwright.config.storybook.ts: runs against storybook-static on :6007
- Add e2e/tests/storybook/storybook-all.spec.ts: one test per story (load iframe, no errors)
- Add scripts/serve-storybook-static.cjs: serves build or stub (empty index) when no build
- npm run test:storybook:playwright (after build-storybook) for full coverage
- Storybook decorator: use bg-background / design tokens for dark (#121212)
- Preview: default dark background #121212
- Button: secondary/ghost/glass aligned to Spotify/Discord (white/5, white/10 hover)
- KodoEmptyState: softer orbs, compact copy, primary CTA without heavy glow

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-07 20:30:49 +01:00

41 lines
1.3 KiB
JavaScript

#!/usr/bin/env node
/**
* Serves storybook-static on port 6007 for Playwright/audit.
* If storybook-static is missing, serves a stub so index.json returns { entries: {} }
* and tests can skip with "Run npm run build-storybook first".
*/
const http = require('http');
const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');
const PORT = 6007;
const staticDir = path.join(process.cwd(), 'storybook-static');
const indexPath = path.join(staticDir, 'index.json');
if (fs.existsSync(indexPath)) {
const proc = spawn('npx', ['serve', 'storybook-static', '-l', String(PORT)], {
stdio: 'inherit',
shell: true,
cwd: process.cwd(),
});
proc.on('error', (err) => {
console.error(err);
process.exit(1);
});
proc.on('exit', (code) => process.exit(code ?? 0));
} else {
const stubIndex = JSON.stringify({ entries: {} });
const server = http.createServer((req, res) => {
if (req.url === '/index.json' || req.url === '/') {
res.setHeader('Content-Type', 'application/json');
res.end(stubIndex);
return;
}
res.statusCode = 404;
res.end('Not found. Run npm run build-storybook first.');
});
server.listen(PORT, () => {
console.log(`Stub Storybook server at http://localhost:${PORT} (no storybook-static; run build-storybook first)`);
});
}