2026-02-12 19:33:54 +01:00
|
|
|
const { test, expect } = require('@playwright/test');
|
2026-06-21 18:03:07 +02:00
|
|
|
const { openController, resetGame, addPoints } = require('./helpers.cjs');
|
2026-02-12 19:33:54 +01:00
|
|
|
|
|
|
|
|
test.describe('Full Match Simulation', () => {
|
|
|
|
|
|
2026-06-21 18:03:07 +02:00
|
|
|
test('Partita 2/3: Home vince il primo set', async ({ context }) => {
|
|
|
|
|
const controllerPage = await openController(context);
|
2026-02-12 19:33:54 +01:00
|
|
|
|
|
|
|
|
await resetGame(controllerPage);
|
|
|
|
|
|
|
|
|
|
// Cambia modalità a 2/3
|
|
|
|
|
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 vince 25-0 ===
|
|
|
|
|
await addPoints(controllerPage, 'home', 25);
|
|
|
|
|
|
|
|
|
|
// Verifica punteggio 25
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-pts')).toHaveText('25');
|
|
|
|
|
|
2026-06-21 18:03:07 +02:00
|
|
|
// A 25-0 compare automaticamente il dialog "SET VINTO": vai al set successivo
|
|
|
|
|
await controllerPage.waitForSelector('.dialog-winner');
|
|
|
|
|
await controllerPage.getByText('VAI AL SET SUCCESSIVO').click();
|
|
|
|
|
// doNuovoSet riapre il dialog di configurazione: chiudilo
|
|
|
|
|
await controllerPage.locator('.dialog-config .btn-cancel').click();
|
|
|
|
|
await controllerPage.waitForTimeout(200);
|
2026-02-12 19:33:54 +01:00
|
|
|
|
|
|
|
|
// Verifica set 1 per Home
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-set')).toContainText('SET 1');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Set decisivo 2/3: vittoria a 15 punti', async ({ context }) => {
|
2026-06-21 18:03:07 +02:00
|
|
|
const controllerPage = await openController(context);
|
2026-02-12 19:33:54 +01:00
|
|
|
|
|
|
|
|
await resetGame(controllerPage);
|
|
|
|
|
|
|
|
|
|
// Cambia modalità a 2/3
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Imposta set 1-1 manualmente (simula set pareggiati)
|
|
|
|
|
await controllerPage.locator('.btn-set.home-bg').click();
|
|
|
|
|
await controllerPage.waitForTimeout(50);
|
|
|
|
|
await controllerPage.locator('.btn-set.guest-bg').click();
|
|
|
|
|
await controllerPage.waitForTimeout(100);
|
|
|
|
|
|
|
|
|
|
// Verifica set 1-1
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-set')).toContainText('SET 1');
|
|
|
|
|
await expect(controllerPage.locator('.team-score.guest-bg .team-set')).toContainText('SET 1');
|
|
|
|
|
|
|
|
|
|
// === SET DECISIVO: Home porta a 15 ===
|
|
|
|
|
await addPoints(controllerPage, 'home', 15);
|
|
|
|
|
|
|
|
|
|
// Verifica punteggio 15 (e il set è decisivo: dopo 15 punti il gioco è vinto)
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-pts')).toHaveText('15');
|
|
|
|
|
|
2026-06-21 18:03:07 +02:00
|
|
|
// A 15 nel set decisivo scatta la vittoria: compare il dialog (PARTITA FINITA)
|
|
|
|
|
await expect(controllerPage.locator('.dialog-winner')).toBeVisible();
|
2026-02-12 19:33:54 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('Set normale: punti oltre 25 fino ai vantaggi', async ({ context }) => {
|
2026-06-21 18:03:07 +02:00
|
|
|
const controllerPage = await openController(context);
|
2026-02-12 19:33:54 +01:00
|
|
|
|
|
|
|
|
await resetGame(controllerPage);
|
|
|
|
|
|
|
|
|
|
// Porta a 24-24
|
|
|
|
|
await addPoints(controllerPage, 'home', 24);
|
|
|
|
|
await addPoints(controllerPage, 'guest', 24);
|
|
|
|
|
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-pts')).toHaveText('24');
|
|
|
|
|
await expect(controllerPage.locator('.team-score.guest-bg .team-pts')).toHaveText('24');
|
|
|
|
|
|
|
|
|
|
// Home va a 25 (non è vittoria perché serve scarto di 2)
|
|
|
|
|
await controllerPage.locator('.team-score.home-bg').click();
|
|
|
|
|
await controllerPage.waitForTimeout(100);
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-pts')).toHaveText('25');
|
|
|
|
|
|
|
|
|
|
// Si possono ancora aggiungere punti (non è vittoria a 25-24)
|
|
|
|
|
await controllerPage.locator('.team-score.home-bg').click();
|
|
|
|
|
await controllerPage.waitForTimeout(100);
|
|
|
|
|
await expect(controllerPage.locator('.team-score.home-bg .team-pts')).toHaveText('26');
|
|
|
|
|
|
2026-06-21 18:03:07 +02:00
|
|
|
// 26-24 è vittoria → compare automaticamente il dialog SET VINTO
|
|
|
|
|
await expect(controllerPage.locator('.dialog-winner')).toBeVisible();
|
2026-02-12 19:33:54 +01:00
|
|
|
});
|
|
|
|
|
});
|