mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-27 17:27:51 +08:00
Update app tests
This commit is contained in:
parent
3d788df4d7
commit
a90e9193f4
2 changed files with 10 additions and 7 deletions
|
@ -1802,7 +1802,7 @@ defmodule Livebook.Session do
|
|||
defp after_operation(state, _prev_state, {:app_unregistered, _client_id}) do
|
||||
broadcast_app_message(state.session_id, {:app_registration_changed, state.session_id, false})
|
||||
|
||||
state
|
||||
notify_update(state)
|
||||
end
|
||||
|
||||
defp after_operation(state, _prev_state, _operation), do: state
|
||||
|
|
|
@ -6,8 +6,6 @@ defmodule LivebookWeb.AppsLiveTest do
|
|||
alias Livebook.{Session, Sessions}
|
||||
|
||||
test "updates UI when app is deployed and terminated", %{conn: conn} do
|
||||
{:ok, view, _} = live(conn, ~p"/apps")
|
||||
|
||||
session = start_session()
|
||||
|
||||
Sessions.subscribe()
|
||||
|
@ -18,6 +16,8 @@ defmodule LivebookWeb.AppsLiveTest do
|
|||
|
||||
Session.set_notebook_name(session.pid, "My app #{slug}")
|
||||
|
||||
{:ok, view, _} = live(conn, ~p"/apps")
|
||||
|
||||
refute render(view) =~ slug
|
||||
|
||||
Session.deploy_app(session.pid)
|
||||
|
@ -35,8 +35,6 @@ defmodule LivebookWeb.AppsLiveTest do
|
|||
end
|
||||
|
||||
test "terminating an app", %{conn: conn} do
|
||||
{:ok, view, _} = live(conn, ~p"/apps")
|
||||
|
||||
session = start_session()
|
||||
|
||||
Sessions.subscribe()
|
||||
|
@ -45,22 +43,27 @@ defmodule LivebookWeb.AppsLiveTest do
|
|||
app_settings = %{Livebook.Notebook.AppSettings.new() | slug: slug}
|
||||
Session.set_app_settings(session.pid, app_settings)
|
||||
|
||||
{:ok, view, _} = live(conn, ~p"/apps")
|
||||
|
||||
Session.deploy_app(session.pid)
|
||||
assert_receive {:session_created, %{app_info: %{slug: ^slug}}}
|
||||
|
||||
assert_receive {:session_updated, %{app_info: %{slug: ^slug, registered: true}}}
|
||||
assert_receive {:session_updated,
|
||||
%{app_info: %{slug: ^slug, status: :running, registered: true}}}
|
||||
|
||||
view
|
||||
|> element(~s/[data-app-slug="#{slug}"] button[aria-label="stop app"]/)
|
||||
|> render_click()
|
||||
|
||||
assert_receive {:session_updated, %{app_info: %{slug: ^slug, registered: false}}}
|
||||
assert_receive {:session_updated,
|
||||
%{app_info: %{slug: ^slug, status: :stopped, registered: false}}}
|
||||
|
||||
view
|
||||
|> element(~s/[data-app-slug="#{slug}"] button[aria-label="terminate app"]/)
|
||||
|> render_click()
|
||||
|
||||
assert_receive {:session_closed, %{app_info: %{slug: ^slug}}}
|
||||
|
||||
refute render(view) =~ slug
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue