presseportale/tests/Feature/PressReleaseShowPhase8aTest.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

170 lines
5.8 KiB
PHP

<?php
use App\Enums\PressReleaseStatus;
use App\Models\Category;
use App\Models\Company;
use App\Models\Contact;
use App\Models\PressRelease;
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);
});
/**
* @return array{customer: User, company: Company, contact: Contact, category: Category, pr: PressRelease}
*/
function makeCustomerForShowPhase8a(array $prAttributes = []): array
{
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
$contact = Contact::factory()->for($company)->create([
'portal' => $company->portal->value,
]);
$category = Category::factory()->create();
$pr = PressRelease::factory()->create(array_merge([
'user_id' => $customer->id,
'company_id' => $company->id,
'category_id' => $category->id,
'portal' => $company->portal->value,
'status' => 'draft',
], $prAttributes));
$pr->contacts()->sync([$contact->id]);
return compact('customer', 'company', 'contact', 'category', 'pr');
}
function makeAdminForShowPhase8a(): User
{
$admin = User::factory()->create(['is_active' => true]);
$admin->assignRole('admin');
return $admin;
}
test('customer show zeigt den Untertitel direkt unter dem Titel', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'title' => 'Brauerei eröffnet zweiten Standort',
'subtitle' => 'Ein Untertitel der Pressemitteilung',
]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Brauerei eröffnet zweiten Standort')
->assertSee('Ein Untertitel der Pressemitteilung');
});
test('customer show zeigt geplante Veröffentlichung wenn gesetzt', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'status' => PressReleaseStatus::Review->value,
'scheduled_at' => '2026-07-01 09:30:00',
]);
$this->actingAs($customer);
// 09:30 UTC wird in Europe/Berlin (CEST, +02:00) als 11:30 angezeigt.
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Geplante Veröffentlichung')
->assertSee('01.07.2026 11:30');
});
test('customer show zeigt Sperrfrist wenn embargo_at gesetzt', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'status' => PressReleaseStatus::Published->value,
'embargo_at' => '2026-08-15 12:00:00',
]);
$this->actingAs($customer);
// 12:00 UTC wird in Europe/Berlin (CEST, +02:00) als 14:00 angezeigt.
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Sperrfrist bis')
->assertSee('15.08.2026 14:00');
});
test('customer show zeigt Kein-Export-Hinweis wenn no_export aktiv', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'no_export' => true,
]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Kein Export aktiv');
});
test('customer show zeigt Boilerplate-Override als eigene Card', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'boilerplate_override' => 'Über die Beispiel AG: Wir machen Bier seit 1850.',
]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertSee('Eigener Abbinder (Boilerplate)')
->assertSee('Über die Beispiel AG: Wir machen Bier seit 1850.');
});
test('customer show zeigt Boilerplate-Override nicht wenn leer', function () {
/** @var TestCase $this */
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
'boilerplate_override' => null,
]);
$this->actingAs($customer);
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
->assertDontSee('Eigener Abbinder (Boilerplate)');
});
test('admin show zeigt den Untertitel direkt unter dem Titel', function () {
/** @var TestCase $this */
$admin = makeAdminForShowPhase8a();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'title' => 'Großer Auftritt der Brauerei',
'subtitle' => 'Pressekonferenz am Freitag',
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Großer Auftritt der Brauerei')
->assertSee('Pressekonferenz am Freitag');
});
test('admin show zeigt Boilerplate-Override als eigene Card', function () {
/** @var TestCase $this */
$admin = makeAdminForShowPhase8a();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'boilerplate_override' => 'Über das Beispiel-Unternehmen: Mehr Infos folgen.',
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Eigener Abbinder (Boilerplate)')
->assertSee('Über das Beispiel-Unternehmen: Mehr Infos folgen.');
});
test('admin show zeigt Boilerplate-Override nicht wenn leer', function () {
/** @var TestCase $this */
$admin = makeAdminForShowPhase8a();
$this->actingAs($admin);
$pr = PressRelease::factory()->create([
'boilerplate_override' => null,
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertDontSee('Eigener Abbinder (Boilerplate)');
});