Fix online status on clients page (#4307)

Closes #4271
This commit is contained in:
Andrew Dryga
2024-03-25 14:00:42 -06:00
committed by GitHub
parent d4ba178515
commit 4844422a31
2 changed files with 23 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ defmodule Web.Clients.Show do
def mount(%{"id" => id}, _session, socket) do
with {:ok, client} <-
Clients.fetch_client_by_id(id, socket.assigns.subject,
preload: [:actor, last_used_token: [identity: [:provider]]]
preload: [:online?, :actor, last_used_token: [identity: [:provider]]]
) do
if connected?(socket) do
:ok = Clients.subscribe_to_clients_presence_for_actor(client.actor)

View File

@@ -97,6 +97,28 @@ defmodule Web.Live.Clients.ShowTest do
assert table["user agent"] =~ client.last_seen_user_agent
end
test "shows client online status", %{
account: account,
client: client,
identity: identity,
conn: conn
} do
:ok = Domain.Clients.connect_client(client)
{:ok, lv, _html} =
conn
|> authorize_conn(identity)
|> live(~p"/#{account}/clients/#{client}")
table =
lv
|> element("#client")
|> render()
|> vertical_table_to_map()
assert table["status"] =~ "Online"
end
test "updates client online status using presence", %{
account: account,
client: client,