From a90e9193f45ffc5e17146c9f64a84fbb80329110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 28 Feb 2023 17:28:10 +0100 Subject: [PATCH] Update app tests --- lib/livebook/session.ex | 2 +- test/livebook_web/live/apps_live_test.exs | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/livebook/session.ex b/lib/livebook/session.ex index c0f4d70ba..3ba688390 100644 --- a/lib/livebook/session.ex +++ b/lib/livebook/session.ex @@ -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 diff --git a/test/livebook_web/live/apps_live_test.exs b/test/livebook_web/live/apps_live_test.exs index 691e06fa0..9900446e5 100644 --- a/test/livebook_web/live/apps_live_test.exs +++ b/test/livebook_web/live/apps_live_test.exs @@ -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