fix: Corriger les tests E2E après l'introduction du cache-aside paginé
Some checks failed
CI / Backend Tests (push) Has been cancelled
CI / Frontend Tests (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
CI / Naming Conventions (push) Has been cancelled
CI / Build Check (push) Has been cancelled

Le commit 23dd717 a introduit un cache Redis (paginated_queries.cache)
pour les requêtes paginées. Les tests E2E qui modifient les données via
SQL direct (beforeAll, cleanup) contournent la couche applicative et ne
déclenchent pas l'invalidation du cache, provoquant des données obsolètes.

De plus, plusieurs problèmes d'isolation entre tests ont été découverts :
- Les tests classes.spec.ts supprimaient les données d'autres specs via
  DELETE FROM school_classes sans nettoyer les FK dépendantes
- Les tests user-blocking utilisaient des emails partagés entre les
  projets Playwright (chromium/firefox/webkit) exécutés en parallèle,
  causant des race conditions sur l'état du compte utilisateur
- Le handler NotifyTeachersPedagogicalDayHandler s'exécutait de manière
  synchrone, bloquant la réponse HTTP pendant l'envoi des emails
- La sélection d'un enseignant remplaçant effaçait l'autre dropdown car
  {#if} supprimait l'option sélectionnée du DOM

Corrections appliquées :
- Ajout de cache:pool:clear après chaque modification SQL directe
- Nettoyage des FK dépendantes avant les DELETE (classes, subjects)
- Emails uniques par projet navigateur pour éviter les race conditions
- Routage de JourneePedagogiqueAjoutee vers le transport async
- Remplacement de {#if} par disabled sur les selects de remplacement
- Recherche par nom sur la page classes pour gérer la pagination
- Patterns toPass() pour la fiabilité Firefox sur les color pickers
This commit is contained in:
2026-03-01 23:33:42 +01:00
parent 23dd7177f2
commit 1db8a7a0b2
13 changed files with 353 additions and 99 deletions

View File

@@ -47,6 +47,15 @@ test.describe('Branding Visual Customization', () => {
`docker compose -f "${composeFile}" exec -T php sh -c "rm -rf /app/public/uploads/logos/${TENANT_ID}" 2>&1`,
{ encoding: 'utf-8' }
);
try {
execSync(
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear paginated_queries.cache 2>&1`,
{ encoding: 'utf-8' }
);
} catch {
// Cache pool may not exist in all environments
}
});
// Helper to login as admin
@@ -142,27 +151,36 @@ test.describe('Branding Visual Customization', () => {
await page.goto(`${ALPHA_URL}/admin/branding`);
await waitForPageLoaded(page);
const colorInput = page.locator('#primaryColor');
// Use color picker input for reliable cross-browser reactive updates
// Wrap in toPass() to handle Firefox timing where fill() may not immediately trigger change event
const colorPicker = page.locator('#primaryColorPicker');
// --- Dark blue: passes AA (ratio ~10.3) → "Lisible" ---
await colorInput.fill('#1E3A5F');
await expect(async () => {
await colorPicker.fill('#1e3a5f');
await expect(page.locator('.contrast-badge')).toContainText('Lisible', { timeout: 2000 });
}).toPass({ timeout: 10000 });
await expect(page.locator('.contrast-indicator.pass')).toBeVisible();
await expect(page.locator('.contrast-badge')).toContainText('Lisible');
await expect(page.locator('.preview-swatch').first()).toBeVisible();
await expect(page.locator('.preview-swatch').first()).toHaveCSS(
'background-color',
'rgb(30, 58, 95)'
'rgb(30, 58, 95)',
{ timeout: 5000 }
);
// --- Yellow: fails AA completely (ratio ~1.07) → "Illisible" ---
await colorInput.fill('#FFFF00');
await expect(async () => {
await colorPicker.fill('#ffff00');
await expect(page.locator('.contrast-badge')).toContainText('Illisible', { timeout: 2000 });
}).toPass({ timeout: 10000 });
await expect(page.locator('.contrast-indicator.fail')).toBeVisible();
await expect(page.locator('.contrast-badge')).toContainText('Illisible');
// --- Dark yellow: passes AA Large only (ratio ~3.7) → "Attention" ---
await colorInput.fill('#8B8000');
await expect(async () => {
await colorPicker.fill('#8b8000');
await expect(page.locator('.contrast-badge')).toContainText('Attention', { timeout: 2000 });
}).toPass({ timeout: 10000 });
await expect(page.locator('.contrast-indicator.warning')).toBeVisible();
await expect(page.locator('.contrast-badge')).toContainText('Attention');
});
// ============================================================================
@@ -173,8 +191,12 @@ test.describe('Branding Visual Customization', () => {
await page.goto(`${ALPHA_URL}/admin/branding`);
await waitForPageLoaded(page);
// Set a dark blue color
await page.locator('#primaryColor').fill('#1E3A5F');
// Set a dark blue color via color picker (more reliable than text input across browsers)
// Wrap in toPass() to handle Firefox timing where fill() may not immediately trigger change event
await expect(async () => {
await page.locator('#primaryColorPicker').fill('#1e3a5f');
await expect(page.getByRole('button', { name: /enregistrer/i })).toBeEnabled({ timeout: 2000 });
}).toPass({ timeout: 10000 });
// Click save and wait for API response
const responsePromise = page.waitForResponse(