kick forever
CI/CD / test_and_check_app (push) Successful in 2m19s
CI/CD / Publish immutable image (push) Successful in 1m16s

This commit is contained in:
2026-09-24 14:38:18 +02:00
parent b190ff719e
commit 4dfe79ce5c
22 changed files with 271 additions and 113 deletions
+39 -10
View File
@@ -44,7 +44,6 @@ test('the room owner sees active room players on the dashboard', function () {
$room = createRoomForPlayerKick($owner);
$moderator = addPlayerToKickRoom($room, 'Moderator', $owner, true);
$participant = addPlayerToKickRoom($room, 'Anna');
addPlayerToKickRoom($room, 'Inactive')->update(['inactive_at' => now()]);
$this->actingAs($owner)
->get(route('dashboard'))
@@ -77,8 +76,8 @@ test('the room owner can kick an active participant', function () {
->delete(route('room.player.destroy', [$room, $participant]))
->assertRedirect();
expect($participant->fresh()->inactive_at)->not->toBeNull()
->and($room->fresh()->state_version)->toBe($previousVersion + 1);
$this->assertModelMissing($participant);
expect($room->fresh()->state_version)->toBe($previousVersion + 1);
Event::assertDispatched(
RoomStateChanged::class,
@@ -104,6 +103,36 @@ test('the room owner can kick an active participant', function () {
Event::assertDispatchedTimes(RoomStateChanged::class, 1);
});
test('a kicked guest loses their votes and their name becomes available', function () {
$owner = User::factory()->create();
$room = createRoomForPlayerKick($owner);
addPlayerToKickRoom($room, 'Moderator', $owner, true);
$guest = addPlayerToKickRoom($room, 'Nico');
$vote = $guest->votes()->create([
'room_id' => $room->id,
'round' => $room->current_round,
'value' => '3',
]);
$this->actingAs($owner)
->delete(route('room.player.destroy', [$room, $guest]))
->assertRedirect();
$this->assertModelMissing($guest);
$this->assertModelMissing($vote);
auth()->logout();
$this->withSession(["room_players.{$room->id}" => $guest->id])
->post(route('room.code'), [
'join_code' => $room->join_code,
'player_name' => 'Nico',
])
->assertRedirect(route('room.show', $room));
expect($room->players()->where('name', 'Nico')->sole()->id)->not->toBe($guest->id);
});
test('the room moderator can kick an active participant without shared management', function () {
$owner = User::factory()->create();
$room = createRoomForPlayerKick($owner, ['owner_id' => null]);
@@ -116,7 +145,7 @@ test('the room moderator can kick an active participant without shared managemen
->delete(route('room.player.destroy', [$room, $target]))
->assertRedirect();
expect($target->fresh()->inactive_at)->not->toBeNull();
$this->assertModelMissing($target);
Event::assertDispatchedTimes(RoomStateChanged::class, 1);
});
@@ -135,7 +164,7 @@ test('a participant cannot kick another player when participant management is di
->delete(route('room.player.destroy', [$room, $target]))
->assertForbidden();
expect($target->fresh()->inactive_at)->toBeNull();
$this->assertModelExists($target);
Event::assertNotDispatched(RoomStateChanged::class);
});
@@ -154,7 +183,7 @@ test('a participant can kick another player when participant management is enabl
->delete(route('room.player.destroy', [$room, $target]))
->assertRedirect();
expect($target->fresh()->inactive_at)->not->toBeNull();
$this->assertModelMissing($target);
Event::assertDispatched(RoomStateChanged::class);
});
@@ -171,7 +200,7 @@ test('a participant cannot kick themselves when participant management is enable
->delete(route('room.player.destroy', [$room, $participant]))
->assertForbidden();
expect($participant->fresh()->inactive_at)->toBeNull();
$this->assertModelExists($participant);
Event::assertNotDispatched(RoomStateChanged::class);
});
@@ -189,7 +218,7 @@ test('an anonymous visitor without a room session cannot kick from an ownerless
$this->delete(route('room.player.destroy', [$room, $target]))
->assertForbidden();
expect($target->fresh()->inactive_at)->toBeNull();
$this->assertModelExists($target);
Event::assertNotDispatched(RoomStateChanged::class);
});
@@ -204,7 +233,7 @@ test('the room owner cannot kick their own player', function () {
->delete(route('room.player.destroy', [$room, $moderator]))
->assertForbidden();
expect($moderator->fresh()->inactive_at)->toBeNull();
$this->assertModelExists($moderator);
Event::assertNotDispatched(RoomStateChanged::class);
});
@@ -221,6 +250,6 @@ test('the room owner cannot kick a player from another room', function () {
->delete(route('room.player.destroy', [$room, $target]))
->assertForbidden();
expect($target->fresh()->inactive_at)->toBeNull();
$this->assertModelExists($target);
Event::assertNotDispatched(RoomStateChanged::class);
});