User Panel: Phase-8-Abschluss, Titelbild/Lizenzen/Zeitzonen und KI-Pruef-Pipeline

Phase 8 (Rest) + Umbauten vom 10./11.06.:
- Ein Titelbild pro PM (Cover 1280x580), SVG-Platzhalter-Set + Picker,
  PressReleaseCoverImage-Resolver
- Lizenz-/Rechteformular nach "Lizenztyp Bildupload" (7 Lizenztypen,
  Personen-/Sachrechte-Status, bedingte Pflichtfelder, Risikohinweise)
- Veroeffentlichungs-Box vereinfacht (Embargo aus der Form-UI entfernt),
  geplante Termine in Europe/Berlin (Speicherung UTC, DISPLAY_TIMEZONE)
- Quota-Stub (users.press_release_quota) + monatlicher Reset-Command
- Einreichungs-Modal einheitlich in Show/Create/Edit; Ghost-Buttons auf
  filled; PM-Editor-Layout responsive entkoppelt (.pr-editor-layout)

KI-Pruef-Pipeline (Phasen 1-5 des Entwicklungsplans):
- API-Haertung: status nicht mehr per API setzbar, eigene Submit-Route
  durch denselben Funnel (Blacklist, Quota, Status-Log)
- Klassifikation Rot/Gelb/Gruen asynchron (Queue classification,
  OpenAI-Treiber + deterministischer Fallback), ki_audits-Audit-Log
- Routing: Rot -> rejected + Mail, Gelb -> Review-Queue, Gruen ->
  Auto-Publish; Scheduler publiziert nur gruene faellige PMs
- Content-Score 0-100 -> Stufe (Standard/Geprueft/Hochwertig) inkl.
  Editor-Panel und Badges; Re-Klassifikation/-Score bei Aenderung
- Admin: KI-Badge + Filter, On-Demand-Pruefung mit Anbieter-Override

Suite: 442 passed, 4 skipped.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-06-12 08:30:13 +00:00
parent 0efabaf446
commit a000238ca8
141 changed files with 5922 additions and 1001 deletions

View file

@ -0,0 +1,101 @@
<?php
use App\Enums\PressReleaseClassification;
use App\Enums\PressReleaseStatus;
use App\Jobs\ClassifyPressRelease;
use App\Jobs\ScorePressRelease;
use App\Models\PressRelease;
use App\Models\User;
use App\Services\PressRelease\Classification\ClassificationManager;
use App\Services\PressRelease\PressReleaseService;
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);
$admin = User::factory()->create(['is_active' => true]);
$admin->assignRole('admin');
$this->actingAs($admin);
});
test('admin editor exposes the KI check button and modal', function () {
/** @var TestCase $this */
$pressRelease = PressRelease::factory()->create(['status' => PressReleaseStatus::Review->value]);
LivewireVolt::test('admin.press-releases.edit', ['id' => $pressRelease->id])
->assertSee('Prüfung')
->assertSee('Prüfung im Hintergrund starten');
});
test('runKiCheck dispatches a non-routing classification job with provider override', function () {
/** @var TestCase $this */
Queue::fake();
$pressRelease = PressRelease::factory()->create(['status' => PressReleaseStatus::Review->value]);
LivewireVolt::test('admin.press-releases.edit', ['id' => $pressRelease->id])
->set('kiProvider', 'deterministic')
->call('runKiCheck')
->assertHasNoErrors();
Queue::assertPushedOn('classification', ClassifyPressRelease::class, function (ClassifyPressRelease $job) use ($pressRelease) {
return $job->pressReleaseId === $pressRelease->id
&& $job->route === false
&& $job->providerOverride === 'deterministic';
});
});
test('runKiCheck dispatches a scoring job when content score is selected', function () {
/** @var TestCase $this */
Queue::fake();
$pressRelease = PressRelease::factory()->create(['status' => PressReleaseStatus::Review->value]);
LivewireVolt::test('admin.press-releases.edit', ['id' => $pressRelease->id])
->set('kiRunClassification', false)
->set('kiRunContentScore', true)
->call('runKiCheck')
->assertHasNoErrors();
Queue::assertPushed(ScorePressRelease::class, fn (ScorePressRelease $job) => $job->pressReleaseId === $pressRelease->id);
Queue::assertNotPushed(ClassifyPressRelease::class);
});
test('runKiCheck does nothing when no check is selected', function () {
/** @var TestCase $this */
Queue::fake();
$pressRelease = PressRelease::factory()->create(['status' => PressReleaseStatus::Review->value]);
LivewireVolt::test('admin.press-releases.edit', ['id' => $pressRelease->id])
->set('kiRunClassification', false)
->call('runKiCheck')
->assertHasNoErrors();
Queue::assertNothingPushed();
});
test('a non-routing classification job updates the verdict but leaves the status unchanged', function () {
/** @var TestCase $this */
config()->set('scoring.classification.provider', 'deterministic');
config()->set('blacklist.words', ['penis']);
// Rote Einstufung, aber als Re-Check ohne Routing: Status bleibt published.
$pressRelease = PressRelease::factory()->published()->create([
'title' => 'Titel penis',
'text' => 'Inhalt',
]);
(new ClassifyPressRelease($pressRelease->id, route: false))->handle(
app(ClassificationManager::class),
app(PressReleaseService::class),
);
$fresh = $pressRelease->fresh();
expect($fresh->classification)->toBe(PressReleaseClassification::Red);
expect($fresh->status)->toBe(PressReleaseStatus::Published);
});

