presseportale/tests/Feature/Admin/AdminPressReleaseShowTest.php
Kevin Adametz a000238ca8 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>
2026-06-12 08:30:13 +00:00

125 lines
4 KiB
PHP

<?php
use App\Enums\PressReleaseStatus;
use App\Models\Company;
use App\Models\Contact;
use App\Models\PressRelease;
use App\Models\PressReleaseStatusLog;
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 makeAdminForShow(): User
{
$admin = User::factory()->create(['is_active' => true]);
$admin->assignRole('admin');
return $admin;
}
test('admin show rendert Rejection-Banner mit letzter Begründung', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'status' => PressReleaseStatus::Rejected->value,
]);
PressReleaseStatusLog::query()->create([
'press_release_id' => $pr->id,
'changed_by_user_id' => $admin->id,
'from_status' => PressReleaseStatus::Review->value,
'to_status' => PressReleaseStatus::Rejected->value,
'reason' => 'Werbliche Sprache, bitte überarbeiten.',
'source' => 'admin',
'created_at' => now(),
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Diese Pressemitteilung wurde abgelehnt')
->assertSee('Werbliche Sprache, bitte überarbeiten.');
});
test('admin show zeigt zugeordnete Pressekontakte', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$company = Company::factory()->presseecho()->create();
$contact = Contact::factory()->for($company)->create([
'first_name' => 'Max',
'last_name' => 'Mustermann',
'responsibility' => 'Pressesprecher',
'email' => 'presse@example.test',
'portal' => $company->portal->value,
]);
$pr = PressRelease::factory()->create(['company_id' => $company->id]);
$pr->contacts()->sync([$contact->id]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Zugeordnete Pressekontakte')
->assertSee('Max Mustermann')
->assertSee('Pressesprecher')
->assertSee('presse@example.test');
});
test('admin show zeigt Hinweis bei fehlenden Kontakten', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$pr = PressRelease::factory()->create();
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Dieser Pressemitteilung ist kein Pressekontakt zugeordnet.');
});
test('admin show zeigt Scheduling-Termin im Review-Workflow', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'status' => PressReleaseStatus::Review->value,
'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 12:00');
});
test('admin show zeigt Embargo-Info im Published-Workflow', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'status' => PressReleaseStatus::Published->value,
'published_at' => '2026-06-01 10:00:00',
'embargo_at' => now()->addDays(10),
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Sperrfrist bis');
});
test('admin show zeigt Autor im Status-Verlauf-Grid', function () {
/** @var TestCase $this */
$admin = makeAdminForShow();
$this->actingAs($admin);
$author = User::factory()->create(['name' => 'Anna Autorin']);
$pr = PressRelease::factory()->create(['user_id' => $author->id]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Anna Autorin');
});