Boost-Slot-Grenzen (5/3) + Kategorie-Boost zum halben Satz
Entscheidung 13.07.: verkauft wird nur, was sichtbar ist — max. 5 gleichzeitige Boosts je Startseite, 3 je Branchenseite (= die sichtbaren Plaetze; Hero-Slider damit vertagt). Neue Stufe Kategorie-Boost (nur Branchenseite, 6/10/18 Credits = 50 % aufgerundet); der Startseiten-Boost (12/20/35) erscheint weiter auf Start- UND Branchenseite. - boosts.placement (home/category, Bestand = home) + BoostPlacement-Enum; Preise/Slots in config/credits.php (boost_category, boost_slots) - BoostService::slotAvailability() je Ausgabe (Portal x Sprache, Kategorie zusaetzlich je Rubrik); ausgebucht -> soldOut-Exception mit fruehestem freien Termin; Verlaengerungen halten ihren Slot, Stufen verlaengern unabhaengig; Kategorie-Boost invalidiert nur Kategorie-Caches - Startseite zeigt nur Home-Boosts; Branchenseite: Kategorie-Boosts mit Vorrang (ihre 3 Slots sind die Garantie), Home-Boosts fuellen den Rest - Add-on-Panel der PM-Seite: zwei Boost-Angebote, bei vollem Inventar "Derzeit ausgebucht — frei ab" statt Kauf-Buttons (serverseitig gegated); Buchungsseiten-Preisliste um die Kategorie-Staffel ergaenzt Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
b1be14e1b3
commit
4853d48b83
19 changed files with 702 additions and 98 deletions
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\BoostPlacement;
|
||||
use App\Enums\PressReleaseClassification;
|
||||
use App\Models\Boost;
|
||||
use App\Models\Category;
|
||||
|
|
@ -8,6 +9,7 @@ use App\Models\PressRelease;
|
|||
use App\Models\User;
|
||||
use App\Services\Billing\CreditWalletService;
|
||||
use App\Services\Billing\ProofPdfService;
|
||||
use App\Services\PressRelease\BoostService;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
|
@ -49,8 +51,10 @@ 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('Startseiten-Boost')
|
||||
->assertSee('7 Tage für 12 Credits buchen')
|
||||
->assertSee('Kategorie-Boost')
|
||||
->assertSee('7 Tage für 6 Credits buchen')
|
||||
->assertSee('Veröffentlichungsnachweis')
|
||||
->assertSee('Für 3 Credits kaufen');
|
||||
});
|
||||
|
|
@ -66,7 +70,8 @@ test('add-on buttons only debit after the purchase confirmation modal', function
|
|||
->call('confirmBoost', 14)
|
||||
->assertSet('pendingPurchase', [
|
||||
'type' => 'boost',
|
||||
'label' => 'Boost — 14 Tage Platzierung',
|
||||
'placement' => 'home',
|
||||
'label' => 'Startseiten-Boost — 14 Tage',
|
||||
'credits' => 20,
|
||||
'days' => 14,
|
||||
'extendsUntil' => null,
|
||||
|
|
@ -160,6 +165,57 @@ test('booking a boost from the detail page debits the wallet and activates it',
|
|||
expect($pr->fresh()->isBoosted())->toBeTrue();
|
||||
});
|
||||
|
||||
test('a category boost books through the confirmation modal at the half staffel', 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('confirmBoost', 7, 'category')
|
||||
->assertSet('pendingPurchase.placement', 'category')
|
||||
->assertSet('pendingPurchase.label', 'Kategorie-Boost — 7 Tage')
|
||||
->assertSet('pendingPurchase.credits', 6)
|
||||
->set('purchaseConfirmed', true)
|
||||
->call('buyPendingAddOn');
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(4); // 10 - 6 (7 Tage, halber Satz)
|
||||
expect(app(BoostService::class)->isBoosted($pr->fresh(), BoostPlacement::Category))->toBeTrue();
|
||||
expect(app(BoostService::class)->isBoosted($pr->fresh(), BoostPlacement::Home))->toBeFalse();
|
||||
});
|
||||
|
||||
test('sold-out slots replace the buy buttons with the next free date', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
$this->wallet->credit($customer, 40);
|
||||
|
||||
// Alle 5 Startseiten-Slots der Ausgabe belegt (fremde PMs, gleiche Ausgabe).
|
||||
$freeAt = now()->addDays(2);
|
||||
foreach (range(1, 5) as $i) {
|
||||
$other = PressRelease::factory()->published()->create([
|
||||
'portal' => $pr->portal->value,
|
||||
'classification' => PressReleaseClassification::Green->value,
|
||||
]);
|
||||
Boost::factory()->for($other)->create(['ends_at' => $freeAt->copy()->addDays($i - 1)]);
|
||||
}
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->assertSee('Derzeit ausgebucht — der nächste Platz wird am '.$freeAt->format('d.m.Y').' frei.')
|
||||
->assertDontSee('7 Tage für 12 Credits buchen')
|
||||
// Der Kategorie-Boost hat ein eigenes Slot-Inventar und bleibt buchbar.
|
||||
->assertSee('7 Tage für 6 Credits buchen');
|
||||
|
||||
// Serverseitiges Gate: ein direkter Kauf-Call bucht trotzdem nicht.
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->call('buyBoost', 7);
|
||||
|
||||
expect($customer->fresh()->creditBalance())->toBe(40);
|
||||
expect($pr->fresh()->isBoosted())->toBeFalse();
|
||||
});
|
||||
|
||||
test('buying a proof from the detail page unlocks the download', function () {
|
||||
/** @var TestCase $this */
|
||||
['customer' => $customer, 'pr' => $pr] = publishedGreenPrForOwner();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue