File size: 1,344 Bytes
4a58e48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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();