Files
segnapunti/tests/e2e/referto.spec.cjs
T
davide e6099be0cb test(e2e): spec del referto a PARTITA FINITA
Porta una partita 2/3 a conclusione, intercetta il popup aperto dal bottone
REFERTO e verifica il contenuto (titolo, set, risultato). window.print è
neutralizzato per non bloccare il test.
2026-06-21 18:03:36 +02:00

49 lines
2.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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');
await expect(body).toContainText('Set 1');
await expect(body).toContainText('Set 2');
// Home ha vinto 2 set a 0
await expect(body).toContainText('2 0');
});
});