168 lines
5.7 KiB
PHP
168 lines
5.7 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);
|
|
|
|
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);
|
|
|
|
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('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)');
|
|
});
|