fix: shift edit time slot dropdown loading state and test coverage
The time slot dropdown in the shift edit dialog could flash the "create a time slot first" alert during loading, and show raw ULIDs when time slot data hadn't loaded yet. Fixed by: - Adding loading state indicator to the time slot dropdown - Using the shift's existing time_slot object as a fallback item while the full list is fetching - Showing the dropdown (with loading spinner) instead of the misleading "no time slots" alert during fetch Added test coverage for time_slot_id validation on shift updates: - Update with valid same-event time slot (200) - Update with cross-org time slot (422) - Update on sub-event with parent festival time slot (200) - Store/update responses include nested time_slot object Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -477,6 +477,38 @@ class FestivalEventTest extends TestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_shift_on_sub_event_with_parent_festival_time_slot(): void
|
||||
{
|
||||
$section = FestivalSection::factory()->create([
|
||||
'event_id' => $this->subEvent->id,
|
||||
]);
|
||||
|
||||
$subEventTimeSlot = TimeSlot::factory()->create([
|
||||
'event_id' => $this->subEvent->id,
|
||||
]);
|
||||
|
||||
$festivalTimeSlot = TimeSlot::factory()->create([
|
||||
'event_id' => $this->festival->id,
|
||||
]);
|
||||
|
||||
// Create a shift with the sub-event time slot
|
||||
$shift = Shift::factory()->create([
|
||||
'festival_section_id' => $section->id,
|
||||
'time_slot_id' => $subEventTimeSlot->id,
|
||||
]);
|
||||
|
||||
Sanctum::actingAs($this->orgAdmin);
|
||||
|
||||
// Update to use a festival time slot — should succeed
|
||||
$response = $this->putJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->subEvent->id}/sections/{$section->id}/shifts/{$shift->id}", [
|
||||
'time_slot_id' => $festivalTimeSlot->id,
|
||||
]);
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonPath('data.time_slot_id', $festivalTimeSlot->id)
|
||||
->assertJsonPath('data.time_slot.id', $festivalTimeSlot->id);
|
||||
}
|
||||
|
||||
public function test_create_shift_on_local_section_with_other_event_time_slot_returns_422(): void
|
||||
{
|
||||
$section = FestivalSection::factory()->create([
|
||||
|
||||
Reference in New Issue
Block a user