Veroeffentlichungs-Gate: proaktive Buchungs-Meldung + Schalter test-stabil
- PM-Detailseite (Entwurf/Ueberarbeiten): ist kein Buchungs-Gate erfuellt,
erscheint statt 'Zur Pruefung einreichen' der Hinweis 'Noch keine Buchung'
mit Link zur Buchungsseite ('Buchung waehlen'). Entwurf speichern bleibt frei.
- phpunit pinnt BILLING_ENFORCE_BOOKING=false, damit der Gate in Tests
deterministisch bleibt (Tests, die ihn brauchen, setzen ihn per config)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3c6190099f
commit
44b676116e
3 changed files with 115 additions and 17 deletions
|
|
@ -36,5 +36,6 @@
|
|||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="TELESCOPE_ENABLED" value="false"/>
|
||||
<env name="BASIC_AUTH_ENABLED" value="false"/>
|
||||
<env name="BILLING_ENFORCE_BOOKING" value="false" force="true"/>
|
||||
</php>
|
||||
</phpunit>
|
||||
|
|
|
|||
|
|
@ -183,6 +183,9 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends
|
|||
'quotaRemaining' => $user->pressReleaseQuotaRemaining(),
|
||||
'canEdit' => auth()->user()->can('update', $pr)
|
||||
&& in_array($pr->status->value, ['draft', 'rejected']),
|
||||
// Einreichen zur Prüfung ist hinter eine bezahlte Buchung gegated
|
||||
// (Decision-Update §5.1, Schalter billing.enforce_booking).
|
||||
'hasActiveBooking' => $user->hasActiveBooking(),
|
||||
'latestRejection' => $latestRejection,
|
||||
'contacts' => $pr->contacts,
|
||||
'statusLogs' => $pr->statusLogs,
|
||||
|
|
@ -378,23 +381,44 @@ new #[Layout('components.layouts.app'), Title('Pressemitteilung')] class extends
|
|||
{{ $pr->status === PressReleaseStatus::Rejected ? __('Überarbeiten') : __('Entwurf') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="p-5 flex flex-wrap items-center gap-3">
|
||||
<p class="text-[13px] text-[color:var(--color-ink-2)] m-0 flex-1 min-w-[220px]">
|
||||
{{ $pr->status === PressReleaseStatus::Rejected
|
||||
? __('Sie können den Text bearbeiten und erneut zur Prüfung einreichen.')
|
||||
: __('Reichen Sie den Entwurf ein, sobald er vollständig ist.') }}
|
||||
</p>
|
||||
<div class="flex items-center gap-2 flex-shrink-0 flex-wrap">
|
||||
@if ($canEdit)
|
||||
<flux:button variant="filled" icon="pencil" href="{{ route('me.press-releases.edit', $pr->id) }}" wire:navigate>
|
||||
{{ __('Bearbeiten') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
<flux:modal.trigger name="confirm-submit-review">
|
||||
<flux:button type="button" variant="primary">
|
||||
{{ $pr->status === PressReleaseStatus::Rejected ? __('Erneut einreichen') : __('Zur Prüfung einreichen') }}
|
||||
</flux:button>
|
||||
</flux:modal.trigger>
|
||||
<div class="p-5 space-y-4">
|
||||
@unless ($hasActiveBooking)
|
||||
{{-- Veröffentlichungs-Gate: Einreichen zur Prüfung setzt eine
|
||||
bezahlte Option voraus. Speichern als Entwurf bleibt frei. --}}
|
||||
<div class="px-4 py-3 rounded-[5px] border text-[13px] flex items-start gap-3
|
||||
bg-[color:var(--color-warn-soft)] border-[color:var(--color-warn)]/30 text-[color:var(--color-ink-2)]">
|
||||
<flux:icon.lock-closed class="size-[16px] flex-shrink-0 mt-0.5 text-[color:var(--color-accent-deep)]" />
|
||||
<div class="flex-1">
|
||||
<span class="font-semibold text-[color:var(--color-ink)]">{{ __('Noch keine Buchung.') }}</span>
|
||||
{{ __('Den Entwurf können Sie frei speichern. Zum Einreichen und Veröffentlichen benötigen Sie eine bezahlte Option (Tarif, Einzel-PM oder Extra-PM aus Guthaben).') }}
|
||||
</div>
|
||||
</div>
|
||||
@endunless
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<p class="text-[13px] text-[color:var(--color-ink-2)] m-0 flex-1 min-w-[220px]">
|
||||
{{ $pr->status === PressReleaseStatus::Rejected
|
||||
? __('Sie können den Text bearbeiten und erneut zur Prüfung einreichen.')
|
||||
: __('Reichen Sie den Entwurf ein, sobald er vollständig ist.') }}
|
||||
</p>
|
||||
<div class="flex items-center gap-2 flex-shrink-0 flex-wrap">
|
||||
@if ($canEdit)
|
||||
<flux:button variant="filled" icon="pencil" href="{{ route('me.press-releases.edit', $pr->id) }}" wire:navigate>
|
||||
{{ __('Bearbeiten') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
@if ($hasActiveBooking)
|
||||
<flux:modal.trigger name="confirm-submit-review">
|
||||
<flux:button type="button" variant="primary">
|
||||
{{ $pr->status === PressReleaseStatus::Rejected ? __('Erneut einreichen') : __('Zur Prüfung einreichen') }}
|
||||
</flux:button>
|
||||
</flux:modal.trigger>
|
||||
@else
|
||||
<flux:button variant="primary" icon="credit-card" href="{{ route('me.bookings.index') }}" wire:navigate>
|
||||
{{ __('Buchung wählen') }}
|
||||
</flux:button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
|
|
|||
73
tests/Feature/PressReleaseBookingGateTest.php
Normal file
73
tests/Feature/PressReleaseBookingGateTest.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\SinglePurchase;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Livewire\Volt\Volt as LivewireVolt;
|
||||
use Tests\TestCase;
|
||||
|
||||
beforeEach(function (): void {
|
||||
/** @var TestCase $this */
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
});
|
||||
|
||||
function draftForGate(): array
|
||||
{
|
||||
$customer = User::factory()->create(['is_active' => true]);
|
||||
$customer->assignRole('customer');
|
||||
|
||||
$company = Company::factory()->presseecho()->create();
|
||||
$customer->companies()->attach($company->id, ['role' => 'owner']);
|
||||
|
||||
$pr = PressRelease::factory()->create([
|
||||
'user_id' => $customer->id,
|
||||
'company_id' => $company->id,
|
||||
'category_id' => Category::factory()->create()->id,
|
||||
'portal' => $company->portal->value,
|
||||
'status' => 'draft',
|
||||
]);
|
||||
|
||||
return compact('customer', 'pr');
|
||||
}
|
||||
|
||||
test('with the gate on a draft without a booking shows the notice and links to bookings', function () {
|
||||
/** @var TestCase $this */
|
||||
config()->set('billing.enforce_booking', true);
|
||||
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->assertSee('Noch keine Buchung')
|
||||
->assertSee('Buchung wählen')
|
||||
->assertSee(route('me.bookings.index'), false)
|
||||
->assertDontSee('Zur Prüfung einreichen');
|
||||
});
|
||||
|
||||
test('with the gate on a paid single purchase unlocks the submission action', function () {
|
||||
/** @var TestCase $this */
|
||||
config()->set('billing.enforce_booking', true);
|
||||
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
||||
SinglePurchase::factory()->paid()->create(['user_id' => $customer->id]);
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->assertDontSee('Noch keine Buchung')
|
||||
->assertSee('Zur Prüfung einreichen');
|
||||
});
|
||||
|
||||
test('with the gate off the notice never shows', function () {
|
||||
/** @var TestCase $this */
|
||||
config()->set('billing.enforce_booking', false);
|
||||
['customer' => $customer, 'pr' => $pr] = draftForGate();
|
||||
|
||||
$this->actingAs($customer);
|
||||
|
||||
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
||||
->assertDontSee('Noch keine Buchung')
|
||||
->assertSee('Zur Prüfung einreichen');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue