mirror of
https://github.com/ClaperCo/Claper.git
synced 2026-08-29 10:09:08 +02:00
72 lines
2.8 KiB
Elixir
72 lines
2.8 KiB
Elixir
defmodule ClaperWeb.EventLive.ShowTest do
|
|
use ClaperWeb.ConnCase
|
|
|
|
import Phoenix.LiveViewTest
|
|
import Claper.{AccountsFixtures, PostsFixtures, PresentationsFixtures}
|
|
|
|
setup [:register_and_log_in_user]
|
|
|
|
test "renders the fixed attendee room stack and identity menu", %{
|
|
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)
|
|
|
|
assert "h-[100dvh]" in classes(document, "#attendee-room")
|
|
assert "grid-rows-[auto_auto_minmax(0,1fr)]" in classes(document, "#attendee-room")
|
|
assert "z-[60]" in classes(document, "#side-menu")
|
|
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") != []
|
|
assert Floki.attribute(document, "[data-reaction-icon]", "draggable") == ["false"]
|
|
assert "pointer-events-none" in classes(document, "[data-reaction-icon]")
|
|
assert Floki.find(document, "#top-identity-button") == []
|
|
assert Floki.find(document, "#composer-identity-button") != []
|
|
|
|
[close_command] = Floki.attribute(document, "#nicknamepicker", "data-close")
|
|
|
|
assert [["hide", %{"to" => "#identity-menu"}]] = Jason.decode!(close_command)
|
|
assert Floki.attribute(document, "#nicknamepicker", "phx-click") == []
|
|
end
|
|
|
|
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
|
|
|
|
defp classes(document, selector) do
|
|
document
|
|
|> Floki.attribute(selector, "class")
|
|
|> List.first()
|
|
|> String.split()
|
|
end
|
|
end
|