diff --git a/resources/views/components/product/badges.blade.php b/resources/views/components/product/badges.blade.php index 729b321..4d36e6a 100644 --- a/resources/views/components/product/badges.blade.php +++ b/resources/views/components/product/badges.blade.php @@ -5,7 +5,7 @@ @endphp @if($ticked->isNotEmpty()) -
+
merge(['class' => 'flex flex-wrap items-center gap-1.5']) }}> @foreach($ticked as $key => $label) {{ $label }} diff --git a/resources/views/components/product/card.blade.php b/resources/views/components/product/card.blade.php index 7ac304a..78c1b40 100644 --- a/resources/views/components/product/card.blade.php +++ b/resources/views/components/product/card.blade.php @@ -38,9 +38,7 @@

-
- -
+
diff --git a/resources/views/products/show.blade.php b/resources/views/products/show.blade.php index 0cec866..7f6a663 100644 --- a/resources/views/products/show.blade.php +++ b/resources/views/products/show.blade.php @@ -54,9 +54,7 @@ {{ $product->created_at->format('M j, Y') }}
-
- -
+ @if($product->tags->isNotEmpty())
diff --git a/tests/Feature/ProductBadgesTest.php b/tests/Feature/ProductBadgesTest.php index b35d17f..c0592d6 100644 --- a/tests/Feature/ProductBadgesTest.php +++ b/tests/Feature/ProductBadgesTest.php @@ -100,3 +100,16 @@ test('existing product without new data still renders', function () { $this->get(route('products.show', $product))->assertOk(); }); + +test('badge-less product emits no badge markup on card or show page', function () { + $product = Product::factory()->approved()->create(); + + $this->get(route('products.show', $product))->assertOk()->assertDontSee('rounded-full text-xs font-medium', false); + + $html = view('components.product.card', ['product' => $product->load(['user', 'category'])])->render(); + expect($html)->not->toContain('mb-3 flex') + ->and($html)->not->toContain('gap-1.5'); + + $badged = Product::factory()->approved()->create(['eu_made' => true])->load(['user', 'category']); + expect(view('components.product.card', ['product' => $badged])->render())->toContain('gap-1.5')->toContain('EU made'); +});