2026-07-15 17:46:22 +02:00
|
|
|
defmodule ClaperWeb.EventLive.ShowTest do
|
|
|
|
|
use ClaperWeb.ConnCase
|
|
|
|
|
|
|
|
|
|
import Phoenix.LiveViewTest
|
2026-07-16 17:32:08 +02:00
|
|
|
import Claper.{AccountsFixtures, PostsFixtures, PresentationsFixtures}
|
2026-07-15 17:46:22 +02:00
|
|
|
|
|
|
|
|
setup [:register_and_log_in_user]
|
|
|
|
|
|
2026-07-16 17:32:08 +02:00
|
|
|
test "renders the fixed attendee room stack and identity menu", %{
|
2026-07-15 17:46:22 +02:00
|
|
|
conn: conn,
|
|
|
|
|
user: user
|
|
|
|
|
} do
|
|
|
|
|
presentation_file = presentation_file_fixture(%{user: user}, [:event])
|
|
|
|
|
presentation_state_fixture(%{presentation_file: presentation_file})
|
|
|
|
|
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/e/#{presentation_file.event.code}")
|
|
|
|
|
|
|
|
|
|
document = Floki.parse_document!(html)
|
|
|
|
|
|
2026-07-16 17:32:08 +02:00
|
|
|
assert "h-[100dvh]" in classes(document, "#attendee-room")
|
|
|
|
|
assert "grid-rows-[auto_auto_minmax(0,1fr)]" in classes(document, "#attendee-room")
|
2026-07-15 17:46:22 +02:00
|
|
|
assert "z-[60]" in classes(document, "#side-menu")
|
2026-07-16 17:32:08 +02:00
|
|
|
assert "h-[40dvh]" in classes(document, "#focus-slot")
|
|
|
|
|
assert Floki.find(document, "#focus-media img") != []
|
|
|
|
|
assert Floki.find(document, "[data-focus-collapse]") != []
|
|
|
|
|
assert Floki.find(document, "[data-focus-show]") != []
|
|
|
|
|
assert document |> Floki.find("[data-focus-show]") |> Floki.text() =~ "Show presentation"
|
|
|
|
|
assert "overflow-y-auto" in classes(document, "#chat-feed")
|
|
|
|
|
assert Floki.attribute(document, "#chat-feed", "phx-hook") == ["RoomFeed"]
|
|
|
|
|
assert Floki.attribute(document, "#post-form", "phx-hook") == ["PostForm"]
|
|
|
|
|
assert "attendee-composer" in classes(document, "#post-form")
|
|
|
|
|
assert Floki.find(document, "#room-topbar") != []
|
|
|
|
|
assert Floki.find(document, "#room-composer") != []
|
2026-07-16 22:20:04 +02:00
|
|
|
assert Floki.attribute(document, "[data-reaction-icon]", "draggable") == ["false"]
|
|
|
|
|
assert "pointer-events-none" in classes(document, "[data-reaction-icon]")
|
2026-07-16 17:32:08 +02:00
|
|
|
assert Floki.find(document, "#top-identity-button") == []
|
|
|
|
|
assert Floki.find(document, "#composer-identity-button") != []
|
2026-07-15 17:46:22 +02:00
|
|
|
|
|
|
|
|
[close_command] = Floki.attribute(document, "#nicknamepicker", "data-close")
|
|
|
|
|
|
2026-07-16 17:32:08 +02:00
|
|
|
assert [["hide", %{"to" => "#identity-menu"}]] = Jason.decode!(close_command)
|
2026-07-15 17:46:22 +02:00
|
|
|
assert Floki.attribute(document, "#nicknamepicker", "phx-click") == []
|
|
|
|
|
end
|
|
|
|
|
|
2026-07-16 17:32:08 +02:00
|
|
|
test "updates reaction controls when message reactions are enabled", %{conn: conn, user: user} do
|
|
|
|
|
presentation_file = presentation_file_fixture(%{user: user}, [:event])
|
|
|
|
|
|
|
|
|
|
state =
|
|
|
|
|
presentation_state_fixture(%{
|
|
|
|
|
presentation_file: presentation_file,
|
|
|
|
|
message_reaction_enabled: false
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
post_fixture(%{event: presentation_file.event, user: user_fixture()})
|
|
|
|
|
|
|
|
|
|
{:ok, view, html} = live(conn, ~p"/e/#{presentation_file.event.code}")
|
|
|
|
|
|
|
|
|
|
refute html =~ "data-message-reaction-trigger"
|
|
|
|
|
|
|
|
|
|
send(view.pid, {:state_updated, %{state | message_reaction_enabled: true}})
|
|
|
|
|
|
|
|
|
|
assert render(view) =~ "data-message-reaction-trigger"
|
|
|
|
|
end
|
|
|
|
|
|
2026-08-04 22:21:28 +07:00
|
|
|
test "does not render the focus panel without attendee content", %{conn: conn, user: user} do
|
|
|
|
|
presentation_file = presentation_file_fixture(%{user: user, length: 0}, [:event])
|
|
|
|
|
presentation_state_fixture(%{presentation_file: presentation_file})
|
|
|
|
|
|
|
|
|
|
{:ok, _view, html} = live(conn, ~p"/e/#{presentation_file.event.code}")
|
|
|
|
|
|
|
|
|
|
document = Floki.parse_document!(html)
|
|
|
|
|
|
|
|
|
|
assert Floki.find(document, "#focus-slot") == []
|
2026-08-05 09:05:24 +07:00
|
|
|
assert "grid-rows-[auto_minmax(0,1fr)]" in classes(document, "#attendee-room")
|
2026-08-04 22:21:28 +07:00
|
|
|
refute html =~ "Waiting for content"
|
|
|
|
|
end
|
|
|
|
|
|
2026-07-24 23:33:12 +02:00
|
|
|
test "renders attendee captions as a collapsible panel that cannot be disabled", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
user: user
|
|
|
|
|
} do
|
|
|
|
|
presentation_file = presentation_file_fixture(%{user: user}, [:event])
|
|
|
|
|
presentation_state_fixture(%{presentation_file: presentation_file})
|
|
|
|
|
|
|
|
|
|
{:ok, _config} =
|
|
|
|
|
Claper.Transcriptions.create_transcription_config(%{
|
|
|
|
|
presentation_file_id: presentation_file.id,
|
|
|
|
|
enabled: true,
|
|
|
|
|
visibility: "attendee"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, view, html} = live(conn, ~p"/e/#{presentation_file.event.code}")
|
|
|
|
|
|
|
|
|
|
document = Floki.parse_document!(html)
|
|
|
|
|
|
|
|
|
|
assert "grid-rows-[auto_auto_auto_minmax(0,1fr)]" in classes(document, "#attendee-room")
|
|
|
|
|
assert Floki.attribute(document, "#caption-panel", "phx-hook") == ["AttendeeCaptions"]
|
|
|
|
|
assert Floki.find(document, "[data-caption-collapse]") != []
|
|
|
|
|
assert Floki.find(document, "[data-caption-show]") != []
|
|
|
|
|
assert Floki.find(document, "[data-caption-toggle]") == []
|
|
|
|
|
assert document |> Floki.find("[data-caption-show]") |> Floki.text() =~ "Show captions"
|
|
|
|
|
|
|
|
|
|
send(view.pid, {:transcription_delta, "Live caption text"})
|
|
|
|
|
|
|
|
|
|
assert view
|
|
|
|
|
|> render()
|
|
|
|
|
|> Floki.parse_document!()
|
|
|
|
|
|> Floki.find("[data-caption-text]")
|
|
|
|
|
|> Floki.text() =~ "Live caption text"
|
|
|
|
|
end
|
|
|
|
|
|
2026-07-15 17:46:22 +02:00
|
|
|
defp classes(document, selector) do
|
|
|
|
|
document
|
|
|
|
|
|> Floki.attribute(selector, "class")
|
|
|
|
|
|> List.first()
|
|
|
|
|
|> String.split()
|
|
|
|
|
end
|
|
|
|
|
end
|