Add-on-Modal: Pflicht-Schalter + Verlaengerungs-Hinweis bei laufendem Boost
Kauf-Button bleibt deaktiviert, bis der Bestaetigungs-Schalter aktiv ist (serverseitig abgesichert). Laeuft bereits ein Boost, warnt das Modal, dass die Buchung die Laufzeit verlaengert, mit altem und neuem Enddatum. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
d5b806443e
commit
cc61bf21d9
2 changed files with 79 additions and 4 deletions
|
|
@ -69,6 +69,8 @@ test('add-on buttons only debit after the purchase confirmation modal', function
|
|||
'label' => 'Boost — 14 Tage Platzierung',
|
||||
'credits' => 20,
|
||||
'days' => 14,
|
||||
'extendsUntil' => null,
|
||||
'newEndsAt' => null,
|
||||
])
|
||||
->assertSee('Kauf bestätigen')
|
||||
->assertSee('Kostenpflichtig buchen');
|
||||
|
|
@ -77,13 +79,39 @@ test('add-on buttons only debit after the purchase confirmation modal', function
|
|||
expect($customer->fresh()->creditBalance())->toBe(40);
|
||||
expect($pr->fresh()->isBoosted())->toBeFalse();
|
||||
|
||||
// Ohne den Pflicht-Schalter bleibt der Kauf aus und das Modal offen.
|
||||
$component->call('buyPendingAddOn')
|
||||
->assertSet('pendingPurchase', null);
|
||||
->assertSet('pendingPurchase.type', 'boost');
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(40);
|
||||
expect($pr->fresh()->isBoosted())->toBeFalse();
|
||||
|
||||
$component->set('purchaseConfirmed', true)
|
||||
->call('buyPendingAddOn')
|
||||
->assertSet('pendingPurchase', null)
|
||||
->assertSet('purchaseConfirmed', false);
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(20);
|
||||
expect($pr->fresh()->isBoosted())->toBeTrue();
|
||||
});
|
||||
|
||||
test('the confirmation modal warns when the purchase extends a running boost', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
$this->wallet->credit($customer, 40);
|
||||
|
||||
$activeUntil = now()->addDays(3)->setTime(12, 0);
|
||||
Boost::factory()->for($pr)->for($customer)->create(['ends_at' => $activeUntil]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->call('confirmBoost', 7)
|
||||
->assertSet('pendingPurchase.extendsUntil', $activeUntil->format('d.m.Y H:i'))
|
||||
->assertSet('pendingPurchase.newEndsAt', $activeUntil->copy()->addDays(7)->format('d.m.Y H:i'))
|
||||
->assertSee('Diese Buchung verlängert den laufenden Boost.');
|
||||
});
|
||||
|
||||
test('the proof purchase runs through the confirmation modal as well', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
|
|
@ -95,6 +123,7 @@ test('the proof purchase runs through the confirmation modal as well', function
|
|||
->call('confirmProof')
|
||||
->assertSet('pendingPurchase.type', 'proof')
|
||||
->assertSet('pendingPurchase.credits', 3)
|
||||
->set('purchaseConfirmed', true)
|
||||
->call('buyPendingAddOn')
|
||||
->assertSee('Nachweis herunterladen');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue