fix: Corriger la disparition des créneaux lors d'un déplacement inter-jour
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

Lors d'un drag & drop d'un créneau vers un autre jour de la semaine,
le nouveau créneau devenait invisible car recurrenceStart était fixé à
la date d'occurrence (le jour source). Si le jour cible tombait avant
cette date dans la semaine, isActiveOnDate retournait false.

recurrenceStart est maintenant fixé au lundi de la semaine d'occurrence,
ce qui garantit la visibilité du créneau dès la semaine du déplacement.
This commit is contained in:
2026-03-07 00:23:54 +01:00
parent 39f8650b92
commit 125d9d8806
2 changed files with 44 additions and 3 deletions

View File

@@ -119,6 +119,41 @@ final class UpdateRecurringSlotHandlerTest extends TestCase
self::assertTrue($result['newSlot']->teacherId->equals(UserId::fromString(self::NEW_TEACHER_ID)));
}
#[Test]
public function allFutureCrossDayMoveSetsRecurrenceStartToWeekMonday(): void
{
// Wednesday slot — moving it to Monday
$slot = $this->createAndSaveSlot(
dayOfWeek: DayOfWeek::WEDNESDAY,
recurrenceStart: new DateTimeImmutable('2026-09-01'),
recurrenceEnd: new DateTimeImmutable('2027-07-04'),
);
$command = new UpdateRecurringSlotCommand(
tenantId: self::TENANT_ID,
slotId: (string) $slot->id,
occurrenceDate: '2026-10-14', // Wednesday
scope: 'all_future',
classId: self::CLASS_ID,
subjectId: self::SUBJECT_ID,
teacherId: self::TEACHER_ID,
dayOfWeek: DayOfWeek::MONDAY->value,
startTime: '08:00',
endTime: '09:00',
room: null,
updatedBy: self::UPDATER_ID,
);
$result = ($this->handler)($command);
$newSlot = $result['newSlot'];
self::assertNotNull($newSlot);
self::assertSame(DayOfWeek::MONDAY, $newSlot->dayOfWeek);
// recurrenceStart must be the Monday of the occurrence week (2026-10-12),
// not the occurrence date (2026-10-14), so the slot is visible this week
self::assertSame('2026-10-12', $newSlot->recurrenceStart->format('Y-m-d'));
}
#[Test]
public function allFutureWithNoOriginalEndUsesNullForNewSlotEnd(): void
{
@@ -149,6 +184,7 @@ final class UpdateRecurringSlotHandlerTest extends TestCase
}
private function createAndSaveSlot(
DayOfWeek $dayOfWeek = DayOfWeek::MONDAY,
?DateTimeImmutable $recurrenceStart = null,
?DateTimeImmutable $recurrenceEnd = null,
): ScheduleSlot {
@@ -157,7 +193,7 @@ final class UpdateRecurringSlotHandlerTest extends TestCase
classId: ClassId::fromString(self::CLASS_ID),
subjectId: SubjectId::fromString(self::SUBJECT_ID),
teacherId: UserId::fromString(self::TEACHER_ID),
dayOfWeek: DayOfWeek::MONDAY,
dayOfWeek: $dayOfWeek,
timeSlot: new TimeSlot('08:00', '09:00'),
room: null,
isRecurring: true,