refactor(catalog): add event date attribute with dynamic options and update related logic

This commit is contained in:
2026-08-07 10:03:31 -03:00
parent 14d53d1e0b
commit 717ee5d194
11 changed files with 224 additions and 86 deletions

View File

@@ -15,6 +15,7 @@ use App\Domains\Catalog\Models\Category;
use App\Domains\Catalog\Models\FeaturedGroup;
use App\Domains\Catalog\Models\Inventory;
use App\Domains\Event\Models\EventDate;
use App\Domains\Shared\Enums\FieldType;
use App\Domains\Tenant\Models\Tenant;
use App\Domains\Ticket\Enums\ValidityTimeType;
use Database\Seeders\AttributeSeeder;
@@ -71,13 +72,15 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
->get();
$this->assertSame(
['servicio', 'color', 'horario', 'talle'],
['event_date', 'servicio', 'color', 'horario', 'talle'],
$attributes->pluck('codigo')->all(),
);
$this->assertSame(['Comedor', 'Vianda'], $attributes[0]->options->pluck('value')->all());
$this->assertSame(['Verde', 'Blanco'], $attributes[1]->options->pluck('value')->all());
$this->assertSame(['Desayuno', 'Almuerzo', 'Cena'], $attributes[2]->options->pluck('value')->all());
$this->assertSame(['14', 'S', 'M', 'L', 'XL', 'XXL'], $attributes[3]->options->pluck('value')->all());
$this->assertSame(FieldType::EventDate, $attributes[0]->type);
$this->assertEmpty($attributes[0]->options);
$this->assertSame(['Comedor', 'Vianda'], $attributes[1]->options->pluck('value')->all());
$this->assertSame(['Verde', 'Blanco'], $attributes[2]->options->pluck('value')->all());
$this->assertSame(['Desayuno', 'Almuerzo', 'Cena'], $attributes[3]->options->pluck('value')->all());
$this->assertSame(['14', 'S', 'M', 'L', 'XL', 'XXL'], $attributes[4]->options->pluck('value')->all());
$this->assertSame(
[
@@ -85,7 +88,7 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
['Almuerzo', ValidityTimeType::TimeWindow, '12:00:00', '15:00:00'],
['Cena', ValidityTimeType::TimeWindow, '20:00:00', '24:00:00'],
],
$attributes[2]->options
$attributes[3]->options
->map(fn ($option): array => [
$option->value,
$option->validityTime->type,
@@ -109,7 +112,7 @@ class FiestaFutbolInfantilProductSeederTest extends TestCase
$this->assertNull($generalAdmission->inventory_id);
$this->assertSame(EventProductType::Entry, $generalAdmission->event_product_type);
$this->assertCount(0, $generalAdmission->itemAttributes);
$this->assertCount(1, $generalAdmission->itemAttributes);
$this->assertCount(4, $generalAdmission->variants);
$this->assertEqualsCanonicalizing(
['2026-10-09', '2026-10-10', '2026-10-11', '2026-10-12'],