diff --git a/lib/livebook_web/live/hub/file_system_form_component.ex b/lib/livebook_web/live/hub/file_system_form_component.ex index ff155297a..3520352f9 100644 --- a/lib/livebook_web/live/hub/file_system_form_component.ex +++ b/lib/livebook_web/live/hub/file_system_form_component.ex @@ -127,9 +127,14 @@ defmodule LivebookWeb.Hub.FileSystemFormComponent do |> put_flash(:success, message) |> push_patch(to: socket.assigns.return_to)} else - {:error, %Ecto.Changeset{} = changeset} -> {:noreply, assign(socket, changeset: changeset)} - {:transport_error, message} -> {:noreply, assign(socket, error_message: message)} - {:error, message} -> {:noreply, assign(socket, error_message: message)} + {:error, %Ecto.Changeset{} = changeset} -> + {:noreply, assign(socket, changeset: Map.replace!(changeset, :action, :validate))} + + {:transport_error, message} -> + {:noreply, assign(socket, error_message: message)} + + {:error, message} -> + {:noreply, assign(socket, error_message: message)} end end diff --git a/lib/livebook_web/live/hub/teams/deployment_group_form_component.ex b/lib/livebook_web/live/hub/teams/deployment_group_form_component.ex index 4334cf405..367626243 100644 --- a/lib/livebook_web/live/hub/teams/deployment_group_form_component.ex +++ b/lib/livebook_web/live/hub/teams/deployment_group_form_component.ex @@ -106,7 +106,7 @@ defmodule LivebookWeb.Hub.Teams.DeploymentGroupFormComponent do |> push_patch(to: ~p"/hub/#{socket.assigns.hub.id}/deployment-groups/edit/#{id}")} else {:error, %Ecto.Changeset{} = changeset} -> - {:noreply, assign(socket, changeset: changeset)} + {:noreply, assign(socket, changeset: Map.replace!(changeset, :action, :validate))} {:transport_error, message} -> {:noreply, assign(socket, error_message: message)} diff --git a/test/livebook_teams/web/hub/edit_live_test.exs b/test/livebook_teams/web/hub/edit_live_test.exs index 3192153ae..e30e2d79c 100644 --- a/test/livebook_teams/web/hub/edit_live_test.exs +++ b/test/livebook_teams/web/hub/edit_live_test.exs @@ -104,6 +104,16 @@ defmodule LivebookWeb.Integration.Hub.EditLiveTest do assert render(view) =~ "Secret TEAM_ADD_SECRET added successfully" assert render(element(view, "#hub-secrets-list")) =~ secret.name assert secret in Livebook.Hubs.get_secrets(hub) + + # Guarantee it shows the error from API + + {:ok, view, _html} = live(conn, ~p"/hub/#{hub.id}/secrets/new") + + view + |> element("#secrets-form") + |> render_submit(attrs) + + assert render(view) =~ "has already been taken" end test "updates existing secret", %{conn: conn, hub: hub} do @@ -332,6 +342,16 @@ defmodule LivebookWeb.Integration.Hub.EditLiveTest do assert_patch(view, "/hub/#{hub.id}/deployment-groups/edit/#{id}") assert render(view) =~ "Deployment group TEAM_ADD_DEPLOYMENT_GROUP added successfully" assert deployment_group in Livebook.Teams.get_deployment_groups(hub) + + # Guarantee it shows the error from API + + {:ok, view, _html} = live(conn, ~p"/hub/#{hub.id}/deployment-groups/new") + + view + |> element("#deployment-groups-form") + |> render_submit(attrs) + + assert render(view) =~ "has already been taken" end test "updates existing deployment group", %{conn: conn, hub: hub} do