test: 302 tests unitaires + 20 E2E Playwright (couverture 94%)
- Unit : domain (GaugeCalculator, Enclos, Dragodinde, XpTable, Race, Tier...) - Unit : application (commands, queries, CommandBus) - Fonctionnel : breeding-workflow, enclos-management, timer-workflow - Régression : gauge-tier, gauge-recharge, xp-timer, level-target, breeding - E2E Playwright + Electron : navigation, timer, recharge jauge, accouplement, persistance des données Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
106
tests/e2e/breeding.spec.ts
Normal file
106
tests/e2e/breeding.spec.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Tests E2E — Workflow d'accouplement
|
||||
*
|
||||
* Navigue vers la vue Accouplement, selectionne deux parents,
|
||||
* verifie la deduction du bebe, et enregistre l'accouplement.
|
||||
*/
|
||||
import { test, expect } from './electron-app';
|
||||
|
||||
test.describe('Workflow d\'accouplement', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Naviguer vers Accouplement via la sidebar
|
||||
await page.click('.sb-item[data-view="accouplement"]');
|
||||
await expect(page.locator('.accoup-view')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('Selectionner Parent 1 en cliquant sur une race', async ({ page }) => {
|
||||
// Cliquer sur la premiere race disponible dans la grille
|
||||
const firstRaceCard = page.locator('.accoup-race-card').first();
|
||||
const raceName = await firstRaceCard.locator('.accoup-race-card-name').textContent();
|
||||
|
||||
await firstRaceCard.click();
|
||||
|
||||
// Verifier que Parent 1 affiche la race selectionnee
|
||||
const selectedParent = page.locator('.accoup-selected-parent-name').first();
|
||||
await expect(selectedParent).toHaveText(raceName!.trim(), { timeout: 3000 });
|
||||
});
|
||||
|
||||
test('Selectionner les deux parents et voir le resultat', async ({ page }) => {
|
||||
// Selectionner "Rousse" comme Parent 1
|
||||
const rousseCard = page.locator('.accoup-race-card[data-race="Rousse"]');
|
||||
await rousseCard.click();
|
||||
await expect(page.locator('.accoup-selected-parent-name').first()).toHaveText('Rousse', { timeout: 3000 });
|
||||
|
||||
// Apres P1 selectionne, la grille filtre les partenaires compatibles
|
||||
// Selectionner le premier partenaire disponible comme Parent 2
|
||||
const partnerCard = page.locator('.accoup-race-card').first();
|
||||
await partnerCard.click();
|
||||
|
||||
// Verifier qu'un resultat (bebe) est affiche
|
||||
// Le resultat apparait dans la zone centrale avec le texte "Resultat"
|
||||
await page.waitForTimeout(500);
|
||||
const parentNames = page.locator('.accoup-selected-parent-name');
|
||||
await expect(parentNames).toHaveCount(2, { timeout: 3000 });
|
||||
});
|
||||
|
||||
test('Definir nombre de couples et bebes puis enregistrer', async ({ page }) => {
|
||||
// Selectionner P1 : Rousse
|
||||
await page.click('.accoup-race-card[data-race="Rousse"]');
|
||||
await expect(page.locator('.accoup-selected-parent-name').first()).toHaveText('Rousse', { timeout: 3000 });
|
||||
|
||||
// Selectionner P2 : premier partenaire compatible
|
||||
const partnerCard = page.locator('.accoup-race-card').first();
|
||||
await partnerCard.click();
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Remplir le nombre de couples
|
||||
const couplesInput = page.locator('#accoup-couples');
|
||||
await couplesInput.click();
|
||||
await couplesInput.fill('3');
|
||||
|
||||
// Remplir les bebes obtenus
|
||||
const babiesInput = page.locator('#accoup-babies');
|
||||
await babiesInput.click();
|
||||
await babiesInput.fill('2');
|
||||
|
||||
// Le bouton Enregistrer devrait etre actif
|
||||
const registerBtn = page.locator('#accoup-register');
|
||||
await expect(registerBtn).toBeEnabled({ timeout: 3000 });
|
||||
|
||||
// Cliquer sur Enregistrer
|
||||
await registerBtn.click();
|
||||
|
||||
// Verifier que le toast success apparait
|
||||
await expect(page.locator('.toast-success')).toBeVisible({ timeout: 3000 });
|
||||
await expect(page.locator('.toast-msg')).toContainText('Accouplement enregistré');
|
||||
|
||||
// Apres l'enregistrement, les parents sont reinitialises
|
||||
// On devrait voir les placeholders "Cliquer ou glisser" a nouveau
|
||||
await expect(page.locator('.accoup-placeholder')).toHaveCount(2, { timeout: 3000 });
|
||||
});
|
||||
|
||||
test('Filtrer les races par generation', async ({ page }) => {
|
||||
// Cliquer sur le chip "Gen 1"
|
||||
await page.click('.accoup-gen-chip[data-gen="1"]');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// Verifier que le chip est actif
|
||||
await expect(page.locator('.accoup-gen-chip[data-gen="1"].active')).toBeVisible();
|
||||
|
||||
// Toutes les races affichees devraient etre de Gen 1
|
||||
const genBadges = page.locator('.accoup-race-card-gen');
|
||||
const count = await genBadges.count();
|
||||
for (let i = 0; i < count; i++) {
|
||||
await expect(genBadges.nth(i)).toContainText('GEN 1');
|
||||
}
|
||||
});
|
||||
|
||||
test('Rechercher une race par nom', async ({ page }) => {
|
||||
const searchInput = page.locator('#accoup-search-input');
|
||||
await searchInput.fill('Rousse');
|
||||
await page.waitForTimeout(300);
|
||||
|
||||
// La grille devrait contenir "Rousse"
|
||||
await expect(page.locator('.accoup-race-card[data-race="Rousse"]')).toBeVisible();
|
||||
});
|
||||
});
|
||||
60
tests/e2e/electron-app.ts
Normal file
60
tests/e2e/electron-app.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Helper Playwright pour lancer l'application Electron.
|
||||
*
|
||||
* Lance l'app depuis dist-electron/main.js (il faut avoir buildé avec `vite build` avant).
|
||||
* Exporte une fixture `test` qui fournit `electronApp` et `page`.
|
||||
*
|
||||
* Chaque test démarre avec un userData vierge (nettoyé automatiquement).
|
||||
*/
|
||||
import { test as base, type ElectronApplication, type Page, _electron as electron } from '@playwright/test';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
const USER_DATA_DIR = path.resolve(__dirname, '../../.e2e-userdata');
|
||||
|
||||
type ElectronFixtures = {
|
||||
electronApp: ElectronApplication;
|
||||
page: Page;
|
||||
};
|
||||
|
||||
export const test = base.extend<ElectronFixtures>({
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
electronApp: async ({}, use) => {
|
||||
// Nettoyer le userData pour partir d'un état vierge à chaque test
|
||||
if (fs.existsSync(USER_DATA_DIR)) {
|
||||
fs.rmSync(USER_DATA_DIR, { recursive: true, force: true });
|
||||
}
|
||||
fs.mkdirSync(USER_DATA_DIR, { recursive: true });
|
||||
|
||||
const mainPath = path.resolve(__dirname, '../../dist-electron/main.js');
|
||||
|
||||
const app = await electron.launch({
|
||||
args: [mainPath],
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_USER_DATA_DIR: USER_DATA_DIR,
|
||||
},
|
||||
});
|
||||
|
||||
await use(app);
|
||||
await app.close();
|
||||
},
|
||||
|
||||
page: async ({ electronApp }, use) => {
|
||||
const window = await electronApp.firstWindow();
|
||||
await window.waitForLoadState('domcontentloaded');
|
||||
await window.waitForSelector('.app-shell', { timeout: 15000 });
|
||||
|
||||
// L'app démarre sans enclos — en créer un pour les tests qui en ont besoin
|
||||
const addBtn = window.locator('#add-enclos-btn');
|
||||
if (await addBtn.isVisible({ timeout: 5000 })) {
|
||||
await addBtn.click();
|
||||
// Attendre que l'enclos apparaisse dans la sidebar
|
||||
await window.waitForSelector('.sb-item .sb-dot', { timeout: 5000 });
|
||||
}
|
||||
|
||||
await use(window);
|
||||
},
|
||||
});
|
||||
|
||||
export { expect } from '@playwright/test';
|
||||
75
tests/e2e/gauge-recharge.spec.ts
Normal file
75
tests/e2e/gauge-recharge.spec.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Tests E2E — Recharge de jauge en cours de session
|
||||
*
|
||||
* Setup: enclos avec baffeur a 100, DD ajoutee, timer demarre.
|
||||
* Recharge la jauge a 50000 et verifie les mises a jour.
|
||||
*/
|
||||
import { test, expect } from './electron-app';
|
||||
|
||||
test.describe('Recharge de jauge pendant une session', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Naviguer vers le premier enclos
|
||||
const firstEnclos = page.locator('.sb-item[data-view]').filter({
|
||||
has: page.locator('.sb-dot'),
|
||||
}).first();
|
||||
await firstEnclos.click();
|
||||
await expect(page.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Activer baffeur avec niveau bas (100)
|
||||
await page.click('.gauge-btn[data-gid="baffeur"]');
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('100');
|
||||
await gaugeInput.press('Enter');
|
||||
|
||||
// L'enclos contient deja 1 DD (creee avec l'enclos)
|
||||
await expect(page.locator('.dd-grid .dd-card')).toHaveCount(1, { timeout: 5000 });
|
||||
|
||||
// Demarrer le timer
|
||||
await page.click('.enc-start-btn');
|
||||
await expect(page.locator('.enc-btn-pause')).toBeVisible({ timeout: 3000 });
|
||||
});
|
||||
|
||||
test('Recharger la jauge met a jour "Alarme dans"', async ({ page }) => {
|
||||
// Avec une jauge a 100, elle se vide rapidement
|
||||
// Attendre un peu pour que la jauge commence a se drainer
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// Recharger la jauge a 50000
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('50000');
|
||||
await gaugeInput.press('Enter');
|
||||
|
||||
// Attendre la mise a jour du DOM
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// "Alarme dans" devrait montrer un vrai temps (pas infini)
|
||||
const alarmText = await page.locator('.enc-alarm').textContent();
|
||||
expect(alarmText).not.toBe('\u221e');
|
||||
expect(alarmText).not.toBe('--:--:--');
|
||||
});
|
||||
|
||||
test('La barre de jauge se met a jour apres la recharge', async ({ page }) => {
|
||||
// Capturer la largeur de la barre avant la recharge
|
||||
const barBefore = await page.locator('.enc-gauge-bar-fill').first().evaluate(
|
||||
(el: HTMLElement) => parseFloat(el.style.width)
|
||||
);
|
||||
|
||||
// Recharger a 80000
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('80000');
|
||||
await gaugeInput.press('Enter');
|
||||
|
||||
// Attendre la mise a jour
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// La barre devrait etre plus large maintenant
|
||||
const barAfter = await page.locator('.enc-gauge-bar-fill').first().evaluate(
|
||||
(el: HTMLElement) => parseFloat(el.style.width)
|
||||
);
|
||||
|
||||
expect(barAfter).toBeGreaterThan(barBefore);
|
||||
});
|
||||
});
|
||||
54
tests/e2e/navigation.spec.ts
Normal file
54
tests/e2e/navigation.spec.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Tests E2E — Navigation dans la sidebar
|
||||
*
|
||||
* Verifie que chaque element de la sidebar affiche la bonne vue.
|
||||
*/
|
||||
import { test, expect } from './electron-app';
|
||||
|
||||
test.describe('Navigation sidebar', () => {
|
||||
test('Cliquer sur "Tableau de bord" affiche le dashboard', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="dashboard"]');
|
||||
// Le dashboard est la vue par defaut, verifions que le contenu est affiche
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
|
||||
test('Cliquer sur "Statistiques" affiche la vue statistiques', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="statistiques"]');
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
|
||||
test('Cliquer sur un enclos affiche la vue enclos', async ({ page }) => {
|
||||
// Le premier enclos a un data-view numerique (son id)
|
||||
const firstEnclos = page.locator('.sb-item[data-view]').filter({
|
||||
has: page.locator('.sb-dot'),
|
||||
}).first();
|
||||
await firstEnclos.click();
|
||||
// La vue enclos contient le conteneur .enclos-view
|
||||
await expect(page.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('Cliquer sur "Accouplement" affiche la vue accouplement', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="accouplement"]');
|
||||
await expect(page.locator('.accoup-view')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('Cliquer sur "Reappro" affiche la vue reappro', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="appro"]');
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
|
||||
test('Cliquer sur "Inventaire" affiche la vue inventaire', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="inventaire"]');
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
|
||||
test('Cliquer sur "Workflows" affiche la vue workflows', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="workflows"]');
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
|
||||
test('Cliquer sur "Parametres" affiche la vue parametres', async ({ page }) => {
|
||||
await page.click('.sb-item[data-view="parametres"]');
|
||||
await expect(page.locator('#enclos-content')).not.toBeEmpty();
|
||||
});
|
||||
});
|
||||
107
tests/e2e/persistence.spec.ts
Normal file
107
tests/e2e/persistence.spec.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* Tests E2E — Persistance des donnees
|
||||
*
|
||||
* Verifie que les donnees (nom de DD, etc.) survivent
|
||||
* a la fermeture et reouverture de l'application.
|
||||
*/
|
||||
import { test as base, expect } from '@playwright/test';
|
||||
import { _electron as electron } from '@playwright/test';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
const MAIN_PATH = path.resolve(__dirname, '../../dist-electron/main.js');
|
||||
const USER_DATA_DIR = path.resolve(__dirname, '../../.e2e-userdata-persistence');
|
||||
|
||||
function cleanDir(dir: string) {
|
||||
try {
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
} catch {
|
||||
// Ignore EPERM on Windows — le dossier sera ecrase au prochain lancement
|
||||
}
|
||||
}
|
||||
|
||||
// Fixture speciale qui permet de relancer l'app
|
||||
const test = base.extend<{}>({});
|
||||
|
||||
test.describe('Persistance des donnees', () => {
|
||||
// Nettoyer les donnees avant le test
|
||||
test.beforeAll(() => {
|
||||
cleanDir(USER_DATA_DIR);
|
||||
});
|
||||
|
||||
test.afterAll(() => {
|
||||
cleanDir(USER_DATA_DIR);
|
||||
});
|
||||
|
||||
test('Le nom d\'une dragodinde persiste apres fermeture et reouverture', async () => {
|
||||
// --- Session 1 : creer un enclos, nommer la DD ---
|
||||
const app1 = await electron.launch({
|
||||
args: [MAIN_PATH],
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_USER_DATA_DIR: USER_DATA_DIR,
|
||||
},
|
||||
});
|
||||
|
||||
const page1 = await app1.firstWindow();
|
||||
await page1.waitForLoadState('domcontentloaded');
|
||||
await page1.waitForSelector('.app-shell', { timeout: 15000 });
|
||||
|
||||
// L'app demarre sans enclos — en creer un (il contient deja 1 DD)
|
||||
await page1.click('#add-enclos-btn');
|
||||
await page1.waitForSelector('.sb-item .sb-dot', { timeout: 5000 });
|
||||
|
||||
// Naviguer vers le premier enclos
|
||||
const firstEnclos1 = page1.locator('.sb-item[data-view]').filter({
|
||||
has: page1.locator('.sb-dot'),
|
||||
}).first();
|
||||
await firstEnclos1.click();
|
||||
await expect(page1.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// L'enclos contient deja 1 DD (creee avec l'enclos)
|
||||
await expect(page1.locator('.dd-grid .dd-card')).toHaveCount(1, { timeout: 5000 });
|
||||
|
||||
// Renommer la DD (trouver l'input de nom dans la carte DD)
|
||||
const ddNameInput = page1.locator('.dd-card .dd-name').first();
|
||||
await ddNameInput.click();
|
||||
await ddNameInput.fill('TestPersist42');
|
||||
await ddNameInput.press('Enter');
|
||||
|
||||
// Attendre que la sauvegarde soit effectuee
|
||||
await page1.waitForTimeout(1000);
|
||||
|
||||
// Fermer l'app
|
||||
await app1.close();
|
||||
|
||||
// --- Session 2 : verifier que la DD est toujours la ---
|
||||
const app2 = await electron.launch({
|
||||
args: [MAIN_PATH],
|
||||
env: {
|
||||
...process.env,
|
||||
ELECTRON_USER_DATA_DIR: USER_DATA_DIR,
|
||||
},
|
||||
});
|
||||
|
||||
const page2 = await app2.firstWindow();
|
||||
await page2.waitForLoadState('domcontentloaded');
|
||||
await page2.waitForSelector('.app-shell', { timeout: 15000 });
|
||||
|
||||
// Naviguer vers le premier enclos
|
||||
const firstEnclos2 = page2.locator('.sb-item[data-view]').filter({
|
||||
has: page2.locator('.sb-dot'),
|
||||
}).first();
|
||||
await firstEnclos2.click();
|
||||
await expect(page2.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
||||
|
||||
// Verifier que la DD est toujours presente
|
||||
await expect(page2.locator('.dd-grid .dd-card')).toHaveCount(1, { timeout: 5000 });
|
||||
|
||||
// Verifier que le nom persiste
|
||||
const ddNameInput2 = page2.locator('.dd-card .dd-name').first();
|
||||
await expect(ddNameInput2).toHaveValue('TestPersist42', { timeout: 5000 });
|
||||
|
||||
await app2.close();
|
||||
});
|
||||
});
|
||||
113
tests/e2e/timer-workflow.spec.ts
Normal file
113
tests/e2e/timer-workflow.spec.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* Tests E2E — Cycle de vie complet du timer
|
||||
*
|
||||
* Navigue vers un enclos, active une jauge, ajoute une DD,
|
||||
* demarre/pause/reprend/reset le timer.
|
||||
*/
|
||||
import { test, expect } from './electron-app';
|
||||
|
||||
test.describe('Cycle de vie du timer', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Naviguer vers le premier enclos via la sidebar
|
||||
const firstEnclos = page.locator('.sb-item[data-view]').filter({
|
||||
has: page.locator('.sb-dot'),
|
||||
}).first();
|
||||
await firstEnclos.click();
|
||||
await expect(page.locator('.enclos-view')).toBeVisible({ timeout: 5000 });
|
||||
});
|
||||
|
||||
test('Activer la jauge baffeur et definir son niveau', async ({ page }) => {
|
||||
// Cliquer sur le bouton baffeur pour l'activer
|
||||
await page.click('.gauge-btn[data-gid="baffeur"]');
|
||||
// Verifier que la jauge est active (classe .on)
|
||||
await expect(page.locator('.gauge-btn[data-gid="baffeur"].on')).toBeVisible();
|
||||
|
||||
// Definir le niveau de la jauge a 50000
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('50000');
|
||||
await gaugeInput.press('Enter');
|
||||
// Verifier que la valeur est bien 50000
|
||||
await expect(gaugeInput).toHaveValue('50000');
|
||||
});
|
||||
|
||||
test('Ajouter une dragodinde puis demarrer le timer', async ({ page }) => {
|
||||
// Activer la jauge baffeur
|
||||
await page.click('.gauge-btn[data-gid="baffeur"]');
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('50000');
|
||||
await gaugeInput.press('Enter');
|
||||
|
||||
// L'enclos contient deja 1 DD (creee avec l'enclos)
|
||||
const ddGrid = page.locator('.dd-grid');
|
||||
await expect(ddGrid.locator('.dd-card')).toHaveCount(1, { timeout: 5000 });
|
||||
|
||||
// Demarrer le timer
|
||||
const startBtn = page.locator('.enc-start-btn');
|
||||
await startBtn.click();
|
||||
|
||||
// Verifier que le bouton est passe en mode PAUSE
|
||||
await expect(page.locator('.enc-btn-pause')).toBeVisible({ timeout: 3000 });
|
||||
|
||||
// Verifier que le temps ecoule n'est plus 00:00:00 (apres un petit delai)
|
||||
await page.waitForTimeout(1500);
|
||||
const elapsedText = await page.locator('.enc-elapsed').textContent();
|
||||
expect(elapsedText).not.toBe('00:00:00');
|
||||
|
||||
// Verifier que "Alarme dans" montre un temps (pas --:--:-- ni infini)
|
||||
const alarmText = await page.locator('.enc-alarm').textContent();
|
||||
expect(alarmText).not.toBe('--:--:--');
|
||||
expect(alarmText).not.toBe('\u221e');
|
||||
});
|
||||
|
||||
test('Pause et reprise du timer', async ({ page }) => {
|
||||
// Setup: activer jauge + DD + demarrer
|
||||
await page.click('.gauge-btn[data-gid="baffeur"]');
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('50000');
|
||||
await gaugeInput.press('Enter');
|
||||
await page.click('button:has-text("Ajouter une Dragodinde")');
|
||||
await page.click('.enc-start-btn');
|
||||
await expect(page.locator('.enc-btn-pause')).toBeVisible({ timeout: 3000 });
|
||||
|
||||
// Mettre en pause
|
||||
await page.click('.enc-btn-pause');
|
||||
// Le bouton devrait afficher REPRENDRE
|
||||
await expect(page.locator('.enc-start-btn')).toContainText('REPRENDRE', { timeout: 3000 });
|
||||
|
||||
// Capturer le temps ecoule apres la pause
|
||||
const elapsedAfterPause = await page.locator('.enc-elapsed').textContent();
|
||||
|
||||
// Attendre un moment pour verifier que le temps ne bouge pas
|
||||
await page.waitForTimeout(1500);
|
||||
const elapsedStillPaused = await page.locator('.enc-elapsed').textContent();
|
||||
expect(elapsedStillPaused).toBe(elapsedAfterPause);
|
||||
|
||||
// Reprendre le timer
|
||||
await page.click('.enc-start-btn');
|
||||
await expect(page.locator('.enc-btn-pause')).toBeVisible({ timeout: 3000 });
|
||||
});
|
||||
|
||||
test('Reset du timer', async ({ page }) => {
|
||||
// Setup: activer jauge + DD + demarrer
|
||||
await page.click('.gauge-btn[data-gid="baffeur"]');
|
||||
const gaugeInput = page.locator('.gauge-inp[data-gid="baffeur"]');
|
||||
await gaugeInput.click();
|
||||
await gaugeInput.fill('50000');
|
||||
await gaugeInput.press('Enter');
|
||||
await page.click('button:has-text("Ajouter une Dragodinde")');
|
||||
await page.click('.enc-start-btn');
|
||||
await expect(page.locator('.enc-btn-pause')).toBeVisible({ timeout: 3000 });
|
||||
|
||||
// Cliquer sur le bouton reset
|
||||
await page.click('.enc-reset-btn');
|
||||
|
||||
// Verifier que le timer est revenu a 00:00:00
|
||||
await expect(page.locator('.enc-elapsed')).toHaveText('00:00:00', { timeout: 3000 });
|
||||
|
||||
// Le bouton devrait afficher DEMARRER
|
||||
await expect(page.locator('.enc-start-btn')).toContainText('MARRER', { timeout: 3000 });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user