Boost-Buchung invalidiert gecachte Start- und Branchenseiten sofort
Statt bis zu 300 s Cache-TTL zu warten, verwirft der BoostService nach der Buchung die Home-/Kategorie-Caches der betroffenen Ausgaben (inkl. Eltern-Rubrik) — die bezahlte Platzierung ist direkt sichtbar. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
cc61bf21d9
commit
6be387c9fb
2 changed files with 65 additions and 1 deletions
|
|
@ -1,10 +1,14 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Enums\PressReleaseClassification;
|
||||
use App\Models\Boost;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use App\Services\Billing\CreditWalletService;
|
||||
use App\Services\PressRelease\BoostService;
|
||||
use App\Services\Web\HomePageData;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
|
@ -44,6 +48,8 @@ function boostPlacementFixture(): array
|
|||
'title' => 'Geboostete aeltere Meldung',
|
||||
'slug' => 'geboostete-aeltere-meldung',
|
||||
'published_at' => now()->subDays(5),
|
||||
// Grün klassifiziert: Voraussetzung fürs Boost-Gate im BoostService.
|
||||
'classification' => PressReleaseClassification::Green->value,
|
||||
]);
|
||||
|
||||
return compact('category', 'company', 'newest', 'boosted');
|
||||
|
|
@ -82,6 +88,28 @@ test('an expired boost does not influence the homepage placement', function () {
|
|||
->assertDontSeeText('Top-Platzierung');
|
||||
});
|
||||
|
||||
test('booking a boost invalidates the cached start and category pages immediately', function () {
|
||||
/** @var TestCase $this */
|
||||
['boosted' => $boosted, 'newest' => $newest] = boostPlacementFixture();
|
||||
|
||||
$owner = User::factory()->create(['is_active' => true]);
|
||||
app(CreditWalletService::class)->credit($owner, 40);
|
||||
|
||||
// Beide Seiten in den Cache legen — noch ohne Boost.
|
||||
expect(app(HomePageData::class)->build(Portal::Presseecho)['leadRelease']->id)->toBe($newest->id);
|
||||
$this->get('https://presseecho.test/de/category/energie-klima')
|
||||
->assertSuccessful()
|
||||
->assertDontSeeText('Top-Platzierung');
|
||||
|
||||
app(BoostService::class)->boost($owner, $boosted, 7);
|
||||
|
||||
// Kein Warten auf die TTL: die Buchung verwirft die gecachten Seiten.
|
||||
expect(app(HomePageData::class)->build(Portal::Presseecho)['leadRelease']->id)->toBe($boosted->id);
|
||||
$this->get('https://presseecho.test/de/category/energie-klima')
|
||||
->assertSuccessful()
|
||||
->assertSeeText('Top-Platzierung');
|
||||
});
|
||||
|
||||
test('a boosted release leads its category page and is labelled', function () {
|
||||
/** @var TestCase $this */
|
||||
['boosted' => $boosted] = boostPlacementFixture();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue