Automatische Pruefung je Meldung hoechstens max_automatic_attempts (3); das letzte Rot blockt statt abzulehnen: Meldung bleibt in review, Admin sieht sie unter "Pruefung noetig" mit allen KI-Begruendungen und entscheidet (Freischalten / Mit Kommentar zurueck). Danach ist die Automatik fuer diese Meldung aus - jede Freigabe geht direkt zum Menschen. Gelb: yellow_to_manual_queue wird jetzt ausgewertet (Vorgabe false). Kundenseite: "Zur Pruefung freigeben" mit Erklaerung der drei Schritte, Versuchszaehler an der Ablehnung, Hinweis auf menschliche Pruefung. Blade: inline @php(...) vor einem @php...@endphp-Block wird als Rohblock gelesen - vier Stellen auf Blockform umgestellt. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
117 lines
4.6 KiB
PHP
117 lines
4.6 KiB
PHP
<?php
|
|
|
|
use App\Enums\AiTextDeclaration;
|
|
use App\Enums\ImageLicenseType;
|
|
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 freigeben')
|
|
->assertSee('Rechtliche Hinweise')
|
|
->assertSee('Mit der Freigabe 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 freigeben')
|
|
->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])
|
|
// KI-Kennzeichnung (Art. 50 KI-VO) ist Pflicht im Submit-Modal.
|
|
->set('aiTextDeclaration', AiTextDeclaration::None->value)
|
|
->set('aiDeclarationConfirmed', true)
|
|
->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 image rights confirmation is hidden while only the placeholder is active', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Ihre Bestätigungen')
|
|
->assertDontSee('Alle Bildrechte sind geklärt.')
|
|
->assertSeeHtml("' / 4'");
|
|
});
|
|
|
|
test('the image rights confirmation appears once an own title image exists', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
|
|
|
|
$pr->images()->create([
|
|
'disk' => 'public',
|
|
'path' => 'press-releases/'.$pr->id.'/images/title.jpg',
|
|
'variants' => ['cover' => 'press-releases/'.$pr->id.'/images/title-cover.jpg'],
|
|
'author' => 'Jane Doe',
|
|
'license_type' => ImageLicenseType::Own->value,
|
|
'rights_confirmed_at' => now(),
|
|
'is_preview' => true,
|
|
'sort_order' => 1,
|
|
]);
|
|
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Alle Bildrechte sind geklärt.')
|
|
->assertSeeHtml("' / 5'");
|
|
});
|
|
|
|
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 der Freigabe versichern Sie:');
|
|
});
|