2026-06-21 18:03:33 +02:00
|
|
|
|
const { test, expect } = require('@playwright/test');
|
|
|
|
|
|
const { openController, resetGame, addPoints } = require('./helpers.cjs');
|
|
|
|
|
|
|
|
|
|
|
|
test.describe('Referto di fine partita', () => {
|
|
|
|
|
|
|
|
|
|
|
|
test('a PARTITA FINITA il bottone REFERTO apre il referto stampabile', async ({ context }) => {
|
|
|
|
|
|
// window.print() bloccherebbe il test: lo neutralizziamo (anche nel popup).
|
|
|
|
|
|
await context.addInitScript(() => { window.print = () => {}; });
|
|
|
|
|
|
|
|
|
|
|
|
const controllerPage = await openController(context);
|
|
|
|
|
|
await resetGame(controllerPage);
|
|
|
|
|
|
|
|
|
|
|
|
// Modalità 2/3 (bastano 2 set per chiudere la partita)
|
|
|
|
|
|
await controllerPage.getByText('Config').click();
|
|
|
|
|
|
await controllerPage.waitForSelector('.dialog-config');
|
|
|
|
|
|
await controllerPage.locator('.btn-mode').getByText('2/3').click();
|
|
|
|
|
|
await controllerPage.locator('.dialog-config .btn-confirm').click();
|
|
|
|
|
|
await controllerPage.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
|
|
// SET 1: Home a 25 → dialog SET VINTO → vai al set successivo
|
|
|
|
|
|
await addPoints(controllerPage, 'home', 25);
|
|
|
|
|
|
await controllerPage.waitForSelector('.dialog-winner');
|
|
|
|
|
|
await controllerPage.getByText('VAI AL SET SUCCESSIVO').click();
|
|
|
|
|
|
await controllerPage.locator('.dialog-config .btn-cancel').click();
|
|
|
|
|
|
await controllerPage.waitForTimeout(200);
|
|
|
|
|
|
|
|
|
|
|
|
// SET 2: Home a 25 → PARTITA FINITA
|
|
|
|
|
|
await addPoints(controllerPage, 'home', 25);
|
|
|
|
|
|
await controllerPage.waitForSelector('.dialog-winner');
|
|
|
|
|
|
|
|
|
|
|
|
const referto = controllerPage.getByRole('button', { name: 'REFERTO' });
|
|
|
|
|
|
await expect(referto).toBeVisible();
|
|
|
|
|
|
|
|
|
|
|
|
// Il click apre il referto in un nuovo popup
|
|
|
|
|
|
const [popup] = await Promise.all([
|
|
|
|
|
|
context.waitForEvent('page'),
|
|
|
|
|
|
referto.click(),
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
// Verifica il contenuto del referto
|
|
|
|
|
|
const body = popup.locator('body');
|
|
|
|
|
|
await expect(body).toContainText('Referto di Gara');
|
2026-07-03 11:31:55 +02:00
|
|
|
|
await expect(popup.locator('.set-numero')).toHaveText(['1', '2']);
|
2026-06-21 18:03:33 +02:00
|
|
|
|
// Home ha vinto 2 set a 0
|
|
|
|
|
|
await expect(body).toContainText('2 – 0');
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|