dd-timer/tests/e2e/gauge-recharge.spec.ts
POL Mickaël 3e485fd09b chore: normalise fins de ligne CRLF → LF dans tout le repo
Applique .gitattributes sur tous les fichiers existants.
Élimine les différences fantômes entre WSL et Windows.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 08:55:10 +02:00

76 lines
2.7 KiB
TypeScript
Executable File

/**
* 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);
});
});