Paket-Vorteile: dynamische, im Admin pflegbare Vorteilsliste je Tarif

Neue JSON-Spalte plans.benefits (Migration + Cast + Plan::benefitsList()).
Im Admin (Tarife & Pakete) pro Tarif zeilenweise pflegbar; die In-App-
Buchungsseite rendert die Liste in den Tarif-Karten statt einer festen
Zeile. Seeder/Factory mit Beispiel-Vorteilen. Single Source of Truth fuer
Buchungsseite und (folgt separat) die oeffentliche Preise-Seite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-18 16:36:09 +00:00
parent 58b427fcd0
commit 446aada9c8
8 changed files with 161 additions and 8 deletions

View file

@ -100,6 +100,46 @@ test('saving a plan updates the local record and triggers the stripe sync', func
->and($plan->daily_limit)->toBe(3);
});
test('benefitsList returns a trimmed, non-empty list and tolerates null', function () {
$plan = Plan::factory()->create(['benefits' => [' Vorteil A ', '', 'Vorteil B', ' ']]);
expect($plan->benefitsList())->toBe(['Vorteil A', 'Vorteil B']);
$bare = Plan::factory()->create(['benefits' => null]);
expect($bare->benefitsList())->toBe([]);
});
test('saving a plan persists the benefits line by line', function () {
/** @var TestCase $this */
$plan = Plan::factory()->create(['name' => 'Business', 'benefits' => []]);
$this->mock(StripePlanSyncService::class, function ($mock) {
$mock->shouldReceive('syncAfterUpdate')->once();
});
$this->actingAs(plansPageAdmin());
LivewireVolt::test('admin.payments.plans')
->call('edit', $plan->id)
->set('benefits', "Erster Vorteil\n\n Zweiter Vorteil \nDritter Vorteil")
->call('save')
->assertHasNoErrors();
expect($plan->refresh()->benefitsList())
->toBe(['Erster Vorteil', 'Zweiter Vorteil', 'Dritter Vorteil']);
});
test('editing a plan preloads its benefits as newline text', function () {
/** @var TestCase $this */
$plan = Plan::factory()->create(['benefits' => ['Vorteil eins', 'Vorteil zwei']]);
$this->actingAs(plansPageAdmin());
LivewireVolt::test('admin.payments.plans')
->call('edit', $plan->id)
->assertSet('benefits', "Vorteil eins\nVorteil zwei");
});
test('saving without a price change shows the plain success message', function () {
/** @var TestCase $this */
$plan = Plan::factory()->create([

View file

@ -54,6 +54,24 @@ test('the bookings page renders the active plans with checkout links', function
->assertSee(route('me.checkout.subscription', ['planSlug' => 'business', 'interval' => 'monthly']), false);
});
test('the plan card renders the maintained benefits list', function () {
/** @var TestCase $this */
Plan::factory()->create([
'name' => 'Business',
'slug' => 'business',
'press_release_quota' => 10,
'benefits' => ['Günstigere Extra-Pressemitteilungen', 'Boost-Platzierung vergünstigt'],
]);
$user = bookingsTestCustomer();
BillingAddress::factory()->create(['user_id' => $user->id]);
$this->actingAs($user);
LivewireVolt::test('customer.bookings')
->assertSee('Günstigere Extra-Pressemitteilungen')
->assertSee('Boost-Platzierung vergünstigt');
});
test('the single pm block links to its checkout', function () {
/** @var TestCase $this */
config()->set('billing.single_pm_stripe_price_id', 'price_test_single_pm');