From e6099be0cbaea71cf80d9ce7ab3986980cb5003c Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Sun, 21 Jun 2026 18:03:33 +0200 Subject: [PATCH] test(e2e): spec del referto a PARTITA FINITA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/e2e/referto.spec.cjs | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/e2e/referto.spec.cjs diff --git a/tests/e2e/referto.spec.cjs b/tests/e2e/referto.spec.cjs new file mode 100644 index 0000000..c4da05d --- /dev/null +++ b/tests/e2e/referto.spec.cjs @@ -0,0 +1,48 @@ +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'); + }); +});