aboutsummaryrefslogtreecommitdiff
path: root/dev/smoke.js
blob: b73625b7b15ecf4c00c26f0d27cfac0267cadbb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Smoke test: load the app, create a document, exercise tools, report errors + screenshot.
const { launch, sleep } = require('./cdp.js');
const out = process.argv[2] || '/tmp/atelier-smoke.png';
(async () => {
  const b = await launch();
  try {
    const page = await b.newPage('http://localhost:8080/');
    await sleep(800);
    await page.eval(`atelier.newDocument({width: 800, height: 600}); 1`);
    await sleep(300);
    // brush stroke
    await page.eval(`atelier.setTool('brush'); 1`);
    await page.drag([[500, 300], [550, 330], [600, 360], [700, 400]]);
    await sleep(300);
    await page.screenshot(out);
    console.log(JSON.stringify(await page.eval(`({layers: atelier.doc.layers.length, hist: atelier.doc.history.entries.map(e=>e.label)})`)));
    console.log(page.logs.join('\n') || 'no console output');
  } finally {
    await b.close();
  }
})().catch((e) => { console.error(e); process.exit(1); });