Add-ons: Kaufbestaetigung vor Credit-Abbuchung + deutlichere Buttons
Boost-Laufzeiten und Nachweis oeffnen jetzt ein Bestaetigungs-Modal mit Preis, Guthaben und Restsaldo; erst "Kostenpflichtig buchen" bucht ab. Boost-Buttons primary mit explizitem Kauf-Label. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
b26dc9057c
commit
93d7f6d480
2 changed files with 191 additions and 15 deletions
|
|
@ -49,11 +49,73 @@ test('a published green release shows the boost and proof add-ons', function ()
|
|||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->assertSee('Add-ons')
|
||||
->assertSee('Boost — Platzierung')
|
||||
->assertSee('7 Tage · 12 Credits')
|
||||
->assertSee('7 Tage für 12 Credits buchen')
|
||||
->assertSee('Veröffentlichungsnachweis')
|
||||
->assertSee('Für 3 Credits kaufen');
|
||||
});
|
||||
|
||||
test('add-on buttons only debit after the purchase confirmation modal', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
$this->wallet->credit($customer, 40);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
$component = LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->call('confirmBoost', 14)
|
||||
->assertSet('pendingPurchase', [
|
||||
'type' => 'boost',
|
||||
'label' => 'Boost — 14 Tage Platzierung',
|
||||
'credits' => 20,
|
||||
'days' => 14,
|
||||
])
|
||||
->assertSee('Kauf bestätigen')
|
||||
->assertSee('Kostenpflichtig buchen');
|
||||
|
||||
// Der Klick auf die Laufzeit selbst bucht noch nichts ab.
|
||||
expect($customer->fresh()->creditBalance())->toBe(40);
|
||||
expect($pr->fresh()->isBoosted())->toBeFalse();
|
||||
|
||||
$component->call('buyPendingAddOn')
|
||||
->assertSet('pendingPurchase', null);
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(20);
|
||||
expect($pr->fresh()->isBoosted())->toBeTrue();
|
||||
});
|
||||
|
||||
test('the proof purchase runs through the confirmation modal as well', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
$this->wallet->credit($customer, 10);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->call('confirmProof')
|
||||
->assertSet('pendingPurchase.type', 'proof')
|
||||
->assertSet('pendingPurchase.credits', 3)
|
||||
->call('buyPendingAddOn')
|
||||
->assertSee('Nachweis herunterladen');
|
||||
|
||||
expect(app(ProofPdfService::class)->hasPurchased($customer->fresh(), $pr))->toBeTrue();
|
||||
expect($customer->fresh()->creditBalance())->toBe(7);
|
||||
});
|
||||
|
||||
test('an unknown boost duration does not open the confirmation modal', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
$this->wallet->credit($customer, 40);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->call('confirmBoost', 999)
|
||||
->assertSet('pendingPurchase', null)
|
||||
->call('buyPendingAddOn');
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(40); // nichts abgebucht
|
||||
});
|
||||
|
||||
test('booking a boost from the detail page debits the wallet and activates it', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue