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>
94 lines
3.3 KiB
PHP
94 lines
3.3 KiB
PHP
<?php
|
||
|
||
use App\Enums\PressReleaseClassification;
|
||
use App\Enums\PressReleaseStatus;
|
||
use App\Jobs\ClassifyPressRelease;
|
||
use App\Models\Category;
|
||
use App\Models\Company;
|
||
use App\Models\PressRelease;
|
||
use App\Models\User;
|
||
use App\Services\PressRelease\PressReleaseService;
|
||
use Illuminate\Support\Facades\Queue;
|
||
use Laravel\Sanctum\Sanctum;
|
||
use Tests\TestCase;
|
||
|
||
test('reclassifyIfClassified dispatches a non-routing job for an already classified press release', function () {
|
||
Queue::fake();
|
||
|
||
$pressRelease = PressRelease::factory()->create([
|
||
'classification' => PressReleaseClassification::Green->value,
|
||
'status' => PressReleaseStatus::Published->value,
|
||
]);
|
||
|
||
app(PressReleaseService::class)->reclassifyIfClassified($pressRelease);
|
||
|
||
Queue::assertPushedOn('classification', ClassifyPressRelease::class, function (ClassifyPressRelease $job) use ($pressRelease) {
|
||
return $job->pressReleaseId === $pressRelease->id && $job->route === false;
|
||
});
|
||
});
|
||
|
||
test('reclassifyIfClassified does nothing for a never-classified press release', function () {
|
||
Queue::fake();
|
||
|
||
$pressRelease = PressRelease::factory()->create(['classification' => null]);
|
||
|
||
app(PressReleaseService::class)->reclassifyIfClassified($pressRelease);
|
||
|
||
Queue::assertNothingPushed();
|
||
});
|
||
|
||
test('api update of a classified press release re-classifies when the content changes', function () {
|
||
/** @var TestCase $this */
|
||
Queue::fake();
|
||
|
||
$user = User::factory()->create();
|
||
$company = Company::factory()->presseecho()->create();
|
||
$category = Category::factory()->withTranslations()->create();
|
||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||
|
||
$pressRelease = PressRelease::factory()->create([
|
||
'user_id' => $user->id,
|
||
'company_id' => $company->id,
|
||
'category_id' => $category->id,
|
||
'portal' => $company->portal->value,
|
||
'status' => PressReleaseStatus::Draft->value,
|
||
'classification' => PressReleaseClassification::Green->value,
|
||
]);
|
||
|
||
Sanctum::actingAs($user, ['press-releases:write']);
|
||
|
||
$this->patchJson("/api/v1/press-releases/{$pressRelease->id}", [
|
||
'text' => 'Komplett neuer Inhalt, der erneut geprüft werden muss.',
|
||
])->assertOk();
|
||
|
||
Queue::assertPushed(ClassifyPressRelease::class, fn (ClassifyPressRelease $job) => $job->route === false);
|
||
});
|
||
|
||
test('api update does not re-classify when content is unchanged', function () {
|
||
/** @var TestCase $this */
|
||
Queue::fake();
|
||
|
||
$user = User::factory()->create();
|
||
$company = Company::factory()->presseecho()->create();
|
||
$category = Category::factory()->withTranslations()->create();
|
||
$user->companies()->attach($company->id, ['role' => 'owner']);
|
||
|
||
$pressRelease = PressRelease::factory()->create([
|
||
'user_id' => $user->id,
|
||
'company_id' => $company->id,
|
||
'category_id' => $category->id,
|
||
'portal' => $company->portal->value,
|
||
'status' => PressReleaseStatus::Draft->value,
|
||
'classification' => PressReleaseClassification::Green->value,
|
||
'keywords' => 'alt',
|
||
]);
|
||
|
||
Sanctum::actingAs($user, ['press-releases:write']);
|
||
|
||
// Nur Keywords ändern – kein Titel/Text → keine Neuklassifikation.
|
||
$this->patchJson("/api/v1/press-releases/{$pressRelease->id}", [
|
||
'keywords' => 'neu',
|
||
])->assertOk();
|
||
|
||
Queue::assertNothingPushed();
|
||
});
|