You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.4 KiB
45 lines
1.4 KiB
/**
|
|
* Probe Toggle page across themes + interaction. Captures screenshots
|
|
* and console errors.
|
|
*/
|
|
import { chromium } from 'playwright';
|
|
import { mkdir } from 'node:fs/promises';
|
|
|
|
const BASE = process.env.BASE_URL ?? 'http://localhost:5177';
|
|
const OUT = 'g:/tmp/demos';
|
|
|
|
async function main() {
|
|
await mkdir(OUT, { recursive: true });
|
|
const b = await chromium.launch();
|
|
const ctx = await b.newContext({ viewport: { width: 1280, height: 900 } });
|
|
const p = await ctx.newPage();
|
|
const errs: string[] = [];
|
|
p.on('console', (m) => {
|
|
if (m.type() === 'error') errs.push(m.text());
|
|
});
|
|
p.on('pageerror', (e) => errs.push('pe: ' + e.message));
|
|
|
|
await p.goto(BASE + '/toggle', { waitUntil: 'networkidle' });
|
|
await p.waitForTimeout(500);
|
|
await p.screenshot({ path: OUT + '/toggle-light.png', fullPage: true });
|
|
|
|
await p.locator('[data-toggle]').first().click();
|
|
await p.waitForTimeout(150);
|
|
await p.screenshot({ path: OUT + '/toggle-press.png', fullPage: true });
|
|
await p.waitForTimeout(500);
|
|
|
|
// Switch to dark theme via the topbar
|
|
await p.locator('button[aria-label="Toggle theme"]').first().click();
|
|
await p.waitForTimeout(300);
|
|
await p.screenshot({ path: OUT + '/toggle-dark.png', fullPage: true });
|
|
|
|
console.log('errors:', errs.length);
|
|
for (const e of errs) console.log(' ' + e.slice(0, 200));
|
|
await b.close();
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|