Add tests for ticket validity and event date formatting

- Create TicketValiditySchemaTest to verify database schema for ticket validity.
- Update CatalogModelsTest to include tests for event date attributes and selection options.
- Introduce EventDateTextFormatterTest for formatting event dates in Spanish.
- Refactor EventModelsTest to include validity time relationships.
- Add SaleDetailResourceTest to ensure correct serialization of purchase items.
- Enhance TicketTest with validity time checks and status management.
- Implement ValidityTimeResourceTest to validate resource output for different validity types.
- Add ValidityTimeTest to verify casting and validity checks for validity time types.
This commit is contained in:
2026-08-11 12:41:35 -03:00
parent b294e5c46e
commit 02cf3f3773
166 changed files with 10203 additions and 1849 deletions

View File

@@ -52,6 +52,9 @@ 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',
'display_categories' => false,
'display_seach_bar' => false,
]);
$response = $this->getJson('/api/tenants/bootstrap/acme.com');
@@ -64,6 +67,9 @@ 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.display_categories', false)
->assertJsonPath('data.display_seach_bar', false)
->assertJsonPath('data.header_bg_color', '#ffffff')->assertJsonPath('data.footer_bg_color', '#ffffff');
$headerUrl = $response->json('data.header_logo');
@@ -242,10 +248,10 @@ class BootstrapTenantControllerTest extends TestCase
->assertJsonPath('data.menues.0.code', 'help')
->assertJsonPath('data.menues.0.label', 'Ayuda')
->assertJsonPath('data.menues.0.parent_menu_code', null)
->assertJsonPath('data.menues.0.submenues.0.code', 'help.faq')
->assertJsonPath('data.menues.0.submenues.0.label', 'Preguntas frecuentes')
->assertJsonPath('data.menues.0.submenues.0.code', 'help.shipping')
->assertJsonPath('data.menues.0.submenues.0.label', 'Envíos')
->assertJsonPath('data.menues.0.submenues.0.parent_menu_code', 'help')
->assertJsonPath('data.menues.0.submenues.1.code', 'help.shipping');
->assertJsonPath('data.menues.0.submenues.1.code', 'help.faq');
$assertCleanMenu = function (array $menu) use (&$assertCleanMenu): void {
$this->assertArrayNotHasKey('created_at', $menu);
@@ -259,10 +265,10 @@ class BootstrapTenantControllerTest extends TestCase
};
$menus = $response->json('data.menues');
$this->assertEquals($staticContent, $menus[0]['submenues'][0]['static_content']);
$this->assertEquals($staticContent, $menus[0]['submenues'][1]['static_content']);
$assertCleanMenu($menus[0]);
$this->assertArrayNotHasKey('static_content', $menus[0]);
$this->assertArrayNotHasKey('static_content', $menus[0]['submenues'][1]);
$this->assertArrayNotHasKey('static_content', $menus[0]['submenues'][0]);
}
public function test_it_returns_only_menus_assigned_to_the_user_role(): void
@@ -297,6 +303,49 @@ class BootstrapTenantControllerTest extends TestCase
->assertJsonMissing(['code' => 'admin.catalog']);
}
public function test_it_orders_parent_menus_and_their_submenus_by_label(): void
{
$tenant = $this->createTenant();
$userRole = Role::query()->create([
'codigo' => RoleCode::User->value,
'nombre' => 'Usuario',
]);
$zeta = Menu::query()->create([
'code' => 'zeta',
'label' => 'Zeta',
'route' => '/zeta',
]);
$tree = Menu::query()->create([
'code' => 'tree',
'label' => 'Árbol',
'route' => '/arbol',
]);
$fox = Menu::query()->create([
'code' => 'tree.fox',
'label' => 'Zorro',
'parent_menu_code' => $tree->code,
'route' => '/arbol/zorro',
]);
$eagle = Menu::query()->create([
'code' => 'tree.eagle',
'label' => 'Águila',
'parent_menu_code' => $tree->code,
'route' => '/arbol/aguila',
]);
$menuCodes = [$zeta->code, $tree->code, $fox->code, $eagle->code];
$tenant->menues()->sync($menuCodes);
$userRole->menus()->sync($menuCodes);
$this->getJson('/api/tenants/bootstrap/acme.com')
->assertOk()
->assertJsonPath('data.menues.0.code', 'tree')
->assertJsonPath('data.menues.1.code', 'zeta')
->assertJsonPath('data.menues.0.submenues.0.code', 'tree.eagle')
->assertJsonPath('data.menues.0.submenues.1.code', 'tree.fox');
}
public function test_it_rejects_duplicate_domains_after_normalization_when_storing(): void
{
$base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==';