2022-07-23 01:44:03 +02:00
|
|
|
defmodule ClaperWeb.EventLiveTest do
|
|
|
|
|
use ClaperWeb.ConnCase
|
|
|
|
|
|
|
|
|
|
import Phoenix.LiveViewTest
|
2026-06-05 10:03:02 +02:00
|
|
|
import Claper.{FormsFixtures, PresentationsFixtures}
|
2022-07-23 01:44:03 +02:00
|
|
|
|
|
|
|
|
@update_attrs %{name: "some updated name"}
|
|
|
|
|
|
|
|
|
|
defp create_event(params) do
|
2022-07-28 14:36:32 +02:00
|
|
|
presentation_file = presentation_file_fixture(%{user: params.user}, [:event])
|
|
|
|
|
presentation_state_fixture(%{presentation_file: presentation_file})
|
|
|
|
|
params |> Map.put(:presentation_file, presentation_file)
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Index" do
|
2022-07-28 14:36:32 +02:00
|
|
|
setup [:register_and_log_in_user, :create_event]
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2022-07-28 14:36:32 +02:00
|
|
|
test "lists all events", %{conn: conn, presentation_file: presentation_file} do
|
2024-04-06 11:48:47 +02:00
|
|
|
{:ok, _index_live, html} = live(conn, ~p"/events")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2024-04-06 11:48:47 +02:00
|
|
|
assert html =~ "events"
|
2022-07-28 14:36:32 +02:00
|
|
|
assert html =~ presentation_file.event.name
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|
|
|
|
|
|
2022-07-28 14:36:32 +02:00
|
|
|
test "updates event in listing", %{conn: conn, presentation_file: presentation_file} do
|
2024-07-11 16:33:02 +02:00
|
|
|
{:ok, index_live, _html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/edit")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2024-04-07 12:47:03 +02:00
|
|
|
{:ok, conn} =
|
2022-07-23 01:44:03 +02:00
|
|
|
index_live
|
2022-07-28 14:36:32 +02:00
|
|
|
|> form("#event-form", event: @update_attrs)
|
2022-07-23 01:44:03 +02:00
|
|
|
|> render_submit()
|
2024-04-06 11:48:47 +02:00
|
|
|
|> follow_redirect(conn, ~p"/events")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2024-04-07 12:47:03 +02:00
|
|
|
assert html_response(conn, 200) =~ "Updated successfully"
|
|
|
|
|
assert html_response(conn, 200) =~ "some updated name"
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|
|
|
|
|
|
2022-07-28 14:36:32 +02:00
|
|
|
test "deletes event in listing", %{conn: conn, presentation_file: presentation_file} do
|
2024-07-11 16:33:02 +02:00
|
|
|
{:ok, index_live, _html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/edit")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2022-11-17 13:37:34 +01:00
|
|
|
{:ok, conn} =
|
|
|
|
|
index_live
|
2026-03-13 20:09:42 +01:00
|
|
|
|> element(~s{a[phx-click="delete"][phx-value-id=#{presentation_file.event.uuid}]})
|
2022-11-17 13:37:34 +01:00
|
|
|
|> render_click()
|
2024-04-06 11:48:47 +02:00
|
|
|
|> follow_redirect(conn, ~p"/events")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2024-04-06 11:48:47 +02:00
|
|
|
{:ok, index_live, _html} = live(conn, ~p"/events")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2022-07-28 14:36:32 +02:00
|
|
|
refute has_element?(index_live, "#event-#{presentation_file.event.uuid}")
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "Show" do
|
2022-07-28 14:36:32 +02:00
|
|
|
setup [:register_and_log_in_user, :create_event]
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2022-07-28 14:36:32 +02:00
|
|
|
test "displays event", %{conn: conn, presentation_file: presentation_file} do
|
2022-11-17 13:37:34 +01:00
|
|
|
{:ok, _show_live, html} =
|
2024-04-06 11:48:47 +02:00
|
|
|
live(conn, ~p"/e/#{presentation_file.event.code}")
|
2022-07-23 01:44:03 +02:00
|
|
|
|
2024-04-06 11:48:47 +02:00
|
|
|
assert html =~ "Be the first to react !"
|
2022-07-28 14:36:32 +02:00
|
|
|
assert html =~ presentation_file.event.name
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|
|
|
|
|
end
|
2026-04-14 17:27:42 +02:00
|
|
|
|
2026-04-15 08:04:27 +02:00
|
|
|
describe "Manage" do
|
|
|
|
|
setup [:register_and_log_in_user, :create_event]
|
|
|
|
|
|
|
|
|
|
test "prompts to regenerate missing thumbnails and starts regeneration", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
presentation_file: presentation_file
|
|
|
|
|
} do
|
|
|
|
|
Oban.Testing.with_testing_mode(:manual, fn ->
|
|
|
|
|
{:ok, manage_live, html} = live(conn, ~p"/e/#{presentation_file.event.code}/manage")
|
|
|
|
|
|
|
|
|
|
assert html =~ "No thumbnails are available"
|
|
|
|
|
assert html =~ "Regenerate thumbnails"
|
|
|
|
|
|
|
|
|
|
manage_live
|
|
|
|
|
|> element(~s{button[phx-click="regenerate-thumbnails"]})
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
assert render(manage_live) =~ "Thumbnail regeneration started"
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2026-06-01 18:35:37 +02:00
|
|
|
describe "Stats" do
|
|
|
|
|
setup [:register_and_log_in_user, :create_event]
|
|
|
|
|
|
|
|
|
|
test "hides interaction tabs that have no content", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
presentation_file: presentation_file
|
|
|
|
|
} do
|
|
|
|
|
{:ok, _stats_live, html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/stats")
|
|
|
|
|
|
|
|
|
|
refute html =~ ~s(phx-value-tab="messages")
|
|
|
|
|
refute html =~ ~s(phx-value-tab="polls")
|
|
|
|
|
refute html =~ ~s(phx-value-tab="forms")
|
|
|
|
|
refute html =~ ~s(phx-value-tab="web_content")
|
|
|
|
|
refute html =~ ~s(phx-value-tab="quizzes")
|
|
|
|
|
refute html =~ ~s(phx-value-tab="transcriptions")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "displays transcriptions in report", %{conn: conn, presentation_file: presentation_file} do
|
|
|
|
|
{:ok, _transcription} =
|
|
|
|
|
Claper.Transcriptions.create_transcription(%{
|
|
|
|
|
presentation_file_id: presentation_file.id,
|
|
|
|
|
language: "en",
|
|
|
|
|
text: "Welcome to the event"
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, stats_live, _html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/stats")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
stats_live
|
|
|
|
|
|> element(~s{button[phx-value-tab="transcriptions"]})
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
assert html =~ "Transcriptions"
|
|
|
|
|
assert html =~ "Welcome to the event"
|
|
|
|
|
assert html =~ "UTC"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "loads more transcriptions in report", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
presentation_file: presentation_file
|
|
|
|
|
} do
|
|
|
|
|
for index <- 1..26 do
|
|
|
|
|
{:ok, _transcription} =
|
|
|
|
|
Claper.Transcriptions.create_transcription(%{
|
|
|
|
|
presentation_file_id: presentation_file.id,
|
|
|
|
|
language: "en",
|
|
|
|
|
text: "Transcript segment #{index}"
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
{:ok, stats_live, _html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/stats")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
stats_live
|
|
|
|
|
|> element(~s{button[phx-value-tab="transcriptions"]})
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
assert html =~ "Transcriptions"
|
|
|
|
|
assert html =~ "Transcript segment 1"
|
|
|
|
|
refute html =~ "Transcript segment 26"
|
|
|
|
|
assert html =~ "Load more"
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
stats_live
|
|
|
|
|
|> element(~s{button[phx-click="load_more_transcriptions"]})
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
assert html =~ "Transcript segment 1"
|
|
|
|
|
assert html =~ "Transcript segment 26"
|
|
|
|
|
refute html =~ "Load more"
|
|
|
|
|
end
|
2026-06-05 10:03:02 +02:00
|
|
|
|
|
|
|
|
test "displays emoji avatars for form submissions in report", %{
|
|
|
|
|
conn: conn,
|
|
|
|
|
presentation_file: presentation_file
|
|
|
|
|
} do
|
|
|
|
|
form = form_fixture(%{presentation_file_id: presentation_file.id})
|
|
|
|
|
|
|
|
|
|
{:ok, _form_submit} =
|
|
|
|
|
Claper.Forms.create_form_submit(%{
|
|
|
|
|
form_id: form.id,
|
|
|
|
|
attendee_identifier: "attendee-1",
|
|
|
|
|
response: %{"Name" => "Ada"}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
{:ok, stats_live, _html} = live(conn, ~p"/events/#{presentation_file.event.uuid}/stats")
|
|
|
|
|
|
|
|
|
|
html =
|
|
|
|
|
stats_live
|
|
|
|
|
|> element(~s{button[phx-value-tab="forms"]})
|
|
|
|
|
|> render_click()
|
|
|
|
|
|
|
|
|
|
assert html =~ "Ada"
|
|
|
|
|
assert html =~ "avatar avatar-placeholder"
|
|
|
|
|
end
|
2026-06-01 18:35:37 +02:00
|
|
|
end
|
|
|
|
|
|
2026-04-14 17:27:42 +02:00
|
|
|
describe "Join" do
|
|
|
|
|
test "renders the join page", %{conn: conn} do
|
|
|
|
|
{:ok, join_live, html} = live(conn, ~p"/")
|
|
|
|
|
|
|
|
|
|
assert html =~ "Join the event"
|
|
|
|
|
assert html =~ "Event code"
|
|
|
|
|
assert html =~ "Are you a presenter?"
|
|
|
|
|
assert html =~ "Start creating for free"
|
|
|
|
|
refute html =~ "Turn your slides into conversations"
|
|
|
|
|
|
|
|
|
|
assert has_element?(join_live, "#form")
|
|
|
|
|
assert has_element?(join_live, "#input[placeholder='ABCD1234']")
|
|
|
|
|
end
|
|
|
|
|
end
|
2022-07-23 01:44:03 +02:00
|
|
|
end
|