Files
self c1f4339dde refactor: move Aether into TribeOne plugin namespace
Use TribeOne.TribesPlugin.Aether modules throughout the plugin and expose chat@1 from the entry module for capability-based consumers.
2026-05-26 01:13:28 +02:00

75 lines
2.7 KiB
Elixir

defmodule TribeOne.TribesPlugin.Aether.ChatPageTest do
use Tribes.PluginTest.PageCase, plugin: TribeOne.TribesPlugin.Aether.Plugin
alias TribeOne.TribesPlugin.Aether.Chat
test "renders the public chat for signed-out visitors", %{conn: conn} do
{:ok, view, _html} = live(conn, "/aether/chat")
assert has_element?(view, "#aether-chat-page")
assert has_element?(view, "#chat-signed-out", "Sign in to join the chat.")
end
test "renders the message composer for signed-in users", %{signed_in_conn: conn} do
{:ok, view, _html} = live(conn, "/aether/chat")
assert has_element?(view, "#chat-message-form")
assert has_element?(view, "#chat-send-button", "Send")
end
test "posts a public synced message", %{signed_in_conn: conn} do
slug = "test-chat-#{System.unique_integer([:positive])}"
{:ok, view, _html} = live(conn, "/aether/chat/#{slug}")
view
|> form("#chat-message-form", %{"message" => %{"body" => "Hello from chat test"}})
|> render_submit()
assert has_element?(view, "#chat-messages", "Hello from chat test")
end
test "renders compact embedded chat", %{conn: conn} do
slug = "embed-chat-#{System.unique_integer([:positive])}"
{:ok, view, _html} = live(conn, "/aether/chat/embed/#{slug}")
assert has_element?(view, "#aether-chat-embed")
assert has_element?(view, "#chat-embed-header")
refute has_element?(view, "#aether-chat-page")
end
test "renders Marmot scaffold without public composer", %{signed_in_conn: conn} do
slug = "marmot-chat-#{System.unique_integer([:positive])}"
{:ok, view, _html} = live(conn, "/aether/chat/marmot/#{slug}")
assert has_element?(view, "#chat-marmot-notice")
assert has_element?(view, "#chat-marmot-disabled")
refute has_element?(view, "#chat-message-form")
end
test "ensures context group channels with stable slugs" do
attrs = %{
context_provider: "sender",
context_type: "stream",
context_id: "stream-123",
title: "Stream chat"
}
assert {:ok, first} = Chat.ensure_channel(attrs)
assert {:ok, second} = Chat.ensure_channel(attrs)
assert first.id == second.id
assert first.slug == "sender-stream-stream-123"
assert first.conversation_kind == :context_group
assert Chat.embed_path(first) == "/aether/chat/embed/sender-stream-stream-123"
assert Chat.marmot_path(first) == "/aether/chat/marmot/sender-stream-stream-123"
end
test "ensures context group channels through provider helper" do
assert {:ok, channel} =
Chat.ensure_context_channel("sender", "stream", "stream-456", %{title: "Stream Chat"})
assert channel.slug == "sender-stream-stream-456"
assert channel.conversation_kind == :context_group
end
end