fix: Corriger les 84 échecs E2E pré-existants
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:
@@ -105,8 +105,9 @@ async function createHomework(page: import('@playwright/test').Page, title: stri
|
||||
await page.locator('#hw-subject').selectOption({ index: 1 });
|
||||
await page.locator('#hw-title').fill(title);
|
||||
|
||||
// Type in WYSIWYG editor
|
||||
// Type in WYSIWYG editor (TipTap initializes asynchronously)
|
||||
const editorContent = page.locator('.modal .rich-text-content');
|
||||
await expect(editorContent).toBeVisible({ timeout: 10000 });
|
||||
await editorContent.click();
|
||||
await page.keyboard.type('Consignes du devoir');
|
||||
|
||||
@@ -188,11 +189,30 @@ test.describe('Rich Text & Attachments (Story 5.9)', () => {
|
||||
});
|
||||
|
||||
test.beforeEach(async () => {
|
||||
// homework_submissions has NO CASCADE on homework_id — delete submissions first
|
||||
try {
|
||||
runSql(`DELETE FROM submission_attachments WHERE submission_id IN (SELECT hs.id FROM homework_submissions hs JOIN homework h ON hs.homework_id = h.id WHERE h.tenant_id = '${TENANT_ID}' AND h.teacher_id IN (SELECT id FROM users WHERE email = '${TEACHER_EMAIL}' AND tenant_id = '${TENANT_ID}'))`);
|
||||
} catch { /* Table may not exist */ }
|
||||
try {
|
||||
runSql(`DELETE FROM homework_submissions WHERE homework_id IN (SELECT id FROM homework WHERE tenant_id = '${TENANT_ID}' AND teacher_id IN (SELECT id FROM users WHERE email = '${TEACHER_EMAIL}' AND tenant_id = '${TENANT_ID}'))`);
|
||||
} catch { /* Table may not exist */ }
|
||||
try {
|
||||
runSql(`DELETE FROM homework WHERE tenant_id = '${TENANT_ID}' AND teacher_id IN (SELECT id FROM users WHERE email = '${TEACHER_EMAIL}' AND tenant_id = '${TENANT_ID}')`);
|
||||
} catch {
|
||||
// Table may not exist
|
||||
}
|
||||
|
||||
// Disable any homework rules left by other test files (homework-rules-warning,
|
||||
// homework-rules-hard) to prevent rule warnings blocking homework creation.
|
||||
try {
|
||||
runSql(`UPDATE homework_rules SET enabled = false, updated_at = NOW() WHERE tenant_id = '${TENANT_ID}'`);
|
||||
} catch { /* Table may not exist */ }
|
||||
|
||||
// Clear school calendar entries that may block dates (Vacances de Printemps, etc.)
|
||||
try {
|
||||
runSql(`DELETE FROM school_calendar_entries WHERE tenant_id = '${TENANT_ID}'`);
|
||||
} catch { /* Table may not exist */ }
|
||||
|
||||
clearCache();
|
||||
});
|
||||
|
||||
@@ -231,8 +251,9 @@ test.describe('Rich Text & Attachments (Story 5.9)', () => {
|
||||
await page.locator('#hw-subject').selectOption({ index: 1 });
|
||||
await page.locator('#hw-title').fill('Devoir texte riche');
|
||||
|
||||
// Type in rich text editor
|
||||
// Type in rich text editor (TipTap initializes asynchronously)
|
||||
const editorContent = page.locator('.modal .rich-text-content');
|
||||
await expect(editorContent).toBeVisible({ timeout: 10000 });
|
||||
await editorContent.click();
|
||||
await page.keyboard.type('Consignes importantes');
|
||||
|
||||
@@ -255,6 +276,7 @@ test.describe('Rich Text & Attachments (Story 5.9)', () => {
|
||||
await page.locator('#hw-title').fill('Devoir gras test');
|
||||
|
||||
const editorContent = page.locator('.modal .rich-text-content');
|
||||
await expect(editorContent).toBeVisible({ timeout: 10000 });
|
||||
await editorContent.click();
|
||||
await page.keyboard.type('Normal ');
|
||||
|
||||
@@ -459,8 +481,9 @@ test.describe('Rich Text & Attachments (Story 5.9)', () => {
|
||||
await hwCard.getByRole('button', { name: /modifier/i }).click();
|
||||
await expect(page.getByRole('dialog')).toBeVisible({ timeout: 10000 });
|
||||
|
||||
// WYSIWYG editor contains the old text
|
||||
// WYSIWYG editor contains the old text (TipTap initializes asynchronously)
|
||||
const editorContent = page.locator('.modal .rich-text-content');
|
||||
await expect(editorContent).toBeVisible({ timeout: 10000 });
|
||||
await expect(editorContent).toContainText('Ancienne description', { timeout: 5000 });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user