Skip to content

Commit

Permalink
check if healthcheck is sent back
Browse files Browse the repository at this point in the history
  • Loading branch information
filipecabaco committed Feb 12, 2025
1 parent 2181e5c commit f0766b0
Showing 1 changed file with 11 additions and 41 deletions.
52 changes: 11 additions & 41 deletions test/integration/user_socket_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -119,59 +119,29 @@ defmodule RealtimeWeb.UserSocketTest do
tenant = Tenants.get_tenant_by_external_id(@external_id)
Realtime.Api.update_tenant(tenant, %{jwt_jwks: %{keys: ["potato"]}})

for _socket <- sockets do
# assert_receive %Message{
# topic: ^topic,
# event: "system",
# payload: %{
# "extension" => "system",
# "message" => "Server requested disconnect",
# "status" => "ok"
# }
# },
# 500

assert_receive %Message{event: "phx_close"}, 500
for socket <- sockets do
WebsocketClient.send_heartbeat(socket)
refute_receive %Message{event: "phx_reply"}, 500
end
end

test "on jwt_secret the socket closes and sends a system message", %{topics: topics} do
test "on jwt_secret the socket closes and sends a system message", %{sockets: sockets} do
tenant = Tenants.get_tenant_by_external_id(@external_id)
Realtime.Api.update_tenant(tenant, %{jwt_secret: "potato"})

for _topic <- topics do
# assert_receive %Message{
# topic: ^topic,
# event: "system",
# payload: %{
# "extension" => "system",
# "message" => "Server requested disconnect",
# "status" => "ok"
# }
# },
# 500

assert_receive %Message{event: "phx_close"}, 500
for socket <- sockets do
WebsocketClient.send_heartbeat(socket)
refute_receive %Message{event: "phx_reply"}, 500
end
end

test "on other param changes the socket won't close and no message is sent", %{topics: topics} do
test "on other param changes the socket won't close and no message is sent", %{sockets: sockets} do
tenant = Tenants.get_tenant_by_external_id(@external_id)
Realtime.Api.update_tenant(tenant, %{max_concurrent_users: 100})

for _topic <- topics do
# refute_receive %Message{
# topic: ^topic,
# event: "system",
# payload: %{
# "extension" => "system",
# "message" => "Server requested disconnect",
# "status" => "ok"
# }
# },
# 500

refute_receive %Message{event: "phx_close"}, 500
for socket <- sockets do
WebsocketClient.send_heartbeat(socket)
assert_receive %Message{event: "phx_reply"}, 500
end
end
end
Expand Down

0 comments on commit f0766b0

Please sign in to comment.