const { test, expect } = require('@playwright/test'); const { openController, openDisplay, resetGame, addPoints } = require('./helpers.cjs'); test.describe('Visual Regression', () => { test('Display: screenshot a 0-0', async ({ context }) => { const controllerPage = await openController(context); const displayPage = await openDisplay(context); await resetGame(controllerPage); // Attende che il display riceva lo stato await displayPage.waitForTimeout(500); await expect(displayPage).toHaveScreenshot('display-0-0.png', { maxDiffPixelRatio: 0.05, animations: 'disabled', mask: [displayPage.locator('.connection-status')], }); }); test('Display: screenshot durante partita (15-12)', async ({ context }) => { const controllerPage = await openController(context); const displayPage = await openDisplay(context); await resetGame(controllerPage); // Porta il punteggio a 15-12 await addPoints(controllerPage, 'home', 15); await addPoints(controllerPage, 'guest', 12); await displayPage.waitForTimeout(500); await expect(displayPage).toHaveScreenshot('display-15-12.png', { maxDiffPixelRatio: 0.05, animations: 'disabled', mask: [displayPage.locator('.connection-status')], }); }); test('Controller: screenshot stato iniziale', async ({ context }) => { const controllerPage = await openController(context); await resetGame(controllerPage); await expect(controllerPage).toHaveScreenshot('controller-initial.png', { maxDiffPixelRatio: 0.05, }); }); test('Controller: screenshot con modal config aperta', async ({ context }) => { const controllerPage = await openController(context); await resetGame(controllerPage); // Apri config await controllerPage.getByText('Config').click(); await controllerPage.waitForSelector('.dialog-config'); await controllerPage.waitForTimeout(300); await expect(controllerPage).toHaveScreenshot('controller-config-modal.png', { maxDiffPixelRatio: 0.05, }); }); });