feat(layouts): add 'Single' layout option to GroupLayout and update related functionality
This commit is contained in:
@@ -241,6 +241,32 @@ class CatalogControllerTest extends TestCase
|
||||
->assertJsonPath('0.nombre', 'carousel Item 1');
|
||||
}
|
||||
|
||||
public function test_single_group_layout_returns_only_its_first_available_item(): void
|
||||
{
|
||||
$tenant = $this->createTenant('catalog-single-layout');
|
||||
$group = $this->createGroup(
|
||||
$tenant,
|
||||
ProductLayout::TicketSelector,
|
||||
'Entradas',
|
||||
groupLayout: GroupLayout::Single,
|
||||
);
|
||||
|
||||
foreach (['Primera entrada', 'Segunda entrada'] as $order => $name) {
|
||||
$item = $this->createItem($tenant, $name);
|
||||
$group->featuredItems()->create([
|
||||
'catalog_item_id' => $item->id,
|
||||
'order' => $order,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->getJson("/api/tenants/{$tenant->codigo}/catalog")
|
||||
->assertOk()
|
||||
->assertJsonPath('0.layout', ProductLayout::TicketSelector->value)
|
||||
->assertJsonPath('0.group_layout', GroupLayout::Single->value)
|
||||
->assertJsonCount(1, '0.items')
|
||||
->assertJsonPath('0.items.0.nombre', 'Primera entrada');
|
||||
}
|
||||
|
||||
public function test_groups_can_source_items_from_a_category_or_the_entire_catalog(): void
|
||||
{
|
||||
$tenant = $this->createTenant('catalog-sources');
|
||||
|
||||
Reference in New Issue
Block a user