fix: Filtrer enseignants et matières par affectation lors de la création de créneaux
Quand une classe n'avait aucune affectation enseignant-matière, les selects de la modale de création de créneau affichaient tous les enseignants et toutes les matières au lieu d'une liste vide. Cela permettait de soumettre des combinaisons invalides, produisant un message d'erreur avec des UUID incompréhensibles. Les dropdowns n'affichent plus que les enseignants/matières effectivement affectés à la classe sélectionnée. Le message d'erreur backend est reformulé sans UUID pour le cas où la validation frontend serait contournée.
This commit is contained in:
@@ -42,10 +42,12 @@ function resolveDeterministicIds(): { schoolId: string; academicYearId: string }
|
||||
const output = execSync(
|
||||
`docker compose -f "${composeFile}" exec -T php php -r '` +
|
||||
`require "/app/vendor/autoload.php"; ` +
|
||||
`$t="${TENANT_ID}"; $ns="6ba7b814-9dad-11d1-80b4-00c04fd430c8"; ` +
|
||||
`echo Ramsey\\Uuid\\Uuid::uuid5($ns,"school-$t")->toString()."\\n"; ` +
|
||||
`$t="${TENANT_ID}"; ` +
|
||||
`$dns="6ba7b810-9dad-11d1-80b4-00c04fd430c8"; ` +
|
||||
`$ay="6ba7b814-9dad-11d1-80b4-00c04fd430c8"; ` +
|
||||
`echo Ramsey\\Uuid\\Uuid::uuid5($dns,"school-$t")->toString()."\\n"; ` +
|
||||
`$m=(int)date("n"); $s=$m>=9?(int)date("Y"):(int)date("Y")-1; $e=$s+1; ` +
|
||||
`echo Ramsey\\Uuid\\Uuid::uuid5($ns,"$t:$s-$e")->toString();` +
|
||||
`echo Ramsey\\Uuid\\Uuid::uuid5($ay,"$t:$s-$e")->toString();` +
|
||||
`' 2>&1`,
|
||||
{ encoding: 'utf-8' }
|
||||
).trim();
|
||||
@@ -147,11 +149,13 @@ async function fillSlotForm(
|
||||
if (className) {
|
||||
await dialog.locator('#slot-class').selectOption({ label: className });
|
||||
}
|
||||
// Wait for assignments to load — only the test teacher is assigned,
|
||||
// so the teacher dropdown filters down to 1 option
|
||||
// Wait for assignments to load, then select subject first (filters teachers)
|
||||
const subjectOptions = dialog.locator('#slot-subject option:not([value=""])');
|
||||
await expect(subjectOptions.first()).toBeAttached({ timeout: 10000 });
|
||||
await dialog.locator('#slot-subject').selectOption({ index: 1 });
|
||||
// After subject selection, wait for teacher dropdown to be filtered
|
||||
const teacherOptions = dialog.locator('#slot-teacher option:not([value=""])');
|
||||
await expect(teacherOptions).toHaveCount(1, { timeout: 10000 });
|
||||
await dialog.locator('#slot-subject').selectOption({ index: 1 });
|
||||
await dialog.locator('#slot-teacher').selectOption({ index: 1 });
|
||||
await dialog.locator('#slot-day').selectOption(dayValue);
|
||||
await dialog.locator('#slot-start').fill(startTime);
|
||||
@@ -180,39 +184,31 @@ test.describe('Schedule Management - Modification & Conflicts & Calendar (Story
|
||||
|
||||
const { schoolId, academicYearId } = resolveDeterministicIds();
|
||||
|
||||
// Ensure test classes exist
|
||||
// Clean up stale test data (e.g. from previous runs with wrong school_id)
|
||||
try {
|
||||
runSql(
|
||||
`INSERT INTO school_classes (id, tenant_id, school_id, academic_year_id, name, level, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', '${academicYearId}', 'E2E-Schedule-6A', '6ème', 'active', NOW(), NOW()) ON CONFLICT DO NOTHING`
|
||||
);
|
||||
runSql(`DELETE FROM schedule_slots WHERE class_id IN (SELECT id FROM school_classes WHERE name IN ('E2E-Schedule-6A','E2E-Schedule-5A') AND tenant_id = '${TENANT_ID}')`);
|
||||
runSql(`DELETE FROM teacher_assignments WHERE school_class_id IN (SELECT id FROM school_classes WHERE name IN ('E2E-Schedule-6A','E2E-Schedule-5A') AND tenant_id = '${TENANT_ID}')`);
|
||||
runSql(`DELETE FROM school_classes WHERE name IN ('E2E-Schedule-6A','E2E-Schedule-5A') AND tenant_id = '${TENANT_ID}'`);
|
||||
runSql(`DELETE FROM subjects WHERE code IN ('E2SMATH','E2SFRA') AND tenant_id = '${TENANT_ID}'`);
|
||||
} catch {
|
||||
// May already exist
|
||||
// Tables may not exist
|
||||
}
|
||||
|
||||
try {
|
||||
runSql(
|
||||
`INSERT INTO school_classes (id, tenant_id, school_id, academic_year_id, name, level, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', '${academicYearId}', 'E2E-Schedule-5A', '5ème', 'active', NOW(), NOW()) ON CONFLICT DO NOTHING`
|
||||
);
|
||||
} catch {
|
||||
// May already exist
|
||||
}
|
||||
// Create test classes
|
||||
runSql(
|
||||
`INSERT INTO school_classes (id, tenant_id, school_id, academic_year_id, name, level, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', '${academicYearId}', 'E2E-Schedule-6A', '6ème', 'active', NOW(), NOW())`
|
||||
);
|
||||
runSql(
|
||||
`INSERT INTO school_classes (id, tenant_id, school_id, academic_year_id, name, level, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', '${academicYearId}', 'E2E-Schedule-5A', '5ème', 'active', NOW(), NOW())`
|
||||
);
|
||||
|
||||
// Ensure test subjects exist
|
||||
try {
|
||||
runSql(
|
||||
`INSERT INTO subjects (id, tenant_id, school_id, name, code, color, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', 'E2E-Schedule-Maths', 'E2ESCHEDMATH', '#3b82f6', 'active', NOW(), NOW()) ON CONFLICT DO NOTHING`
|
||||
);
|
||||
} catch {
|
||||
// May already exist
|
||||
}
|
||||
|
||||
try {
|
||||
runSql(
|
||||
`INSERT INTO subjects (id, tenant_id, school_id, name, code, color, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', 'E2E-Schedule-Français', 'E2ESCHEDFRA', '#ef4444', 'active', NOW(), NOW()) ON CONFLICT DO NOTHING`
|
||||
);
|
||||
} catch {
|
||||
// May already exist
|
||||
}
|
||||
// Create test subjects
|
||||
runSql(
|
||||
`INSERT INTO subjects (id, tenant_id, school_id, name, code, color, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', 'E2E-Schedule-Maths', 'E2SMATH', '#3b82f6', 'active', NOW(), NOW())`
|
||||
);
|
||||
runSql(
|
||||
`INSERT INTO subjects (id, tenant_id, school_id, name, code, color, status, created_at, updated_at) VALUES (gen_random_uuid(), '${TENANT_ID}', '${schoolId}', 'E2E-Schedule-Français', 'E2SFRA', '#ef4444', 'active', NOW(), NOW())`
|
||||
);
|
||||
|
||||
cleanupScheduleData();
|
||||
cleanupCalendarEntries();
|
||||
|
||||
Reference in New Issue
Block a user