presseportale/tests/Feature/PressReleasePublishModalPhase8iTest.php
Kevin Adametz 2a46aed1a9 Einreichen-Modal: Panel-Struktur und fixierter Kontingent-Badge
Das Modal war ein unstrukturierter Stapel aus zwei Boxen und losen
Switches; der Kontingent-Badge wurde vom Flex-Layout zusammengedrückt
und brach um ("3 /" / "3"). Jetzt: drei beschriftete Panels (Rechtliche
Hinweise, PM-Kontingent, Ihre Bestätigungen) im portalweiten
panel/panel-head-Stil, die Switches als getrennte Zeilen mit
Fortschrittszähler (x / 4) im Panel-Kopf, Badge mit shrink-0 und
whitespace-nowrap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 14:16:56 +00:00

79 lines
3.2 KiB
PHP

<?php
use App\Enums\PressReleaseStatus;
use App\Models\Plan;
use Database\Seeders\RolesAndPermissionsSeeder;
use Illuminate\Support\Facades\Queue;
use Livewire\Volt\Volt as LivewireVolt;
use Tests\TestCase;
beforeEach(function (): void {
/** @var TestCase $this */
$this->seed(RolesAndPermissionsSeeder::class);
// Klassifikations-Job nicht inline ausführen, damit der Submit hier nur den
// Übergang nach „review" prüft (KI-Routing siehe ClassificationJobTest).
Queue::fake();
});
test('customer show renders the publish confirmation modal with legal note and quota', function () {
/** @var TestCase $this */
// Das Kontingent erscheint nur mit scharfem Launch-Schalter und Tarif —
// unbegrenzte User (Schalter aus, Bestandsschutz) sehen den Block nicht.
config()->set('billing.enforce_booking', true);
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
$customer->update(['press_release_quota_used_this_month' => 1]);
$plan = Plan::factory()->create([
'press_release_quota' => 3,
'stripe_price_id_monthly' => 'price_test_m_modal',
]);
subscribeUserToPlan($customer, $plan);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Pressemitteilung zur Prüfung einreichen')
->assertSee('Rechtliche Hinweise')
->assertSee('Mit dem Einreichen versichern Sie:')
->assertSee('PM-Kontingent diesen Monat')
->assertSee('2 / 3')
->assertSee('Ihre Bestätigungen');
});
test('the quota block is hidden for users with an unlimited quota', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
$this->actingAs($customer);
// Launch-Schalter aus → Kontingent unbegrenzt → kein Quota-Block.
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Pressemitteilung zur Prüfung einreichen')
->assertDontSee('PM-Kontingent diesen Monat');
});
test('submitting from the show modal moves the draft into review without consuming quota', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
$customer->update(['press_release_quota_used_this_month' => 0]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->call('submitForReview')
->assertHasNoErrors();
expect($pr->fresh()->status)->toBe(PressReleaseStatus::Review);
// Slot-Verbrauch erst bei Veröffentlichung (Decision-Update §3.2).
expect($customer->fresh()->press_release_quota_used_this_month)->toBe(0);
});
test('the modal shows a booking notice instead of the submit flow when the gate is enforced', function () {
/** @var TestCase $this */
config()->set('billing.enforce_booking', true);
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Buchung erforderlich')
->assertDontSee('Mit dem Einreichen versichern Sie:');
});