livebook/test/livebook_web/live/learn_live_test.exs

27 lines
744 B
Elixir
Raw Normal View History

defmodule LivebookWeb.LearnLiveTest do
use LivebookWeb.ConnCase, async: true
import Phoenix.LiveViewTest
test "link to introductory notebook correctly creates a new session", %{conn: conn} do
2023-02-23 02:34:54 +08:00
{:ok, view, _} = live(conn, ~p"/learn")
assert {:error, {:live_redirect, %{to: to}}} =
view
2022-08-29 01:08:43 +08:00
|> element(~s{#welcome-to-livebook a}, "Open notebook")
|> render_click()
assert to =~ "/sessions/"
{:ok, view, _} = live(conn, to)
assert render(view) =~ "Welcome to Livebook"
2023-01-05 23:12:45 +08:00
close_session_by_path(to)
end
2023-01-05 23:12:45 +08:00
defp close_session_by_path("/sessions/" <> session_id) do
{:ok, session} = Livebook.Sessions.fetch_session(session_id)
Livebook.Session.close(session.pid)
end
end