different names in different dynamics
linter / quality (push) Failing after 1m9s
tests / ci (8.3) (push) Failing after 51s
tests / ci (8.4) (push) Failing after 1m7s
tests / ci (8.5) (push) Failing after 1m9s

This commit is contained in:
Daan Meijer
2026-06-17 09:38:54 +02:00
parent 3c414e1ef1
commit 0fee3c1972
15 changed files with 283 additions and 11 deletions
+76
View File
@@ -0,0 +1,76 @@
<?php
use App\Models\User;
use App\Models\Dynamic;
test('user displayNameFor returns user name by default', function () {
$user = User::factory()->create(['name' => 'Alice']);
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($user->id, ['role' => 'participant']);
expect($user->displayNameFor($dynamic))->toBe('Alice');
});
test('user displayNameFor returns custom display name when set', function () {
$user = User::factory()->create(['name' => 'Alice']);
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($user->id, [
'role' => 'participant',
'display_name' => 'Ally',
]);
expect($user->displayNameFor($dynamic))->toBe('Ally');
});
test('participant can update their display name', function () {
$user = User::factory()->create(['name' => 'Alice']);
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($user->id, ['role' => 'participant']);
$this->actingAs($user);
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
'display_name' => 'Ally',
]);
$response->assertRedirect();
// Check database
$this->assertDatabaseHas('participants', [
'user_id' => $user->id,
'dynamic_id' => $dynamic->id,
'display_name' => 'Ally',
]);
// Check display name method
expect($user->displayNameFor($dynamic))->toBe('Ally');
});
test('display name update requires display_name parameter', function () {
$user = User::factory()->create(['name' => 'Alice']);
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($user->id, ['role' => 'participant']);
$this->actingAs($user);
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
'display_name' => '',
]);
$response->assertSessionHasErrors(['display_name']);
});
test('non participant cannot update display name', function () {
$user = User::factory()->create(['name' => 'Alice']);
$nonParticipant = User::factory()->create(['name' => 'Bob']);
$dynamic = Dynamic::factory()->create();
$dynamic->participants()->attach($user->id, ['role' => 'participant']);
$this->actingAs($nonParticipant);
$response = $this->put(route('dynamics.participant.update', $dynamic->id), [
'display_name' => 'Bobby',
]);
$response->assertStatus(404);
});
+1 -1
View File
@@ -16,7 +16,7 @@ use Tests\TestCase;
pest()->extend(TestCase::class)
->use(RefreshDatabase::class)
->in('Feature');
->in('Feature', 'Browser');
/*
|--------------------------------------------------------------------------