-
+
@@ -273,7 +292,7 @@ defmodule LivebookWeb.FileSelectComponent do
defp file_system_menu_button(assigns) do
~H"""
- <.menu id="file-system-menu" disabled={@file_system_select_disabled} position={:bottom_left}>
+ <.menu id={@id} disabled={@file_system_select_disabled} position={:bottom_left}>
<:toggle>
@@ -429,15 +429,15 @@ defmodule LivebookWeb.Hub.Edit.TeamComponent do
def handle_event("mark_as_default", _, socket) do
Hubs.set_default_hub(socket.assigns.hub.id)
- {:noreply, push_navigate(socket, to: ~p"/hub/#{socket.assigns.hub.id}")}
+ {:noreply, assign(socket, default?: true)}
end
def handle_event("remove_as_default", _, socket) do
Hubs.unset_default_hub()
- {:noreply, push_navigate(socket, to: ~p"/hub/#{socket.assigns.hub.id}")}
+ {:noreply, assign(socket, default?: false)}
end
- defp is_default?(hub) do
+ defp default_hub?(hub) do
Hubs.get_default_hub().id == hub.id
end
diff --git a/test/livebook_teams/web/hub/edit_live_test.exs b/test/livebook_teams/web/hub/edit_live_test.exs
index 5fe5d1f47..854aaf968 100644
--- a/test/livebook_teams/web/hub/edit_live_test.exs
+++ b/test/livebook_teams/web/hub/edit_live_test.exs
@@ -334,11 +334,9 @@ defmodule LivebookWeb.Integration.Hub.EditLiveTest do
test "marking and unmarking hub as default", %{conn: conn, hub: hub} do
{:ok, view, _html} = live(conn, ~p"/hub/#{hub.id}")
- assert {:ok, view, _html} =
- view
- |> element("a", "Mark as default")
- |> render_click()
- |> follow_redirect(conn)
+ view
+ |> element("button", "Mark as default")
+ |> render_click()
assert view
|> element("span", "Default")
@@ -346,11 +344,9 @@ defmodule LivebookWeb.Integration.Hub.EditLiveTest do
assert Hubs.get_default_hub().id == hub.id
- assert {:ok, view, _html} =
- view
- |> element("a", "Remove as default")
- |> render_click()
- |> follow_redirect(conn)
+ view
+ |> element("button", "Remove as default")
+ |> render_click()
refute view
|> element("span", "Default")
diff --git a/test/livebook_teams/web/session_live_test.exs b/test/livebook_teams/web/session_live_test.exs
index 3555733bd..f1db5ed7d 100644
--- a/test/livebook_teams/web/session_live_test.exs
+++ b/test/livebook_teams/web/session_live_test.exs
@@ -51,7 +51,6 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# clicks the button to add a new secret
view
- |> with_target("#secrets_list")
|> element("#new-secret-button")
|> render_click(%{})
@@ -76,8 +75,7 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# fills and submits the secrets modal form
# to create a new secret on team hub
- secrets_modal = with_target(view, "#secrets")
- form = element(secrets_modal, ~s{form[phx-submit="save"]})
+ form = element(view, ~s{#secrets-modal form[phx-submit="save"]})
render_change(form, attrs)
render_submit(form, attrs)
@@ -119,7 +117,6 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# clicks the button to edit a secret
view
- |> with_target("#secrets_list")
|> element("#hub-#{id}-secret-#{secret_name}-edit-button")
|> render_click()
@@ -190,8 +187,7 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# clicks the button and fills the form to create a new secret
# that prefilled the name with the received from exception.
render_click(add_secret_button)
- secrets_component = with_target(view, "#secrets-modal")
- form_element = element(secrets_component, "form[phx-submit='save']")
+ form_element = element(view, "#secrets-modal form[phx-submit='save']")
assert has_element?(form_element)
attrs = %{value: secret.value, hub_id: team.id}
render_submit(form_element, %{secret: attrs})
@@ -257,13 +253,12 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
# is being shown, so clicks it's button to set the app secret
# to the session, allowing the user to fetches the secret.
render_click(add_secret_button)
- secrets_component = with_target(view, "#secrets-modal")
- assert render(secrets_component) =~
- "in #{hub_label(team)}. Allow this session to access it?"
+ assert render(view) =~ "in #{hub_label(team)}. Allow this session to access it?"
- grant_access_button = element(secrets_component, "button", "Grant access")
- render_click(grant_access_button)
+ view
+ |> element("#secrets-modal button", "Grant access")
+ |> render_click()
# checks if the secret exists and is inside the session,
# then executes the code cell again and checks if the
@@ -294,15 +289,15 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
bucket_url = "https://my-own-bucket.s3.amazonaws.com"
- file_system =
+ team_file_system =
build(:fs_s3,
id: Livebook.FileSystem.S3.id(team_id, bucket_url),
bucket_url: bucket_url,
hub_id: team_id
)
- Livebook.Hubs.create_file_system(team, file_system)
- assert_receive {:file_system_created, team_file_system}
+ Livebook.Hubs.create_file_system(team, team_file_system)
+ assert_receive {:file_system_created, %{hub_id: ^team_id} = team_file_system}
# loads the session page
{:ok, view, _html} = live(conn, ~p"/sessions/#{session.id}/add-file/storage")
@@ -312,25 +307,21 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
Session.set_notebook_hub(session.pid, personal_id)
assert_receive {:operation, {:set_notebook_hub, _client, ^personal_id}}
- # targets the file system dropdown menu
- file_system_menu = with_target(view, "#add-file-entry-select #file-system-menu-content")
+ file_entry_select = element(view, "#add-file-entry-select")
# checks the file systems from Personal
- assert has_element?(file_system_menu, "#file-system-local")
- assert has_element?(file_system_menu, "#file-system-#{personal_file_system.id}")
- refute has_element?(file_system_menu, "#file-system-#{team_file_system.id}")
+ assert render(file_entry_select) =~ "local"
+ assert render(file_entry_select) =~ personal_file_system.id
+ refute render(file_entry_select) =~ team_file_system.id
# change the hub to Team
# and checks the file systems from Team
Session.set_notebook_hub(session.pid, team.id)
assert_receive {:operation, {:set_notebook_hub, _client, ^team_id}}
- # targets the file system dropdown menu
- file_system_menu = with_target(view, "#file-system-menu")
-
- assert has_element?(file_system_menu, "#file-system-local")
- refute has_element?(file_system_menu, "#file-system-#{personal_file_system.id}")
- assert has_element?(file_system_menu, "#file-system-#{team_file_system.id}")
+ assert render(file_entry_select) =~ "local"
+ refute render(file_entry_select) =~ personal_file_system.id
+ assert render(file_entry_select) =~ team_file_system.id
end
test "shows file system from offline hub", %{conn: conn, session: session} do
@@ -360,12 +351,10 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
Session.set_notebook_hub(session.pid, hub_id)
assert_receive {:operation, {:set_notebook_hub, _client, ^hub_id}}
- # targets the file system dropdown menu
- file_system_menu = with_target(view, "#add-file-entry-select #file-system-menu-content")
-
# checks the file systems from Offline hub
- assert has_element?(file_system_menu, "#file-system-local")
- assert has_element?(file_system_menu, "#file-system-#{file_system.id}")
+ file_entry_select = element(view, "#add-file-entry-select")
+ assert render(file_entry_select) =~ "local"
+ assert render(file_entry_select) =~ file_system.id
remove_offline_hub_file_system(file_system)
end
diff --git a/test/livebook_web/live/file_select_component_test.exs b/test/livebook_web/live/file_select_component_test.exs
index dca197fc5..946e38330 100644
--- a/test/livebook_web/live/file_select_component_test.exs
+++ b/test/livebook_web/live/file_select_component_test.exs
@@ -26,7 +26,7 @@ defmodule LivebookWeb.FileSelectComponentTest do
defp attrs(attrs) do
Keyword.merge(
[
- id: 1,
+ id: "1",
file: FileSystem.File.local(p("/")),
extnames: [".livemd"],
running_files: []
diff --git a/test/livebook_web/live/session_live_test.exs b/test/livebook_web/live/session_live_test.exs
index eadbf3f8d..ad75e41e0 100644
--- a/test/livebook_web/live/session_live_test.exs
+++ b/test/livebook_web/live/session_live_test.exs
@@ -1515,8 +1515,7 @@ defmodule LivebookWeb.SessionLiveTest do
# Clicks the button and fills the form to create a new secret
# that prefilled the name with the received from exception.
render_click(add_secret_button)
- secrets_component = with_target(view, "#secrets-modal")
- form_element = element(secrets_component, "form[phx-submit='save']")
+ form_element = element(view, "#secrets-modal form[phx-submit='save']")
assert has_element?(form_element)
render_submit(form_element, %{secret: %{value: secret.value, hub_id: secret.hub_id}})
@@ -1562,12 +1561,10 @@ defmodule LivebookWeb.SessionLiveTest do
# is being shown, so clicks it's button to set the app secret
# to the session, allowing the user to fetches the secret.
render_click(add_secret_button)
- secrets_component = with_target(view, "#secrets-modal")
- assert render(secrets_component) =~
- "in #{hub_label(secret)}. Allow this session to access it?"
+ assert render(view) =~ "in #{hub_label(secret)}. Allow this session to access it?"
- grant_access_button = element(secrets_component, "button", "Grant access")
+ grant_access_button = element(view, "#secrets-modal button", "Grant access")
render_click(grant_access_button)
# Checks if the secret exists and is inside the session,
@@ -1621,7 +1618,6 @@ defmodule LivebookWeb.SessionLiveTest do
# clicks the button to edit a secret
view
- |> with_target("#secrets_list")
|> element("#hub-#{hub.id}-secret-#{secret_name}-edit-button")
|> render_click()