View file

@ -22,7 +22,7 @@ function makeAdmin(): User
return $admin;
}
test('admin create form persistiert scheduled_at und embargo_at', function () {
test('admin create form persistiert scheduled_at aus datum und uhrzeit ohne embargo', function () {
/** @var TestCase $this */
Carbon::setTestNow('2026-06-01 10:00:00');
@ -38,7 +38,8 @@ test('admin create form persistiert scheduled_at und embargo_at', function () {
->set('categoryId', $category->id)
->set('portal', $company->portal->value)
->set('publishMode', 'scheduled')
->set('scheduledAt', '2026-06-05T14:30')
->set('scheduledDate', '2026-06-05')
->set('scheduledTime', '14:30')
->set('useEmbargo', true)
->set('embargoAt', '2026-06-10T08:00')
->call('save')
@ -46,8 +47,11 @@ test('admin create form persistiert scheduled_at und embargo_at', function () {
$pr = PressRelease::query()->latest('id')->firstOrFail();
expect($pr->scheduled_at?->toDateTimeString())->toBe('2026-06-05 14:30:00');
expect($pr->embargo_at?->toDateTimeString())->toBe('2026-06-10 08:00:00');
// Eingabe 14:30 erfolgt in Europe/Berlin (CEST, +02:00) und wird als
// 12:30 UTC gespeichert.
expect($pr->scheduled_at?->toDateTimeString())->toBe('2026-06-05 12:30:00');
expect($pr->scheduled_at?->copy()->setTimezone('Europe/Berlin')->format('Y-m-d H:i'))->toBe('2026-06-05 14:30');
expect($pr->embargo_at)->toBeNull();
});
test('admin create form lehnt scheduled_at in der Vergangenheit ab', function () {
@ -71,7 +75,7 @@ test('admin create form lehnt scheduled_at in der Vergangenheit ab', function ()
->assertHasErrors(['scheduledAt']);
});
test('admin edit hydriert scheduled_at und embargo_at', function () {
test('admin edit hydriert scheduled_at in datum und uhrzeit ohne embargo', function () {
/** @var TestCase $this */
Carbon::setTestNow('2026-06-01 10:00:00');
@ -79,18 +83,22 @@ test('admin edit hydriert scheduled_at und embargo_at', function () {
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'scheduled_at' => '2026-06-05 14:30:00',
// 12:30 UTC entspricht 14:30 in Europe/Berlin (CEST) so wird der
// Termin in den Eingabefeldern angezeigt.
'scheduled_at' => '2026-06-05 12:30:00',
'embargo_at' => '2026-06-10 08:00:00',
]);
LivewireVolt::test('admin.press-releases.edit', ['id' => $pr->id])
->assertSet('publishMode', 'scheduled')
->assertSet('scheduledAt', '2026-06-05T14:30')
->assertSet('useEmbargo', true)
->assertSet('embargoAt', '2026-06-10T08:00');
->assertSet('scheduledDate', '2026-06-05')
->assertSet('scheduledTime', '14:30')
->assertSet('useEmbargo', false)
->assertSet('embargoAt', null);
});
test('admin edit persistiert scheduled_at und embargo_at', function () {
test('admin edit persistiert scheduled_at aus datum und uhrzeit ohne embargo', function () {
/** @var TestCase $this */
Carbon::setTestNow('2026-06-01 10:00:00');
@ -104,7 +112,8 @@ test('admin edit persistiert scheduled_at und embargo_at', function () {
LivewireVolt::test('admin.press-releases.edit', ['id' => $pr->id])
->set('publishMode', 'scheduled')
->set('scheduledAt', '2026-06-08T09:00')
->set('scheduledDate', '2026-06-08')
->set('scheduledTime', '09:00')
->set('useEmbargo', true)
->set('embargoAt', '2026-06-12T12:00')
->call('save')
@ -112,8 +121,9 @@ test('admin edit persistiert scheduled_at und embargo_at', function () {
$pr->refresh();
expect($pr->scheduled_at?->toDateTimeString())->toBe('2026-06-08 09:00:00');
expect($pr->embargo_at?->toDateTimeString())->toBe('2026-06-12 12:00:00');
// Eingabe 09:00 in Europe/Berlin (CEST, +02:00) wird als 07:00 UTC gespeichert.
expect($pr->scheduled_at?->toDateTimeString())->toBe('2026-06-08 07:00:00');
expect($pr->embargo_at)->toBeNull();
});
test('admin publishMode now clears scheduled_at on save', function () {

View file

@ -91,9 +91,10 @@ test('admin show zeigt Scheduling-Termin im Review-Workflow', function () {
'scheduled_at' => '2026-06-15 10:00:00',
]);
// 10:00 UTC wird in Europe/Berlin (CEST, +02:00) als 12:00 angezeigt.
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Geplante Veröffentlichung')
->assertSee('15.06.2026 10:00');
->assertSee('15.06.2026 12:00');
});
test('admin show zeigt Embargo-Info im Published-Workflow', function () {