From 7cc3b8bb5e8ef4004a53e426642ebabbaf6cc987 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Fri, 3 Jul 2026 10:59:20 +0200 Subject: [PATCH] test(e2e): aggiungi flusso end-to-end del time out Copre il percorso completo controller -> display: apertura modal, vincolo squadra su Avvia, avvio con "nessun video" (deterministico, non dipende dal contenuto di spot/), overlay e banner con countdown, chiusura anticipata e annullamento della modal. --- tests/e2e/timeout.spec.cjs | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/e2e/timeout.spec.cjs diff --git a/tests/e2e/timeout.spec.cjs b/tests/e2e/timeout.spec.cjs new file mode 100644 index 0000000..b889112 --- /dev/null +++ b/tests/e2e/timeout.spec.cjs @@ -0,0 +1,56 @@ +const { test, expect } = require('@playwright/test'); +const { openController, openDisplay, resetGame } = require('./helpers.cjs'); + +// Il flusso usa sempre l'opzione "Nessun video": non dipende dal contenuto +// della cartella spot/ e resta deterministico su qualsiasi macchina. +test.describe('Time Out', () => { + + test('flusso completo: avvio, overlay sul display, chiusura anticipata', async ({ context }) => { + const displayPage = await openDisplay(context); + const controllerPage = await openController(context); + await resetGame(controllerPage); + + // Apri la modal time out + await controllerPage.locator('.btn-timeout').click(); + await expect(controllerPage.locator('.dialog-timeout')).toBeVisible(); + + // Avvia è disabilitato finché non si sceglie la squadra + const avvia = controllerPage.locator('.dialog-timeout .btn-confirm'); + await expect(avvia).toBeDisabled(); + + // Scegli squadra Home e nessun video + await controllerPage.locator('.dialog-timeout .btn-set.home-bg').click(); + await controllerPage.locator('.timeout-video-option').last().locator('input').check(); + await expect(avvia).toBeEnabled(); + await avvia.click(); + + // Display: overlay a tutto schermo con countdown e squadra + await expect(displayPage.locator('.timeout-overlay')).toBeVisible(); + await expect(displayPage.locator('.timeout-placeholder')).toContainText('TIME OUT'); + await expect(displayPage.locator('.timeout-placeholder')).toContainText('Antoniana'); + await expect(displayPage.locator('.timeout-countdown')).toBeVisible(); + + // Controller: banner attivo con nome squadra + await expect(controllerPage.locator('.timeout-banner')).toContainText('TIME OUT'); + await expect(controllerPage.locator('.timeout-banner')).toContainText('Antoniana'); + + // Chiusura anticipata: il bottone (che mostra il countdown) invia stopTimeout + await controllerPage.locator('.btn-timeout').click(); + await expect(displayPage.locator('.timeout-overlay')).not.toBeVisible(); + await expect(controllerPage.locator('.timeout-banner')).not.toBeVisible(); + }); + + test('Annulla chiude la modal senza avviare il time out', async ({ context }) => { + const displayPage = await openDisplay(context); + const controllerPage = await openController(context); + await resetGame(controllerPage); + + await controllerPage.locator('.btn-timeout').click(); + await expect(controllerPage.locator('.dialog-timeout')).toBeVisible(); + + await controllerPage.locator('.dialog-timeout .btn-cancel').click(); + await expect(controllerPage.locator('.dialog-timeout')).not.toBeVisible(); + await expect(controllerPage.locator('.timeout-banner')).not.toBeVisible(); + await expect(displayPage.locator('.timeout-overlay')).not.toBeVisible(); + }); +});