feat(catalog): enhance featured groups with paginated and carousel layouts, update seeder and tests

This commit is contained in:
2026-07-23 13:24:39 -03:00
parent 1438ff66c7
commit e778d862ba
5 changed files with 157 additions and 39 deletions

View File

@@ -21,7 +21,7 @@ class ProductCatalogFromImagesSeederTest extends TestCase
{
use RefreshDatabase;
public function test_it_features_every_sonder_product_in_a_single_image_column(): void
public function test_it_creates_paginated_and_random_carousel_groups_for_sonder(): void
{
Storage::fake('s3');
@@ -52,19 +52,44 @@ class ProductCatalogFromImagesSeederTest extends TestCase
ProductCatalogFromImagesSeeder::class,
]);
$group = FeaturedGroup::query()
$groups = FeaturedGroup::query()
->where('tenant_code', $tenant->codigo)
->with('featuredItems.catalogItem')
->sole();
->orderBy('group_order')
->get()
->keyBy('group_name');
$this->assertSame('Productos', $group->group_name);
$this->assertSame(ProductLayout::ColumnWithImage, $group->product_layout);
$this->assertSame(GroupLayout::Paginated, $group->group_layout);
$this->assertSame(0, $group->group_order);
$paginatedGroup = $groups->get('Productos');
$carouselGroup = $groups->get('Productos destacados');
$catalogItemIds = CatalogItem::query()
->where('tenant_code', $tenant->codigo)
->orderBy('id')
->pluck('id');
$this->assertNotNull($paginatedGroup);
$this->assertSame(ProductLayout::ColumnWithImage, $paginatedGroup->product_layout);
$this->assertSame(GroupLayout::Paginated, $paginatedGroup->group_layout);
$this->assertSame(0, $paginatedGroup->group_order);
$this->assertSame(
CatalogItem::query()->where('tenant_code', $tenant->codigo)->orderBy('id')->pluck('slug')->all(),
$group->featuredItems->pluck('catalogItem.slug')->all(),
$paginatedGroup->featuredItems->pluck('catalogItem.slug')->all(),
);
$this->assertCount(10, $paginatedGroup->featuredItems);
$this->assertNotNull($carouselGroup);
$this->assertSame(ProductLayout::ColumnWithImage, $carouselGroup->product_layout);
$this->assertSame(GroupLayout::Carousel, $carouselGroup->group_layout);
$this->assertSame(1, $carouselGroup->group_order);
$this->assertCount(5, $carouselGroup->featuredItems);
$this->assertCount(
5,
$carouselGroup->featuredItems->pluck('catalog_item_id')->unique(),
);
$this->assertCount(
0,
$carouselGroup->featuredItems
->pluck('catalog_item_id')
->diff($catalogItemIds),
);
$this->assertCount(10, $group->featuredItems);
}
}