mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 20:14:57 +08:00
Add tests
This commit is contained in:
parent
4edafb0a92
commit
7a7dc7867c
2 changed files with 59 additions and 4 deletions
|
@ -571,6 +571,56 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
|
|||
"App deployment created successfully"
|
||||
end
|
||||
|
||||
test "shows tooltip message if user is unauthorized to deploy apps",
|
||||
%{team: team, node: node, org: org, conn: conn, session: session} do
|
||||
Session.set_notebook_hub(session.pid, team.id)
|
||||
|
||||
deployment_group = TeamsRPC.create_deployment_group(node, mode: :online, org: org)
|
||||
id = to_string(deployment_group.id)
|
||||
assert_receive {:deployment_group_created, %{id: ^id, deploy_auth: false}}
|
||||
|
||||
{:ok, view, _} = live(conn, ~p"/sessions/#{session.id}")
|
||||
|
||||
view
|
||||
|> element("a", "Deploy with Livebook Teams")
|
||||
|> render_click()
|
||||
|
||||
# Step: configuring valid app settings
|
||||
|
||||
assert render(view) =~ "You must configure your app before deploying it."
|
||||
|
||||
slug = Livebook.Utils.random_short_id()
|
||||
|
||||
view
|
||||
|> element(~s/#app-settings-modal form/)
|
||||
|> render_submit(%{"app_settings" => %{"slug" => slug}})
|
||||
|
||||
# From this point forward we are in a child LV
|
||||
view = find_live_child(view, "app-teams")
|
||||
assert render(view) =~ "App deployment with Livebook Teams"
|
||||
|
||||
# show the deployment group being able to select to deploy an app
|
||||
assert has_element?(
|
||||
view,
|
||||
~s/[phx-click="select_deployment_group"][phx-value-id="#{deployment_group.id}"]/
|
||||
)
|
||||
|
||||
# then, we update the deployment group, so it will
|
||||
# update the view and show the tooltip with unauthorized error message
|
||||
{:ok, deployment_group} = TeamsRPC.toggle_deployment_authorization(node, deployment_group)
|
||||
assert_receive {:deployment_group_updated, %{id: ^id, deploy_auth: true}}
|
||||
|
||||
refute has_element?(
|
||||
view,
|
||||
~s/[phx-click="select_deployment_group"][phx-value-id="#{deployment_group.id}"]/
|
||||
)
|
||||
|
||||
assert has_element?(
|
||||
view,
|
||||
~s/[data-tooltip="You are not authorized to deploy to this deployment group"][phx-value-id="#{deployment_group.id}"]/
|
||||
)
|
||||
end
|
||||
|
||||
test "shows an error when the deployment size is higher than the maximum size of 20MB",
|
||||
%{team: team, conn: conn, session: session} do
|
||||
Session.set_notebook_hub(session.pid, team.id)
|
||||
|
@ -612,11 +662,12 @@ defmodule LivebookWeb.Integration.SessionLiveTest do
|
|||
app_settings = %{Livebook.Notebook.AppSettings.new() | slug: slug}
|
||||
Session.set_app_settings(session.pid, app_settings)
|
||||
|
||||
deployment_group =
|
||||
TeamsRPC.create_deployment_group(node, mode: :online, org: org, deploy_auth: true)
|
||||
|
||||
deployment_group = TeamsRPC.create_deployment_group(node, mode: :online, org: org)
|
||||
id = to_string(deployment_group.id)
|
||||
assert_receive {:deployment_group_created, %{id: ^id}}
|
||||
assert_receive {:deployment_group_created, %{id: ^id, deploy_auth: false}}
|
||||
|
||||
{:ok, _} = TeamsRPC.toggle_deployment_authorization(node, deployment_group)
|
||||
assert_receive {:deployment_group_updated, %{id: ^id, deploy_auth: true}}
|
||||
|
||||
Session.set_notebook_deployment_group(session.pid, id)
|
||||
assert_receive {:operation, {:set_notebook_deployment_group, _, ^id}}
|
||||
|
|
|
@ -208,4 +208,8 @@ defmodule Livebook.TeamsRPC do
|
|||
def toggle_groups_authorization(node, deployment_group) do
|
||||
:erpc.call(node, TeamsRPC, :toggle_groups_authorization, [deployment_group])
|
||||
end
|
||||
|
||||
def toggle_deployment_authorization(node, deployment_group) do
|
||||
:erpc.call(node, TeamsRPC, :toggle_deployment_authorization, [deployment_group])
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue