feat(addons): finalize event addon catalog and ai styling upgrade flow
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\Event;
|
||||
use App\Models\EventPackage;
|
||||
use App\Models\EventPackageAddon;
|
||||
use App\Models\Package;
|
||||
use App\Models\PackageAddon;
|
||||
use App\Models\Tenant;
|
||||
use Tests\Feature\Tenant\TenantTestCase;
|
||||
|
||||
@@ -225,4 +226,49 @@ class BillingAddonHistoryTest extends TenantTestCase
|
||||
$response->assertStatus(404);
|
||||
$response->assertJsonPath('message', 'Event scope not found.');
|
||||
}
|
||||
|
||||
public function test_tenant_addon_history_uses_catalog_label_when_metadata_label_missing(): void
|
||||
{
|
||||
$package = Package::factory()->endcustomer()->create();
|
||||
|
||||
$event = Event::factory()->for($this->tenant)->create([
|
||||
'slug' => 'catalog-label-event',
|
||||
]);
|
||||
|
||||
$eventPackage = EventPackage::create([
|
||||
'event_id' => $event->id,
|
||||
'package_id' => $package->id,
|
||||
'purchased_price' => $package->price,
|
||||
'purchased_at' => now()->subWeek(),
|
||||
'used_photos' => 0,
|
||||
'used_guests' => 0,
|
||||
'gallery_expires_at' => now()->addDays(20),
|
||||
]);
|
||||
|
||||
PackageAddon::create([
|
||||
'key' => 'catalog_label_test',
|
||||
'label' => 'Catalog label fallback',
|
||||
'active' => true,
|
||||
'sort' => 5,
|
||||
'metadata' => ['price_eur' => 4],
|
||||
]);
|
||||
|
||||
EventPackageAddon::create([
|
||||
'event_package_id' => $eventPackage->id,
|
||||
'event_id' => $event->id,
|
||||
'tenant_id' => $this->tenant->id,
|
||||
'addon_key' => 'catalog_label_test',
|
||||
'quantity' => 1,
|
||||
'status' => 'completed',
|
||||
'amount' => 4.00,
|
||||
'currency' => 'EUR',
|
||||
'metadata' => [],
|
||||
'purchased_at' => now(),
|
||||
]);
|
||||
|
||||
$response = $this->authenticatedRequest('GET', '/api/v1/tenant/billing/addons');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJsonPath('data.0.label', 'Catalog label fallback');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user