presseportale/tests/Feature/Customer/DashboardTest.php
Kevin Adametz 0a3e52d603 19-05-2026 Rebrand Pressekonto, Hub-Flux UI und Legacy-Media-Migration
Umbenennung presseportale → pressekonto in Domains, Themes und Dokumentation.
Design-Tokens, Portal-Shell, Customer-Dashboard, Auth- und Admin-PM-Views.
Artisan-Befehl migrate:legacy-media mit Tests und Hub-Flux-Entwicklungsdocs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-19 16:36:13 +00:00

130 lines
4 KiB
PHP

<?php
use App\Enums\PressReleaseStatus;
use App\Models\BillingAddress;
use App\Models\Company;
use App\Models\PressRelease;
use App\Models\Profile;
use App\Models\User;
use Database\Seeders\RolesAndPermissionsSeeder;
use Livewire\Volt\Volt as LivewireVolt;
use Tests\TestCase;
beforeEach(function () {
$this->seed(RolesAndPermissionsSeeder::class);
});
test('customer dashboard renders core sections without errors', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$this->actingAs($customer);
LivewireVolt::test('customer.dashboard')
->assertSee('Mein Dashboard')
->assertSee(__('Gesamt'))
->assertSee(__('Veröffentlicht'))
->assertSee(__('In Prüfung'))
->assertSee(__('Entwürfe'))
->assertSee(__('Meine letzten Pressemitteilungen'))
->assertSee(__('Datenqualität'))
->assertSee(__('Brand-Bridge'));
});
test('empty-state with three-step intro shows when no press releases exist', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$this->actingAs($customer);
LivewireVolt::test('customer.dashboard')
->assertSee(__('Noch keine Pressemitteilungen'))
->assertSee(__('Erste Pressemitteilung erstellen'))
->assertSee(__('Firma zuordnen'))
->assertSee(__('Mitteilung verfassen'))
->assertSee(__('Zur Prüfung senden'));
});
test('press release list and KPI counts render when data exists', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
$company = Company::factory()->create(['owner_user_id' => $customer->id]);
PressRelease::factory()
->published()
->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'title' => 'Phase 2 Demo Release',
]);
PressRelease::factory()->create([
'user_id' => $customer->id,
'company_id' => $company->id,
'status' => PressReleaseStatus::Draft->value,
]);
$this->actingAs($customer);
LivewireVolt::test('customer.dashboard')
->assertSee('Phase 2 Demo Release')
->assertDontSee(__('Noch keine Pressemitteilungen'))
->assertSee('Alle anzeigen');
});
test('profile completeness hint with percentage appears for partial profiles', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
Profile::factory()->create([
'user_id' => $customer->id,
'first_name' => 'Test',
'last_name' => 'Customer',
'phone' => null,
'address' => null,
'country_code' => null,
'salutation_key' => null,
]);
$this->actingAs($customer);
LivewireVolt::test('customer.dashboard')
->assertSee(__('Profil unvollständig'))
->assertSee('33');
});
test('billing address hint disappears once address is complete', function () {
/** @var TestCase $this */
$customer = User::factory()->create(['is_active' => true]);
$customer->assignRole('customer');
Profile::factory()->create([
'user_id' => $customer->id,
'salutation_key' => 'mr',
'first_name' => 'Test',
'last_name' => 'Customer',
'phone' => '+49 30 1234567',
'address' => 'Teststr. 1',
'country_code' => 'DE',
]);
BillingAddress::query()->create([
'user_id' => $customer->id,
'name' => 'Test Customer GmbH',
'address1' => 'Teststr. 1',
'postal_code' => '10115',
'city' => 'Berlin',
'country_code' => 'DE',
]);
$this->actingAs($customer);
LivewireVolt::test('customer.dashboard')
->assertDontSee(__('Profil unvollständig'))
->assertDontSee(__('Rechnungsadresse fehlt'))
->assertSee(__('Alles im grünen Bereich'));
});