Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Pass validation errors to create dashboard modal (#63241)

Romeo Van Snick908eda55b5b6
diff --git a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
index 098a3be732b..786f4c02136 100644
--- a/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard/dashboard-reproductions.cy.spec.js
@@ -2180,3 +2180,28 @@ describe("issue 53370", () => {
//
});
});
+
+describe("issue 63176", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsNormalUser();
+ });
+
+ it("should not be possible to save a dashboard with an empty name and the correct error should be displayed (metabase#63176)", () => {
+ cy.visit("/");
+ H.newButton().click();
+ H.popover().findByText("Dashboard").click();
+ H.modal().within(() => {
+ cy.findByPlaceholderText("What is the name of your dashboard?").type(" ");
+ cy.button("Create").click();
+
+ cy.findByText("value must be a non-blank string.").should("be.visible");
+ cy.findByPlaceholderText("What is the name of your dashboard?").should(
+ "have.attr",
+ "aria-invalid",
+ "true",
+ );
+ cy.button("Failed").should("be.visible");
+ });
+ });
+});
diff --git a/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx b/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
index fa0fc331a8c..a2192141090 100644
--- a/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
+++ b/frontend/src/metabase/dashboard/containers/CreateDashboardForm.tsx
@@ -85,7 +85,7 @@ export function CreateDashboardForm({
const handleCreate = useCallback(
async (values: CreateDashboardProperties) => {
- const { data: dashboard } = await handleCreateDashboard(values);
+ const dashboard = await handleCreateDashboard(values).unwrap();
if (dashboard) {
onCreate?.(dashboard);
}