优化 刷新页面不在重复播报 离开和登录提示

This commit is contained in:
2026-04-11 22:40:42 +08:00
parent 0a764a3a86
commit ff402be02f
7 changed files with 119 additions and 88 deletions
+20
View File
@@ -6,6 +6,7 @@ use App\Models\Room;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;
class ChatControllerTest extends TestCase
@@ -98,6 +99,25 @@ class ChatControllerTest extends TestCase
$this->assertEquals(0, Redis::hexists("room:{$room->id}:users", $user->username));
}
public function test_can_leave_room_through_signed_expired_route(): void
{
$room = Room::create(['room_name' => 'expired_leave_room']);
$user = User::factory()->create();
$this->actingAs($user)->get(route('chat.room', $room->id));
$this->assertEquals(1, Redis::hexists("room:{$room->id}:users", $user->username));
$url = URL::temporarySignedRoute('chat.leave.expired', now()->addMinutes(5), [
'id' => $room->id,
'user' => $user->id,
]);
$response = $this->getJson($url);
$response->assertStatus(200);
$this->assertEquals(0, Redis::hexists("room:{$room->id}:users", $user->username));
}
/**
* 测试会员用户首次进房时会把专属欢迎主题写入历史消息。
*/