fix: emit no badge markup when no badge is ticked
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
9920fafab6
commit
bf365d029f
@@ -5,7 +5,7 @@
|
||||
@endphp
|
||||
|
||||
@if($ticked->isNotEmpty())
|
||||
<div class="flex flex-wrap items-center gap-1.5">
|
||||
<div {{ $attributes->merge(['class' => 'flex flex-wrap items-center gap-1.5']) }}>
|
||||
@foreach($ticked as $key => $label)
|
||||
<span class="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-primary-100 dark:bg-primary-900 text-primary-800 dark:text-primary-200">
|
||||
{{ $label }}
|
||||
|
||||
@@ -38,9 +38,7 @@
|
||||
</p>
|
||||
|
||||
<!-- Badges -->
|
||||
<div class="mb-3 empty:hidden">
|
||||
<x-product.badges :product="$product" />
|
||||
</div>
|
||||
<x-product.badges :product="$product" class="mb-3" />
|
||||
|
||||
<!-- Meta Information -->
|
||||
<div class="flex items-center justify-between text-xs text-gray-500 dark:text-gray-400">
|
||||
|
||||
@@ -54,9 +54,7 @@
|
||||
<span>{{ $product->created_at->format('M j, Y') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<x-product.badges :product="$product" />
|
||||
</div>
|
||||
<x-product.badges :product="$product" class="mt-3" />
|
||||
|
||||
@if($product->tags->isNotEmpty())
|
||||
<div class="mt-3 flex flex-wrap gap-x-3 gap-y-1 text-sm text-gray-500 dark:text-gray-400">
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user