test(e2e): visual-regression deterministica e baseline rigenerate
- screenshot stabili: animations disabilitate e mask su .connection-status - migrata agli helper condivisi - baseline rigenerate per Chromium, Firefox e Mobile Chrome
@@ -1,32 +1,12 @@
|
|||||||
const { test, expect } = require('@playwright/test');
|
const { test, expect } = require('@playwright/test');
|
||||||
|
const { openController, openDisplay, resetGame, addPoints } = require('./helpers.cjs');
|
||||||
// Helper: reset dal controller
|
|
||||||
async function resetGame(controllerPage) {
|
|
||||||
await controllerPage.getByText(/Reset/i).first().click();
|
|
||||||
const btnConfirm = controllerPage.locator('.dialog .btn-confirm');
|
|
||||||
if (await btnConfirm.isVisible()) {
|
|
||||||
await btnConfirm.click();
|
|
||||||
}
|
|
||||||
// doReset apre automaticamente il dialog di configurazione: chiudilo
|
|
||||||
const cfgCancel = controllerPage.locator('.dialog-config .btn-cancel');
|
|
||||||
if (await cfgCancel.isVisible()) {
|
|
||||||
await cfgCancel.click();
|
|
||||||
}
|
|
||||||
await controllerPage.waitForTimeout(300);
|
|
||||||
}
|
|
||||||
|
|
||||||
test.describe('Visual Regression', () => {
|
test.describe('Visual Regression', () => {
|
||||||
|
|
||||||
test('Display: screenshot a 0-0', async ({ context }) => {
|
test('Display: screenshot a 0-0', async ({ context }) => {
|
||||||
const controllerPage = await context.newPage();
|
const controllerPage = await openController(context);
|
||||||
const displayPage = await context.newPage();
|
const displayPage = await openDisplay(context);
|
||||||
|
|
||||||
await controllerPage.setViewportSize({ width: 390, height: 844 });
|
|
||||||
await controllerPage.goto('http://localhost:3000/controller');
|
|
||||||
await displayPage.goto('http://localhost:3000');
|
|
||||||
await controllerPage.waitForSelector('.conn-bar.connected');
|
|
||||||
|
|
||||||
// Reset per stato pulito
|
|
||||||
await resetGame(controllerPage);
|
await resetGame(controllerPage);
|
||||||
|
|
||||||
// Attende che il display riceva lo stato
|
// Attende che il display riceva lo stato
|
||||||
@@ -34,42 +14,31 @@ test.describe('Visual Regression', () => {
|
|||||||
|
|
||||||
await expect(displayPage).toHaveScreenshot('display-0-0.png', {
|
await expect(displayPage).toHaveScreenshot('display-0-0.png', {
|
||||||
maxDiffPixelRatio: 0.05,
|
maxDiffPixelRatio: 0.05,
|
||||||
|
animations: 'disabled',
|
||||||
|
mask: [displayPage.locator('.connection-status')],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Display: screenshot durante partita (15-12)', async ({ context }) => {
|
test('Display: screenshot durante partita (15-12)', async ({ context }) => {
|
||||||
const controllerPage = await context.newPage();
|
const controllerPage = await openController(context);
|
||||||
const displayPage = await context.newPage();
|
const displayPage = await openDisplay(context);
|
||||||
|
|
||||||
await controllerPage.setViewportSize({ width: 390, height: 844 });
|
|
||||||
await controllerPage.goto('http://localhost:3000/controller');
|
|
||||||
await displayPage.goto('http://localhost:3000');
|
|
||||||
await controllerPage.waitForSelector('.conn-bar.connected');
|
|
||||||
|
|
||||||
await resetGame(controllerPage);
|
await resetGame(controllerPage);
|
||||||
|
|
||||||
// Porta il punteggio a 15-12
|
// Porta il punteggio a 15-12
|
||||||
for (let i = 0; i < 15; i++) {
|
await addPoints(controllerPage, 'home', 15);
|
||||||
await controllerPage.locator('.team-score.home-bg').click();
|
await addPoints(controllerPage, 'guest', 12);
|
||||||
await controllerPage.waitForTimeout(20);
|
|
||||||
}
|
|
||||||
for (let i = 0; i < 12; i++) {
|
|
||||||
await controllerPage.locator('.team-score.guest-bg').click();
|
|
||||||
await controllerPage.waitForTimeout(20);
|
|
||||||
}
|
|
||||||
await displayPage.waitForTimeout(500);
|
await displayPage.waitForTimeout(500);
|
||||||
|
|
||||||
await expect(displayPage).toHaveScreenshot('display-15-12.png', {
|
await expect(displayPage).toHaveScreenshot('display-15-12.png', {
|
||||||
maxDiffPixelRatio: 0.05,
|
maxDiffPixelRatio: 0.05,
|
||||||
|
animations: 'disabled',
|
||||||
|
mask: [displayPage.locator('.connection-status')],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Controller: screenshot stato iniziale', async ({ context }) => {
|
test('Controller: screenshot stato iniziale', async ({ context }) => {
|
||||||
const controllerPage = await context.newPage();
|
const controllerPage = await openController(context);
|
||||||
await controllerPage.setViewportSize({ width: 390, height: 844 });
|
|
||||||
await controllerPage.goto('http://localhost:3000/controller');
|
|
||||||
await controllerPage.waitForSelector('.conn-bar.connected');
|
|
||||||
|
|
||||||
await resetGame(controllerPage);
|
await resetGame(controllerPage);
|
||||||
|
|
||||||
await expect(controllerPage).toHaveScreenshot('controller-initial.png', {
|
await expect(controllerPage).toHaveScreenshot('controller-initial.png', {
|
||||||
@@ -78,10 +47,8 @@ test.describe('Visual Regression', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Controller: screenshot con modal config aperta', async ({ context }) => {
|
test('Controller: screenshot con modal config aperta', async ({ context }) => {
|
||||||
const controllerPage = await context.newPage();
|
const controllerPage = await openController(context);
|
||||||
await controllerPage.setViewportSize({ width: 390, height: 844 });
|
await resetGame(controllerPage);
|
||||||
await controllerPage.goto('http://localhost:3000/controller');
|
|
||||||
await controllerPage.waitForSelector('.conn-bar.connected');
|
|
||||||
|
|
||||||
// Apri config
|
// Apri config
|
||||||
await controllerPage.getByText('Config').click();
|
await controllerPage.getByText('Config').click();
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 58 KiB |