Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(portal): Fix online status on clients page #4307

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion elixir/apps/web/lib/web/live/clients/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 22 additions & 0 deletions elixir/apps/web/test/web/live/clients/show_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading