22-05-2026 Optimierung der User und Admin Panels
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
Kevin Adametz 2026-05-22 11:18:59 +02:00
parent d2ba22c0cf
commit e8c47b7553
73 changed files with 10282 additions and 1546 deletions

View file

@ -0,0 +1,124 @@
<?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',
]);
LivewireVolt::test('admin.press-releases.show', ['id' => $pr->id])
->assertSee('Geplante Veröffentlichung')
->assertSee('15.06.2026 10: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');
});