feat(event): add EventDateTextFormatter for formatting event dates; update Tenant model and resource to include event_date_text; create migration for event_date_text column; enhance tests for event date formatting and tenant updates

This commit is contained in:
2026-08-10 10:42:12 -03:00
parent 1cd60f7021
commit 4aaa66dc38
9 changed files with 181 additions and 0 deletions

View File

@@ -191,6 +191,7 @@ class CatalogSchemaTest extends TestCase
$this->assertTrue(Schema::hasColumns('tenants', [
'event_title',
'event_location',
'event_date_text',
]));
$this->assertEqualsCanonicalizing([
'id',

View File

@@ -56,6 +56,7 @@ class AdminAppEventControllerTest extends TestCase
'id' => $tenant->id,
'event_title' => 'Festival Acme',
'event_location' => 'Predio Ferial, Rosario',
'event_date_text' => '9 de Octubre 2026',
]);
$this->assertDatabaseHas('event_dates', [
'tenant_code' => $tenant->codigo,
@@ -137,6 +138,7 @@ class AdminAppEventControllerTest extends TestCase
'date' => '2026-11-15',
]);
$this->assertDatabaseMissing('event_dates', ['id' => $removedDate->id]);
$this->assertSame('15 de Noviembre 2026', $tenant->fresh()->event_date_text);
$this->assertDatabaseMissing('tenant_social_media', [
'tenant_code' => $tenant->codigo,
'social_media_code' => 'facebook',
@@ -148,6 +150,27 @@ class AdminAppEventControllerTest extends TestCase
]);
}
public function test_updating_event_dates_recalculates_the_tenant_date_text(): void
{
$tenant = $this->createTenant('acme');
Sanctum::actingAs($this->createAdminAppUser($tenant));
$payload = $this->eventPayload();
$payload['dates'] = collect([9, 10, 11, 12])
->map(fn (int $day): array => [
'date' => sprintf('2026-10-%02d', $day),
'start_time' => '09:00',
'end_time' => '18:30',
])
->all();
$this->putJson('/api/v1/adminapp/tenant/event', $payload)->assertOk();
$this->assertSame(
'9, 10, 11 y 12 de Octubre 2026',
$tenant->fresh()->event_date_text
);
}
public function test_update_validates_event_dates_and_contact_urls(): void
{
$tenant = $this->createTenant('acme');

View File

@@ -52,6 +52,7 @@ class BootstrapTenantControllerTest extends TestCase
'footer_bg_color' => '#ffffff',
'header_logo_id' => $headerAttachment->id,
'footer_logo_id' => $footerAttachment->id,
'event_date_text' => '9, 10, 11 y 12 de Octubre 2026',
]);
$response = $this->getJson('/api/tenants/bootstrap/acme.com');
@@ -64,6 +65,7 @@ class BootstrapTenantControllerTest extends TestCase
->assertJsonPath('data.secondary_color', '#00ff00')
->assertJsonPath('data.danger_color', '#0000ff')
->assertJsonPath('data.success_color', '#00ff00')
->assertJsonPath('data.event_date_text', '9, 10, 11 y 12 de Octubre 2026')
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
$headerUrl = $response->json('data.header_logo');