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

110 lines
4.2 KiB
PHP

<?php
use App\Enums\PressReleasePlaceholder;
use App\Models\PressRelease;
use App\Services\PressRelease\PressReleaseCoverImage;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Volt\Volt;
uses(RefreshDatabase::class);
test('placeholder set has eighteen variants and a stable default', function () {
expect(PressReleasePlaceholder::cases())->toHaveCount(18);
expect(PressReleasePlaceholder::default())->toBe(PressReleasePlaceholder::GridBlue);
});
test('invalid placeholder values fall back to the default', function () {
expect(PressReleasePlaceholder::fromValueOrDefault(null))->toBe(PressReleasePlaceholder::default());
expect(PressReleasePlaceholder::fromValueOrDefault('does-not-exist'))->toBe(PressReleasePlaceholder::default());
expect(PressReleasePlaceholder::fromValueOrDefault('05-lines-green'))->toBe(PressReleasePlaceholder::LinesGreen);
expect(PressReleasePlaceholder::fromValueOrDefault('17-signal-green'))->toBe(PressReleasePlaceholder::SignalGreen);
});
test('placeholder variant from a seed is deterministic', function () {
$first = PressReleasePlaceholder::fromSeed(4242);
$second = PressReleasePlaceholder::fromSeed(4242);
expect($first)->toBe($second);
});
test('every placeholder svg asset exists on disk', function () {
foreach (PressReleasePlaceholder::cases() as $variant) {
expect(public_path($variant->path()))->toBeFile();
}
});
test('press releases get a deterministic placeholder variant on creation', function () {
$pr = PressRelease::factory()->create(['placeholder_variant' => null]);
expect($pr->placeholder_variant)->toBeInstanceOf(PressReleasePlaceholder::class);
});
test('cover resolver falls back to the placeholder svg when no image exists', function () {
$pr = PressRelease::factory()->create(['placeholder_variant' => '05-lines-green']);
$cover = app(PressReleaseCoverImage::class);
expect($cover->coverIsPlaceholder($pr))->toBeTrue();
expect($cover->coverUrl($pr))->toContain('images/press-release-placeholders/05-lines-green.svg');
});
test('cover resolver prefers the real preview image over the placeholder', function () {
$pr = PressRelease::factory()->create(['placeholder_variant' => '01-grid-blue']);
$pr->images()->create([
'disk' => 'public',
'path' => 'press/cover.jpg',
'variants' => ['large' => 'press/cover-large.jpg'],
'is_preview' => true,
'sort_order' => 1,
]);
$cover = app(PressReleaseCoverImage::class);
expect($cover->coverIsPlaceholder($pr->fresh()))->toBeFalse();
expect($cover->coverUrl($pr->fresh()))->toContain('storage/press/cover-large.jpg');
});
test('cover resolver prefers the 1280x580 cover variant over large', function () {
$pr = PressRelease::factory()->create(['placeholder_variant' => '01-grid-blue']);
$pr->images()->create([
'disk' => 'public',
'path' => 'press/cover.jpg',
'variants' => [
'large' => 'press/cover-large.jpg',
'cover' => 'press/cover-cover.jpg',
],
'is_preview' => true,
'sort_order' => 1,
]);
$cover = app(PressReleaseCoverImage::class);
expect($cover->coverUrl($pr->fresh()))->toContain('storage/press/cover-cover.jpg');
});
test('cover resolver falls back from cover to large when cover variant is missing', function () {
$pr = PressRelease::factory()->create(['placeholder_variant' => '01-grid-blue']);
$pr->images()->create([
'disk' => 'public',
'path' => 'press/cover.jpg',
'variants' => ['large' => 'press/cover-large.jpg'],
'is_preview' => true,
'sort_order' => 1,
]);
$cover = app(PressReleaseCoverImage::class);
expect($cover->coverUrl($pr->fresh(), 'cover'))->toContain('storage/press/cover-large.jpg');
});
test('placeholder picker mounts with the current variant and confirms a selection', function () {
Volt::test('components.press-release-placeholder-picker', ['current' => '05-lines-green'])
->assertSet('selected', '05-lines-green')
->call('choose', '08-dots-green')
->assertSet('selected', '08-dots-green')
->call('confirm')
->assertDispatched('placeholder-selected', variant: '08-dots-green');
});