- Neue Kachel "Inhaltspruefung" in Status & Verlauf (Badge je Ergebnis, "Ausstehend" ohne Pruefung); bei Gelb neutraler Hinweis, dass die Boost-Platzierung gruen gepruefte Meldungen voraussetzt - Content-Score-Panel des Editors in gemeinsame Komponente x-content-score-panel extrahiert und auf der Detailseite wiederverwendet (Score/100, Stufe, Abstand zur naechsten Schwelle) - PressReleaseClassification::badgeClass() (ok/warn/err) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
264 lines
9.5 KiB
PHP
264 lines
9.5 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use App\Enums\PressReleaseClassification;
|
|
use App\Enums\PressReleaseContentTier;
|
|
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);
|
|
|
|
// Die App läuft in Europe/Berlin; 09:30 wird unverändert angezeigt.
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Geplante Veröffentlichung')
|
|
->assertSee('01.07.2026 09: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);
|
|
|
|
// Die App läuft in Europe/Berlin; 12:00 wird unverändert angezeigt.
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Sperrfrist bis')
|
|
->assertSee('15.08.2026 12: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('customer show links to the public page of a published release', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
|
|
'status' => PressReleaseStatus::Published,
|
|
'published_at' => now()->subHour(),
|
|
'slug' => 'oeffentliche-pm',
|
|
'language' => 'de',
|
|
]);
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Öffentlich ansehen')
|
|
->assertSee(config('domains.domain_presseecho_url').'/de/press-release/oeffentliche-pm', escape: false);
|
|
});
|
|
|
|
test('customer show links to both portals when the release is published on both', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
|
|
'status' => PressReleaseStatus::Published,
|
|
'published_at' => now()->subHour(),
|
|
'portal' => Portal::Both,
|
|
'slug' => 'beide-portale-pm',
|
|
'language' => 'de',
|
|
]);
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Auf Presseecho ansehen')
|
|
->assertSee('Auf Businessportal24 ansehen')
|
|
->assertSee(config('domains.domain_presseecho_url').'/de/press-release/beide-portale-pm', escape: false)
|
|
->assertSee(config('domains.domain_businessportal_url').'/de/press-release/beide-portale-pm', escape: false);
|
|
});
|
|
|
|
test('customer show shows no public link for drafts', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a();
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertDontSee('Öffentlich ansehen');
|
|
});
|
|
|
|
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)');
|
|
});
|
|
|
|
test('customer show zeigt das Pruefergebnis und den Qualitaets-Score', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
|
|
'status' => PressReleaseStatus::Published->value,
|
|
'published_at' => now(),
|
|
'classification' => PressReleaseClassification::Green->value,
|
|
'content_score' => 87,
|
|
'content_tier' => PressReleaseContentTier::Hochwertig->value,
|
|
]);
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Inhaltsprüfung')
|
|
->assertSee('Grün')
|
|
->assertSee('Qualität')
|
|
->assertSee('87')
|
|
->assertSee('Hochwertig')
|
|
->assertSee('Höchste Stufe erreicht.');
|
|
});
|
|
|
|
test('customer show erklaert bei Gelb den fehlenden Boost neutral', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
|
|
'status' => PressReleaseStatus::Published->value,
|
|
'published_at' => now(),
|
|
'classification' => PressReleaseClassification::Yellow->value,
|
|
]);
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Inhaltsprüfung')
|
|
->assertSee('Gelb')
|
|
->assertSee('Die Boost-Platzierung ist grün geprüften Meldungen vorbehalten.');
|
|
});
|
|
|
|
test('customer show zeigt ohne Pruefung Ausstehend und kein Qualitaets-Panel', function () {
|
|
/** @var TestCase $this */
|
|
['customer' => $customer, 'pr' => $pr] = makeCustomerForShowPhase8a([
|
|
'classification' => null,
|
|
'content_score' => null,
|
|
]);
|
|
$this->actingAs($customer);
|
|
|
|
LivewireVolt::test('customer.press-releases.show', ['id' => $pr->id])
|
|
->assertSee('Inhaltsprüfung')
|
|
->assertSee('Ausstehend')
|
|
->assertDontSee('Höchste Stufe erreicht.');
|
|
});
|