Add-ons: Modal statt Toast bei fehlendem Credit-Guthaben

Scheiterte ein Boost- oder Nachweis-Kauf am Wallet-Guthaben, gab es nur
einen flüchtigen Toast ohne Weg zur Lösung. Jetzt öffnet sich ein Modal
mit Kosten, Guthaben und fehlender Differenz sowie einem Direktlink
"Credits aufladen" zur Wallet-Sektion der Buchungsseite (neuer
#credits-Anker).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-07 14:30:57 +00:00
parent 2a46aed1a9
commit dfb8de9e45
3 changed files with 99 additions and 13 deletions

View file

@ -83,6 +83,42 @@ test('buying a proof from the detail page unlocks the download', function () {
expect($customer->fresh()->creditBalance())->toBe(7);
});
test('an add-on purchase without enough credits opens the shortfall modal with a topup link', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
$this->wallet->credit($customer, 1);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->call('buyProof')
->assertSet('creditShortfall', [
'label' => 'Der Veröffentlichungsnachweis',
'required' => 3,
'available' => 1,
])
->assertSee('Nicht genügend Credits')
->assertSee('Es fehlen 2 Credits.')
->assertSee('Credits aufladen')
->assertSee(route('me.bookings.index').'#credits', escape: false);
expect($customer->fresh()->creditBalance())->toBe(1); // nichts abgebucht
});
test('a boost without enough credits opens the shortfall modal instead of booking', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->call('buyBoost', 7)
->assertSet('creditShortfall.label', 'Der Boost')
->assertSee('Nicht genügend Credits');
expect($pr->fresh()->isBoosted())->toBeFalse();
});
test('a non-green release cannot be boosted from the detail page', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();