diff --git a/test/livebook/live_markdown/export_test.exs b/test/livebook/live_markdown/export_test.exs index 0bd2be45b..02ee83500 100644 --- a/test/livebook/live_markdown/export_test.exs +++ b/test/livebook/live_markdown/export_test.exs @@ -1,6 +1,8 @@ defmodule Livebook.LiveMarkdown.ExportTest do use ExUnit.Case, async: true + import Livebook.TestHelpers + alias Livebook.LiveMarkdown.Export alias Livebook.Notebook @@ -1327,7 +1329,7 @@ defmodule Livebook.LiveMarkdown.ExportTest do describe "file entries" do test "persists file entries" do - file = Livebook.FileSystem.File.new(Livebook.FileSystem.Local.new(), "/document.pdf") + file = Livebook.FileSystem.File.new(Livebook.FileSystem.Local.new(), p("/document.pdf")) notebook = %{ Notebook.new() @@ -1340,7 +1342,7 @@ defmodule Livebook.LiveMarkdown.ExportTest do } expected_document = """ - + # My Notebook """ diff --git a/test/livebook_web/live/app_live_test.exs b/test/livebook_web/live/app_live_test.exs index 4b6be821a..d355f4b44 100644 --- a/test/livebook_web/live/app_live_test.exs +++ b/test/livebook_web/live/app_live_test.exs @@ -42,6 +42,12 @@ defmodule LivebookWeb.AppLiveTest do Livebook.Session.app_deactivate(session_pid2) + assert_receive {:app_updated, + %{ + pid: ^app_pid, + sessions: [%{app_status: %{lifecycle: :deactivated}}, _] + }} + {:ok, view, _} = live(conn, ~p"/apps/#{slug}") assert render(view) =~ ~p"/apps/#{slug}/#{session_id1}" diff --git a/test/livebook_web/live/session_live_test.exs b/test/livebook_web/live/session_live_test.exs index 081a254c6..efb90ca12 100644 --- a/test/livebook_web/live/session_live_test.exs +++ b/test/livebook_web/live/session_live_test.exs @@ -1524,6 +1524,8 @@ defmodule LivebookWeb.SessionLiveTest do @tag :tmp_dir test "adding :attachment file entry from file", %{conn: conn, session: session, tmp_dir: tmp_dir} do + Session.subscribe(session.id) + path = Path.join(tmp_dir, "image.jpg") File.write!(path, "content") @@ -1543,6 +1545,8 @@ defmodule LivebookWeb.SessionLiveTest do |> element(~s{#add-file-entry-form}) |> render_submit(%{"data" => %{"name" => "image.jpg", "copy" => "true"}}) + assert_receive {:operation, {:add_file_entries, _client_id, [%{name: "image.jpg"}]}} + assert %{notebook: %{file_entries: [%{type: :attachment, name: "image.jpg"}]}} = Session.get_data(session.pid) @@ -1579,6 +1583,8 @@ defmodule LivebookWeb.SessionLiveTest do end test "adding :attachment file entry from url", %{conn: conn, session: session} do + Session.subscribe(session.id) + bypass = Bypass.open() file_url = "http://localhost:#{bypass.port}/image.jpg" @@ -1603,6 +1609,8 @@ defmodule LivebookWeb.SessionLiveTest do "data" => %{"name" => "image.jpg", "copy" => "true", "url" => file_url} }) + assert_receive {:operation, {:add_file_entries, _client_id, [%{name: "image.jpg"}]}} + assert %{notebook: %{file_entries: [%{type: :attachment, name: "image.jpg"}]}} = Session.get_data(session.pid) @@ -1703,6 +1711,8 @@ defmodule LivebookWeb.SessionLiveTest do @tag :tmp_dir test "transferring file entry", %{conn: conn, session: session, tmp_dir: tmp_dir} do + Session.subscribe(session.id) + tmp_dir = FileSystem.File.local(tmp_dir <> "/") image_file = FileSystem.File.resolve(tmp_dir, "image.jpg") :ok = FileSystem.File.write(image_file, "content") @@ -1716,11 +1726,13 @@ defmodule LivebookWeb.SessionLiveTest do |> element(~s/[data-el-files-list] menu button/, "Copy to files") |> render_click() - assert {:ok, true} = FileSystem.File.exists?(image_file) + assert_receive {:operation, {:add_file_entries, _client_id, [%{name: "image.jpg"}]}} assert %{notebook: %{file_entries: [%{type: :attachment, name: "image.jpg"}]}} = Session.get_data(session.pid) + assert {:ok, true} = FileSystem.File.exists?(image_file) + assert FileSystem.File.resolve(session.files_dir, "image.jpg") |> FileSystem.File.read() == {:ok, "content"} end