Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiECd9RWGMKV7n3K1mdy8T
35 lines
2.3 KiB
JavaScript
35 lines
2.3 KiB
JavaScript
// Il risveglio sulla panchina nel browser vero: Nuova partita, l'introduzione, gli occhi che si aprono annebbiati.
|
|
// npm run browser:risveglio — schermate in /tmp/regolo-risveglio.
|
|
import { chromium } from 'playwright';
|
|
import { mkdirSync } from 'node:fs';
|
|
import assert from 'node:assert/strict';
|
|
import { staticServer } from './helpers.mjs';
|
|
|
|
const out = process.env.OUT ?? '/tmp/regolo-risveglio';
|
|
mkdirSync(out, { recursive: true });
|
|
const server = await staticServer();
|
|
let browser;
|
|
const errors = [];
|
|
try {
|
|
browser = await chromium.launch({ args: ['--autoplay-policy=no-user-gesture-required', '--use-gl=angle', '--use-angle=swiftshader', '--enable-unsafe-swiftshader'] });
|
|
// Sul computer la versione con la sfocatura vera, sul telefono (touch) quella leggera senza filtri.
|
|
for (const mobile of [false, true]) {
|
|
const page = await browser.newPage(mobile ? { viewport: { width: 844, height: 390 }, hasTouch: true, isMobile: true } : { viewport: { width: 1280, height: 860 } });
|
|
const tag = mobile ? 'telefono' : 'computer';
|
|
page.on('pageerror', e => { errors.push(e.message); console.log('ERR', e.message); });
|
|
await page.goto(`http://127.0.0.1:${server.port}/`);
|
|
await page.click('#splash'); await page.click('#new-game'); await page.click('#rione [data-rione="campomigliaio"]'); await page.click('#skip-intro');
|
|
await page.waitForFunction(() => game.closeup?.id === 'risveglio', null, { timeout: 10000 });
|
|
await page.waitForFunction(() => document.getElementById('closeup-close').textContent === 'Salta', null, { timeout: 5000 });
|
|
// Le battute si saltano solo per far correre il tempo fino ai momenti da fotografare.
|
|
for (const [t, name] of [[0.5, '0-buio'], [2.1, '1-primo-tentativo'], [3.8, '2-secondo'], [5.6, '3-quasi'], [7.2, '4-aperti']]) {
|
|
await page.waitForFunction(at => { if (game.speech && game.closeup) game.skip(); return !game.closeup || game.closeup.t >= at; }, t, { timeout: 30000, polling: 50 });
|
|
await page.screenshot({ path: `${out}/${tag}-${name}.png` });
|
|
}
|
|
await page.waitForFunction(() => !game.closeup && game.state.flags.intro, null, { timeout: 15000 });
|
|
await page.screenshot({ path: `${out}/${tag}-5-vecchietti.png` });
|
|
}
|
|
assert.deepEqual(errors, []);
|
|
console.log(`ok: schermate in ${out}`);
|
|
} finally { await browser?.close(); server.kill(); }
|