fix: Corriger les tests E2E après l'introduction du cache-aside paginé
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:
@@ -17,10 +17,19 @@ const TEACHER_EMAIL = 'e2e-calendar-teacher@example.com';
|
||||
const TEACHER_PASSWORD = 'CalendarTeacher123';
|
||||
const TENANT_ID = 'a1b2c3d4-e5f6-7890-abcd-ef1234567890';
|
||||
|
||||
// Dynamic future weekday for pedagogical day (avoids stale hardcoded dates)
|
||||
// Dynamic future weekday for pedagogical day (avoids stale hardcoded dates, French holidays, and summer vacation)
|
||||
const PED_DAY_DATE = (() => {
|
||||
const d = new Date();
|
||||
d.setMonth(d.getMonth() + 2);
|
||||
d.setDate(d.getDate() + 30); // ~1 month ahead, stays within school time (avoids summer vacation)
|
||||
while (d.getDay() === 0 || d.getDay() === 6) d.setDate(d.getDate() + 1);
|
||||
// Skip known French fixed holidays (MM-DD)
|
||||
const holidays = ['01-01', '05-01', '05-08', '07-14', '08-15', '11-01', '11-11', '12-25'];
|
||||
let mmdd = `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
if (holidays.includes(mmdd)) d.setDate(d.getDate() + 1);
|
||||
while (d.getDay() === 0 || d.getDay() === 6) d.setDate(d.getDate() + 1);
|
||||
// Double-check after weekend skip
|
||||
mmdd = `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
if (holidays.includes(mmdd)) d.setDate(d.getDate() + 1);
|
||||
while (d.getDay() === 0 || d.getDay() === 6) d.setDate(d.getDate() + 1);
|
||||
return d.toISOString().split('T')[0];
|
||||
})();
|
||||
@@ -53,6 +62,15 @@ test.describe('Calendar Management (Story 2.11)', () => {
|
||||
} catch {
|
||||
// Table might not have data yet
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
async function loginAsAdmin(page: import('@playwright/test').Page) {
|
||||
@@ -135,6 +153,14 @@ test.describe('Calendar Management (Story 2.11)', () => {
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
await loginAsAdmin(page);
|
||||
await page.goto(`${ALPHA_URL}/admin/calendar`);
|
||||
@@ -374,6 +400,28 @@ test.describe('Calendar Management (Story 2.11)', () => {
|
||||
// Pedagogical Day (AC5)
|
||||
// ============================================================================
|
||||
test.describe('Pedagogical Day', () => {
|
||||
// Clean up any existing ped day with the same date before the serial ped day tests
|
||||
test.beforeAll(async () => {
|
||||
const projectRoot = join(__dirname, '../..');
|
||||
const composeFile = join(projectRoot, 'compose.yaml');
|
||||
try {
|
||||
execSync(
|
||||
`docker compose -f "${composeFile}" exec -T php php bin/console dbal:run-sql "DELETE FROM school_calendar_entries WHERE tenant_id = '${TENANT_ID}' AND type = 'pedagogical_day' AND start_date = '${PED_DAY_DATE}'" 2>&1`,
|
||||
{ encoding: 'utf-8' }
|
||||
);
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
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
|
||||
}
|
||||
});
|
||||
|
||||
test('[P1] add pedagogical day button is visible', async ({ page }) => {
|
||||
await loginAsAdmin(page);
|
||||
await page.goto(`${ALPHA_URL}/admin/calendar`);
|
||||
@@ -459,11 +507,16 @@ test.describe('Calendar Management (Story 2.11)', () => {
|
||||
await dialog.locator('#ped-label').fill(PED_DAY_LABEL);
|
||||
await dialog.locator('#ped-description').fill('Journée de formation continue');
|
||||
|
||||
// Submit
|
||||
// Submit and wait for API response
|
||||
const responsePromise = page.waitForResponse(
|
||||
(resp) => resp.url().includes('/calendar/pedagogical-day') && resp.request().method() === 'POST'
|
||||
);
|
||||
await dialog.getByRole('button', { name: /^ajouter$/i }).click();
|
||||
const response = await responsePromise;
|
||||
expect(response.status()).toBeLessThan(400);
|
||||
|
||||
// Modal should close
|
||||
await expect(dialog).not.toBeVisible({ timeout: 10000 });
|
||||
await expect(dialog).not.toBeVisible({ timeout: 15000 });
|
||||
|
||||
// Success message
|
||||
await expect(
|
||||
|
||||
Reference in New Issue
Block a user