earshelf / source /scripts /shots.mjs
WilburDev's picture
Deploy 2026-11-19T12:25Z
4a58e48 verified
Raw History Blame Contribute Delete
1.34 kB
import { chromium } from '@playwright/test';
const out = process.argv[2];
const b = await chromium.launch({ channel: 'chrome' });
for (const [name, vp, scheme] of [['desk', { width: 1280, height: 800 }, 'light'], ['phone', { width: 360, height: 740 }, 'light'], ['phone-dark', { width: 360, height: 740 }, 'dark'], ['land', { width: 667, height: 320 }, 'light']]) {
const ctx = await b.newContext({ viewport: vp, colorScheme: scheme, deviceScaleFactor: 2 });
const p = await ctx.newPage();
await p.addInitScript(() => localStorage.setItem('earshelf.noWarm', '1'));
await p.goto('http://localhost:4175/');
await p.screenshot({ path: `${out}/${name}-1-empty.png` });
await p.setInputFiles('#file', 'tests/fixtures/lighthouse.epub');
await p.waitForSelector('#player:not([hidden])');
await p.click('#play').catch(() => {});
await p.locator('.s').nth(2).click();
await p.waitForTimeout(400);
await p.screenshot({ path: `${out}/${name}-2-player.png` });
await p.click('#voice-btn');
await p.waitForTimeout(300);
await p.screenshot({ path: `${out}/${name}-3-voice.png` });
await p.keyboard.press('Escape');
await p.click('#back');
await p.click('#sample');
await p.click('#back');
await p.waitForTimeout(300);
await p.screenshot({ path: `${out}/${name}-4-shelf.png` });
await ctx.close();
}
await b.close();