fix: refactored the codebase

This commit is contained in:
2026-08-20 23:00:47 +02:00
parent 6f47ed0674
commit a77f74911d
64 changed files with 2864 additions and 1739 deletions
+42
View File
@@ -171,6 +171,48 @@ test('an authenticated player can restore room access without the previous sessi
->assertSessionHas("room_players.{$room->id}", $moderator->id);
});
test('an active guest with a room session skips the join form', function () {
$room = createLifecycleRoom();
$player = $room->players()->create([
'name' => 'Guest',
'last_seen_at' => now(),
]);
$this->withSession(["room_players.{$room->id}" => $player->id])
->get(route('room.join', ['join_code' => $room->join_code]))
->assertRedirect(route('room.show', $room));
});
test('an inactive guest is sent through join and reuses the existing player', function () {
$room = createLifecycleRoom();
$player = $room->players()->create([
'name' => 'Returning guest',
'last_seen_at' => now()->subHours(2),
'inactive_at' => now()->subHour(),
]);
$session = ["room_players.{$room->id}" => $player->id];
$this->withSession($session)
->get(route('room.show', $room))
->assertRedirect(route('room.join', ['join_code' => $room->join_code]));
$this->withSession($session)
->get(route('room.join', ['join_code' => $room->join_code]))
->assertInertia(fn (Assert $page) => $page
->component('rooms/Join')
->where('defaultPlayerName', 'Returning guest'));
$this->withSession($session)
->post(route('room.code'), [
'join_code' => $room->join_code,
'player_name' => 'Returning guest',
])
->assertRedirect(route('room.show', $room));
expect($room->players()->count())->toBe(1)
->and($player->fresh()->inactive_at)->toBeNull();
});
test('showing or polling a room does not count as room activity', function () {
$room = createLifecycleRoom(['last_activity_at' => now()->subDays(5)]);
$moderator = $room->players()->create([