test heavy workload spreading
This commit is contained in:
parent
becd7573c6
commit
85e2c33c31
2 changed files with 35 additions and 7 deletions
|
|
@ -253,14 +253,14 @@ class ScheduleEndpointTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_it_rejects_spread_placement_for_a_dense_schedule(): void
|
||||
public function test_it_spreads_heavier_days_across_the_full_range(): void
|
||||
{
|
||||
$user = $this->createUser('reader@example.com');
|
||||
$set = $this->createSet($user, 'Course');
|
||||
$lessonLevel = $this->createLevel($set, 'lesson');
|
||||
$repository = app(ElementRepository::class);
|
||||
|
||||
foreach (range(1, 5) as $number) {
|
||||
foreach (range(1, 13) as $number) {
|
||||
$repository->create(new CreateElementDto(
|
||||
name: "Lesson {$number}",
|
||||
level: $lessonLevel,
|
||||
|
|
@ -269,15 +269,22 @@ class ScheduleEndpointTest extends TestCase
|
|||
}
|
||||
$this->createSession($user, 'valid-token');
|
||||
|
||||
$this->credentialedPost('/api/schedules', [
|
||||
$response = $this->credentialedPost('/api/schedules', [
|
||||
'setId' => $set->getId(),
|
||||
'levelId' => $lessonLevel->getId(),
|
||||
'startDate' => '2026-08-10',
|
||||
'targetDate' => '2026-08-13',
|
||||
'targetDate' => '2026-08-14',
|
||||
'workloadPlacement' => 'spread',
|
||||
])->assertBadRequest()->assertExactJson([
|
||||
'error' => 'spread placement requires fewer assignments than days',
|
||||
]);
|
||||
])->assertCreated();
|
||||
|
||||
$days = $response->json('schedule.days');
|
||||
$this->assertIsArray($days);
|
||||
$this->assertSame(
|
||||
[3, 2, 3, 2, 3],
|
||||
array_map(function (array $day): int {
|
||||
return count($day['assignments']);
|
||||
}, $days),
|
||||
);
|
||||
}
|
||||
|
||||
public function test_it_lists_only_the_users_schedules_newest_first(): void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue