2023-05-08 17:26:21 +08:00
|
|
|
defmodule LivebookWeb.AppLiveTest do
|
|
|
|
use LivebookWeb.ConnCase, async: true
|
|
|
|
|
2023-05-11 20:07:19 +08:00
|
|
|
import Livebook.SessionHelpers
|
2023-05-08 17:26:21 +08:00
|
|
|
import Phoenix.LiveViewTest
|
|
|
|
|
|
|
|
alias Livebook.Session
|
|
|
|
|
2023-05-11 20:07:19 +08:00
|
|
|
test "renders only rich output when output type is rich", %{conn: conn} do
|
2023-05-08 17:26:21 +08:00
|
|
|
session = start_session()
|
|
|
|
|
|
|
|
Session.subscribe(session.id)
|
|
|
|
|
|
|
|
slug = Livebook.Utils.random_short_id()
|
2023-05-11 20:07:19 +08:00
|
|
|
app_settings = %{Livebook.Notebook.AppSettings.new() | slug: slug, output_type: :rich}
|
2023-05-08 17:26:21 +08:00
|
|
|
Session.set_app_settings(session.pid, app_settings)
|
|
|
|
|
2023-05-11 20:07:19 +08:00
|
|
|
section_id = insert_section(session.pid)
|
|
|
|
insert_cell_with_output(session.pid, section_id, {:stdout, "Printed output"})
|
|
|
|
insert_cell_with_output(session.pid, section_id, {:plain_text, "Custom text"})
|
|
|
|
|
2023-05-08 17:26:21 +08:00
|
|
|
Session.deploy_app(session.pid)
|
|
|
|
|
|
|
|
assert_receive {:operation, {:add_app, _, _, _}}
|
|
|
|
assert_receive {:operation, {:set_app_registered, _, _, true}}
|
|
|
|
|
|
|
|
{:ok, view, _} = live(conn, ~p"/apps/#{slug}")
|
|
|
|
|
2023-05-11 20:07:19 +08:00
|
|
|
refute render(view) =~ "Printed output"
|
|
|
|
assert render(view) =~ "Custom text"
|
2023-05-08 17:26:21 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
defp start_session() do
|
|
|
|
{:ok, session} = Livebook.Sessions.create_session()
|
|
|
|
on_exit(fn -> Session.close(session.pid) end)
|
|
|
|
session
|
|
|
|
end
|
|
|
|
end
|