67 lines
1.9 KiB
PHP
67 lines
1.9 KiB
PHP
<?php
|
|
|
|
use App\Enums\PressReleaseStatus;
|
|
use App\Models\Company;
|
|
use App\Models\PressRelease;
|
|
use App\Models\User;
|
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
|
use Tests\TestCase;
|
|
|
|
test('guests are redirected to the login page', function () {
|
|
/** @var TestCase $this */
|
|
$response = $this->get(config('domains.domain_portal_url').'/dashboard');
|
|
$response->assertRedirect(route('login'));
|
|
});
|
|
|
|
test('admins can visit the dashboard', function () {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
$this->actingAs($admin);
|
|
|
|
$response = $this->get(config('domains.domain_portal_url').'/dashboard');
|
|
$response->assertSuccessful();
|
|
});
|
|
|
|
test('dashboard renders aggregated press release stats', function () {
|
|
/** @var TestCase $this */
|
|
$this->seed(RolesAndPermissionsSeeder::class);
|
|
|
|
$admin = User::factory()->create(['is_active' => true]);
|
|
$admin->assignRole('admin');
|
|
$this->actingAs($admin);
|
|
|
|
$company = Company::factory()->create();
|
|
|
|
PressRelease::factory()
|
|
->published()
|
|
->create([
|
|
'user_id' => $admin->id,
|
|
'company_id' => $company->id,
|
|
'title' => 'Veröffentlichte Dashboard PM',
|
|
]);
|
|
|
|
PressRelease::factory()
|
|
->inReview()
|
|
->create([
|
|
'user_id' => $admin->id,
|
|
'company_id' => $company->id,
|
|
'title' => 'Review Dashboard PM',
|
|
]);
|
|
|
|
PressRelease::factory()->create([
|
|
'user_id' => $admin->id,
|
|
'company_id' => $company->id,
|
|
'status' => PressReleaseStatus::Draft->value,
|
|
]);
|
|
|
|
$this->get(config('domains.domain_portal_url').'/dashboard')
|
|
->assertSuccessful()
|
|
->assertSee('3')
|
|
->assertSee('1 pub')
|
|
->assertSee('1 prüf')
|
|
->assertSee('1 entwurf')
|
|
->assertSee('Review Dashboard PM');
|
|
});
|