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,154 @@
<?php
use App\Enums\PressReleaseStatus;
use App\Models\Company;
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);
});
function makeCustomerForIndexPhase8b(): User
{
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
return $customer;
}
function makeAdminForIndexPhase8b(): User
{
$admin = User::factory()->create(['is_active' => true]);
$admin->assignRole('admin');
return $admin;
}
test('customer list zeigt Scheduling-Sub-Zeile bei review-PMs mit scheduled_at', function () {
/** @var TestCase $this */
$customer = makeCustomerForIndexPhase8b();
$this->actingAs($customer);
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'portal' => $company->portal->value,
'status' => PressReleaseStatus::Review->value,
'scheduled_at' => now()->addDays(3)->setTime(14, 30),
]);
LivewireVolt::test('customer.press-releases.index')
->assertSee('geplant');
});
test('customer list zeigt Embargo-Sub-Zeile bei PMs mit embargo_at in der Zukunft', function () {
/** @var TestCase $this */
$customer = makeCustomerForIndexPhase8b();
$this->actingAs($customer);
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'portal' => $company->portal->value,
'status' => PressReleaseStatus::Published->value,
'embargo_at' => now()->addDays(7),
]);
LivewireVolt::test('customer.press-releases.index')
->assertSee('Embargo bis');
});
test('customer list zeigt KEINE Scheduling-Sub-Zeile wenn scheduled_at in der Vergangenheit', function () {
/** @var TestCase $this */
$customer = makeCustomerForIndexPhase8b();
$this->actingAs($customer);
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'portal' => $company->portal->value,
'status' => PressReleaseStatus::Published->value,
'scheduled_at' => now()->subDay(),
]);
LivewireVolt::test('customer.press-releases.index')
->assertDontSee('geplant ·');
});
test('customer list zeigt KEINE Embargo-Sub-Zeile wenn embargo_at abgelaufen', function () {
/** @var TestCase $this */
$customer = makeCustomerForIndexPhase8b();
$this->actingAs($customer);
$company = Company::factory()->presseecho()->create();
$customer->companies()->attach($company->id, ['role' => 'owner']);
PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'portal' => $company->portal->value,
'status' => PressReleaseStatus::Published->value,
'embargo_at' => now()->subDay(),
]);
LivewireVolt::test('customer.press-releases.index')
->assertDontSee('Embargo bis');
});
test('admin list zeigt Scheduling-Sub-Zeile bei review-PMs mit scheduled_at', function () {
/** @var TestCase $this */
$admin = makeAdminForIndexPhase8b();
$this->actingAs($admin);
PressRelease::factory()->create([
'status' => PressReleaseStatus::Review->value,
'scheduled_at' => now()->addDays(2)->setTime(10, 0),
]);
LivewireVolt::test('admin.press-releases.index')
->assertSee('geplant');
});
test('admin list zeigt Embargo-Sub-Zeile bei PMs mit embargo_at in der Zukunft', function () {
/** @var TestCase $this */
$admin = makeAdminForIndexPhase8b();
$this->actingAs($admin);
PressRelease::factory()->create([
'status' => PressReleaseStatus::Published->value,
'embargo_at' => now()->addDays(5),
]);
LivewireVolt::test('admin.press-releases.index')
->assertSee('Embargo bis');
});
test('admin list zeigt KEINE Sub-Zeilen wenn weder scheduled_at noch embargo_at', function () {
/** @var TestCase $this */
$admin = makeAdminForIndexPhase8b();
$this->actingAs($admin);
PressRelease::factory()->create([
'status' => PressReleaseStatus::Draft->value,
'scheduled_at' => null,
'embargo_at' => null,
]);
LivewireVolt::test('admin.press-releases.index')
->assertDontSee('geplant ·')
->assertDontSee('Embargo bis');
});