Add info about empty Kino outputs (#1899)

This commit is contained in:
ByeongUk Choi 2023-05-08 18:26:21 +09:00 committed by GitHub
parent 06f318bc20
commit 6061901ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View file

@ -119,6 +119,10 @@ defmodule LivebookWeb.AppLive do
input_values={output_view.input_values}
/>
</div>
<div :if={@data_view.output_views == []} class="info-box">
This deployed notebook is empty. Deployed apps only render Kino outputs.
Ensure you use Kino for interactive visualizations and dynamic content.
</div>
</div>
<div style="height: 80vh"></div>
</div>

View file

@ -0,0 +1,34 @@
defmodule LivebookWeb.AppLiveTest do
use LivebookWeb.ConnCase, async: true
import Phoenix.LiveViewTest
alias Livebook.Session
test "render guidance when Kino output is empty", %{conn: conn} do
session = start_session()
Session.subscribe(session.id)
slug = Livebook.Utils.random_short_id()
app_settings = %{Livebook.Notebook.AppSettings.new() | slug: slug}
Session.set_app_settings(session.pid, app_settings)
Session.set_notebook_name(session.pid, "My app #{slug}")
Session.deploy_app(session.pid)
assert_receive {:operation, {:add_app, _, _, _}}
assert_receive {:operation, {:set_app_registered, _, _, true}}
{:ok, view, _} = live(conn, ~p"/apps/#{slug}")
assert render(view) =~
"This deployed notebook is empty. Deployed apps only render Kino outputs."
end
defp start_session() do
{:ok, session} = Livebook.Sessions.create_session()
on_exit(fn -> Session.close(session.pid) end)
session
end
end