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:
parent
0efabaf446
commit
a000238ca8
141 changed files with 5922 additions and 1001 deletions
101
tests/Feature/Admin/AdminKiCheckTest.php
Normal file
101
tests/Feature/Admin/AdminKiCheckTest.php
Normal 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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue