feat(event): implement EventDateGroupingService to group historical dates and update related resources and tests

This commit is contained in:
2026-09-15 16:28:39 -03:00
parent 51937ca93f
commit 24d87623cc
7 changed files with 293 additions and 4 deletions

View File

@@ -150,6 +150,52 @@ class AdminAppEventControllerTest extends TestCase
->assertJsonMissing(['title' => 'Other Event']);
}
public function test_dates_are_grouped_by_their_final_destination_and_ordered_by_active_date(): void
{
$tenant = $this->createActiveEvent($this->createTenant('acme'), 'Acme Event');
$source13 = $tenant->eventDates()->create([
'date' => '2026-10-13', 'time_start' => '00:00', 'time_end' => '23:59',
]);
$source22 = $tenant->eventDates()->create([
'date' => '2026-10-22', 'time_start' => '00:00', 'time_end' => '23:59',
]);
$middle24 = $tenant->eventDates()->create([
'date' => '2026-10-24', 'time_start' => '00:00', 'time_end' => '23:59',
]);
$active25 = $tenant->eventDates()->create([
'date' => '2026-10-25', 'time_start' => '00:00', 'time_end' => '23:59',
]);
$destination30 = $tenant->eventDates()->create([
'date' => '2026-10-30', 'time_start' => '00:00', 'time_end' => '23:59',
]);
$source13->update(['rescheduled_to_event_date_id' => $destination30->id]);
$source22->update(['rescheduled_to_event_date_id' => $middle24->id]);
$middle24->update(['rescheduled_to_event_date_id' => $destination30->id]);
Sanctum::actingAs($this->createAdminAppUser($tenant));
$this->getJson('/api/v1/adminapp/tenant/event')
->assertOk()
->assertJsonCount(2, 'data.dates')
->assertJsonPath('data.dates.0.id', $active25->id)
->assertJsonCount(0, 'data.dates.0.rescheduled_dates')
->assertJsonPath('data.dates.1.id', $destination30->id)
->assertJsonPath('data.dates.1.rescheduled_dates.0.id', $source13->id)
->assertJsonPath(
'data.dates.1.rescheduled_dates.0.rescheduled_to_event_date_id',
$destination30->id,
)
->assertJsonPath('data.dates.1.rescheduled_dates.1.id', $source22->id)
->assertJsonPath(
'data.dates.1.rescheduled_dates.1.rescheduled_to_event_date_id',
$destination30->id,
)
->assertJsonPath('data.dates.1.rescheduled_dates.2.id', $middle24->id)
->assertJsonPath(
'data.dates.1.rescheduled_dates.2.rescheduled_to_event_date_id',
$destination30->id,
);
}
public function test_reading_a_tenant_without_event_configuration_returns_empty_values(): void
{
$tenant = $this->createTenant('acme');