Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
121 lines
3.9 KiB
PHP
121 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Profile;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class ProfileTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_dashboard_shares_header_data(): void
|
|
{
|
|
$user = User::factory()->create(['first_name' => 'Ada', 'last_name' => 'Lovelace']);
|
|
|
|
$this->actingAs($user)
|
|
->get('/')
|
|
->assertOk()
|
|
->assertInertia(fn (Assert $page) => $page
|
|
->component('Dashboard')
|
|
->where('auth.user.name', 'Ada Lovelace')
|
|
->where('auth.user.initials', 'AL')
|
|
->where('auth.user.avatar_url', null)
|
|
->where('auth.user.is_admin', false)
|
|
->has('branding.portal_name')
|
|
->has('branding.primary_color'));
|
|
}
|
|
|
|
public function test_profile_redirects_to_own_person_page(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)->get('/profil')->assertRedirect("/personen/{$user->id}");
|
|
}
|
|
|
|
public function test_colleague_profile_is_shown(): void
|
|
{
|
|
$colleague = User::factory()->create(['job_title' => 'Pflegedienstleitung']);
|
|
|
|
$this->actingAs(User::factory()->create())
|
|
->get("/personen/{$colleague->id}")
|
|
->assertOk()
|
|
->assertInertia(fn (Assert $page) => $page
|
|
->component('Profile/Show')
|
|
->where('person.job_title', 'Pflegedienstleitung')
|
|
->where('isOwnProfile', false));
|
|
}
|
|
|
|
public function test_inactive_profiles_are_hidden(): void
|
|
{
|
|
$inactive = User::factory()->inactive()->create();
|
|
|
|
$this->actingAs(User::factory()->create())
|
|
->get("/personen/{$inactive->id}")
|
|
->assertNotFound();
|
|
}
|
|
|
|
public function test_own_profile_can_be_updated(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->put('/profil', [
|
|
'first_name' => 'Grete',
|
|
'last_name' => 'Müller',
|
|
'email' => 'grete@example.com',
|
|
'job_title' => 'Mitarbeitervertretung',
|
|
'department' => 'MAV',
|
|
'location' => 'Hamburg',
|
|
'phone' => '040 123',
|
|
'mobile' => null,
|
|
'about' => 'Ansprechpartnerin für alle Fragen rund um die MAV.',
|
|
])
|
|
->assertRedirect()
|
|
->assertSessionHasNoErrors();
|
|
|
|
$user->refresh();
|
|
$this->assertSame('Grete Müller', $user->name);
|
|
$this->assertSame('MAV', $user->department);
|
|
$this->assertSame('grete@example.com', $user->email);
|
|
}
|
|
|
|
public function test_profile_update_cannot_change_account_flags(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)->put('/profil', [
|
|
'first_name' => 'Eve',
|
|
'last_name' => 'Evil',
|
|
'email' => $user->email,
|
|
'is_admin' => true,
|
|
'is_active' => false,
|
|
]);
|
|
|
|
$user->refresh();
|
|
$this->assertFalse($user->is_admin);
|
|
$this->assertTrue($user->is_active);
|
|
}
|
|
|
|
public function test_email_must_be_unique(): void
|
|
{
|
|
User::factory()->create(['email' => 'vergeben@example.com']);
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->put('/profil', ['first_name' => 'A', 'last_name' => 'B', 'email' => 'vergeben@example.com'])
|
|
->assertSessionHasErrors('email');
|
|
}
|
|
|
|
public function test_theme_preference_is_saved_and_validated(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
|
|
$this->actingAs($user)->put('/profil/darstellung', ['theme' => 'dark'])->assertRedirect();
|
|
$this->assertSame('dark', $user->fresh()->theme);
|
|
|
|
$this->actingAs($user)->put('/profil/darstellung', ['theme' => 'pink'])->assertSessionHasErrors('theme');
|
|
}
|
|
}
|