fix: Corriger les 84 échecs E2E pré-existants
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

Les tests E2E échouaient pour trois raisons principales :

1. Initialisation asynchrone TipTap — L'éditeur rich-text s'initialise
   via des imports dynamiques dans onMount(). Les tests interagissaient
   avec .rich-text-content avant que l'élément n'existe dans le DOM.
   Ajout d'attentes explicites avant chaque interaction avec l'éditeur.

2. Pollution inter-tests — Les fonctions de nettoyage (classes, subjects)
   ne supprimaient pas les tables dépendantes (homework, evaluations,
   schedule_slots), provoquant des erreurs FK silencieuses dans les
   try/catch. De plus, homework_submissions n'a pas de ON DELETE CASCADE
   sur homework_id, nécessitant une suppression explicite.

3. État partagé du tenant — Les règles de devoirs (homework_rules) et le
   calendrier scolaire (school_calendar_entries avec Vacances de Printemps)
   persistaient entre les fichiers de test, bloquant la création de devoirs
   dans des tests non liés aux règles.
This commit is contained in:
2026-03-26 14:47:18 +01:00
parent df25a8cbb0
commit 98be1951bf
17 changed files with 302 additions and 36 deletions

View File

@@ -26,13 +26,36 @@ test.describe('Admin Class Detail Page [P1]', () => {
const projectRoot = join(__dirname, '../..');
const composeFile = join(projectRoot, 'compose.yaml');
// Create admin user
// Clear caches to prevent stale data and rate limiter issues
try {
execSync(
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear cache.rate_limiter --env=dev 2>&1`,
{ encoding: 'utf-8' }
);
} catch {
// Cache pool may not exist
}
// Create admin user (or reuse existing)
execSync(
`docker compose -f "${composeFile}" exec -T php php bin/console app:dev:create-test-user --tenant=ecole-alpha --email=${ADMIN_EMAIL} --password=${ADMIN_PASSWORD} --role=ROLE_ADMIN 2>&1`,
{ encoding: 'utf-8' }
);
});
test.beforeEach(async () => {
const projectRoot = join(__dirname, '../..');
const composeFile = join(projectRoot, 'compose.yaml');
try {
execSync(
`docker compose -f "${composeFile}" exec -T php php bin/console cache:pool:clear cache.rate_limiter --env=dev 2>&1`,
{ encoding: 'utf-8' }
);
} catch {
// Cache pool may not exist
}
});
async function loginAsAdmin(page: import('@playwright/test').Page) {
await page.goto(`${ALPHA_URL}/login`);
await page.locator('#email').fill(ADMIN_EMAIL);
@@ -73,9 +96,17 @@ test.describe('Admin Class Detail Page [P1]', () => {
await page.getByRole('button', { name: /créer la classe/i }).click();
await expect(page.getByRole('dialog')).not.toBeVisible({ timeout: 10000 });
// Use search to find the class (pagination may push it off the first page)
const searchInput = page.locator('input[type="search"]');
if (await searchInput.isVisible()) {
await searchInput.fill(name);
await page.waitForTimeout(500);
await page.waitForLoadState('networkidle');
}
// Click modify to go to detail page
const classCard = page.locator('.class-card', { hasText: name });
await expect(classCard).toBeVisible();
await expect(classCard).toBeVisible({ timeout: 10000 });
await classCard.getByRole('button', { name: /modifier/i }).click();
// Verify we are on the edit page
@@ -135,10 +166,15 @@ test.describe('Admin Class Detail Page [P1]', () => {
// Should show success message
await expect(page.getByText(/modifiée avec succès/i)).toBeVisible({ timeout: 10000 });
// Go back to list and verify the new name appears
// Go back to list and verify the new name appears (use search for pagination)
await page.goto(`${ALPHA_URL}/admin/classes`);
await expect(page.getByText(newName)).toBeVisible();
await expect(page.getByText(originalName)).not.toBeVisible();
const searchInput = page.locator('input[type="search"]');
if (await searchInput.isVisible()) {
await searchInput.fill(newName);
await page.waitForTimeout(500);
await page.waitForLoadState('networkidle');
}
await expect(page.getByText(newName)).toBeVisible({ timeout: 10000 });
});
// ============================================================================