From 14d53d1e0b37803bde7c1b747f907724498e0091 Mon Sep 17 00:00:00 2001 From: ncoronel Date: Fri, 7 Aug 2026 09:20:52 -0300 Subject: [PATCH] refactor(catalog): handle null validity time in CatalogItemDetailResource and update related tests --- .../Resources/CatalogItemDetailResource.php | 8 +++++-- .../Event/AdminAppEventControllerTest.php | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/Domains/Catalog/Resources/CatalogItemDetailResource.php b/app/Domains/Catalog/Resources/CatalogItemDetailResource.php index 92ca8ec..7b30ce8 100644 --- a/app/Domains/Catalog/Resources/CatalogItemDetailResource.php +++ b/app/Domains/Catalog/Resources/CatalogItemDetailResource.php @@ -36,7 +36,9 @@ class CatalogItemDetailResource extends JsonResource 'max_units_per_user' => $this->max_units_per_user, 'has_tickets' => $this->has_tickets, 'validity_time_id' => $this->validity_time_id, - 'validity_time' => ValidityTimeResource::make($this->validityTime), + 'validity_time' => $this->validityTime === null + ? null + : ValidityTimeResource::make($this->validityTime), 'attributes' => $this->attributesData(), 'stock_tecnico' => $this->when( $selectedVariant === null, @@ -101,7 +103,9 @@ class CatalogItemDetailResource extends JsonResource 'label' => $option->label, 'sort_order' => $option->sort_order, 'validity_time_id' => $option->validity_time_id, - 'validity_time' => ValidityTimeResource::make($option->validityTime), + 'validity_time' => $option->validityTime === null + ? null + : ValidityTimeResource::make($option->validityTime), 'metadata' => $option->metadata, ]) ->values(), diff --git a/tests/Feature/Event/AdminAppEventControllerTest.php b/tests/Feature/Event/AdminAppEventControllerTest.php index 34030e4..e00c4b0 100644 --- a/tests/Feature/Event/AdminAppEventControllerTest.php +++ b/tests/Feature/Event/AdminAppEventControllerTest.php @@ -2,6 +2,8 @@ namespace Tests\Feature\Event; +use App\Domains\Attachable\Enums\AttachmentType; +use App\Domains\Attachable\Models\Attachment; use App\Domains\Auth\Models\User; use App\Domains\Authorization\Enums\RoleCode; use App\Domains\Tenant\Models\Tenant; @@ -240,11 +242,32 @@ class AdminAppEventControllerTest extends TestCase private function createTenant(string $code): Tenant { + $headerLogo = $this->createAttachment("{$code}-header"); + $footerLogo = $this->createAttachment("{$code}-footer"); + return Tenant::query()->create([ 'codigo' => $code, 'nombre' => ucfirst($code), 'dominio' => "{$code}.test", 'website_type_code' => 'onticket', + 'primary_color' => '#000000', + 'secondary_color' => '#000000', + 'danger_color' => '#000000', + 'success_color' => '#000000', + 'header_bg_color' => '#000000', + 'footer_bg_color' => '#000000', + 'header_logo_id' => $headerLogo->id, + 'footer_logo_id' => $footerLogo->id, + ]); + } + + private function createAttachment(string $name): Attachment + { + return Attachment::query()->create([ + 'path' => "test/{$name}.png", + 'filename' => "{$name}.png", + 'type' => AttachmentType::Image, + 'mime_type' => 'image/png', ]); }