chore: add utility scripts and additional test coverage
STORY: Development requires supporting scripts and comprehensive test coverage. This commit adds utility scripts and extends test suites. COLLABORATION: - scripts/capture-sessions.mjs: Screenshot capture for sessions hub - scripts/capture-timeline.mjs: Timeline view capture utility - sessions-header-logic.ts: Session header business logic - Additional test files for sessions, hooks, and snapshot diffing
This commit is contained in:
parent
812b6cf8c5
commit
173937c1f3
7 changed files with 729 additions and 0 deletions
39
scripts/capture-sessions.mjs
Normal file
39
scripts/capture-sessions.mjs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import { chromium } from 'playwright';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
|
||||
const url = process.argv[2];
|
||||
const mode = process.argv[3];
|
||||
|
||||
if (!url || !mode) {
|
||||
console.error('Usage: node scripts/capture-sessions.mjs <url> <normal|stuck|dead>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const shots = [
|
||||
{ name: 'mobile', width: 390, height: 844 },
|
||||
{ name: 'tablet', width: 768, height: 1024 },
|
||||
{ name: 'desktop', width: 1440, height: 900 },
|
||||
];
|
||||
|
||||
// Ensure artifacts directory exists
|
||||
if (!fs.existsSync('artifacts')) {
|
||||
fs.mkdirSync('artifacts', { recursive: true });
|
||||
}
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
|
||||
for (const shot of shots) {
|
||||
const page = await browser.newPage({ viewport: { width: shot.width, height: shot.height } });
|
||||
await page.goto(url, { waitUntil: 'domcontentloaded' });
|
||||
await page.waitForTimeout(1000); // Wait for session cards to render
|
||||
await page.screenshot({
|
||||
path: path.join('artifacts', `sessions-${shot.name}-${mode}.png`),
|
||||
fullPage: true,
|
||||
});
|
||||
console.log(`Captured: artifacts/sessions-${shot.name}-${mode}.png`);
|
||||
await page.close();
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
console.log('Done!');
|
||||
24
scripts/capture-timeline.mjs
Normal file
24
scripts/capture-timeline.mjs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { chromium } from 'playwright';
|
||||
import path from 'node:path';
|
||||
|
||||
const url = process.argv[2] || 'http://localhost:3003/timeline';
|
||||
|
||||
const shots = [
|
||||
{ name: 'desktop', width: 1440, height: 900 },
|
||||
];
|
||||
|
||||
const browser = await chromium.launch({ headless: true });
|
||||
|
||||
for (const shot of shots) {
|
||||
const page = await browser.newPage({ viewport: { width: shot.width, height: shot.height } });
|
||||
await page.goto(url, { waitUntil: 'domcontentloaded' });
|
||||
await page.waitForTimeout(2000);
|
||||
await page.screenshot({
|
||||
path: path.join('artifacts', `timeline-${shot.name}.png`),
|
||||
fullPage: true,
|
||||
});
|
||||
await page.close();
|
||||
}
|
||||
|
||||
await browser.close();
|
||||
console.log('Screenshot saved to artifacts/timeline-desktop.png');
|
||||
Loading…
Add table
Add a link
Reference in a new issue