The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Closes EMB-1037 preview_embed endpoint for filter search (#66077)
Sébastien591b453e4ca0
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.jsindex 90c53bdad05..f98381e274c 100644--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js@@ -391,6 +391,45 @@ describe("scenarios > embedding > dashboard parameters", () => {});});+ it("should allow searching dashboard parameters in preview embed modal", () => {+ H.visitDashboard("@dashboardId");++ H.openStaticEmbeddingModal({+ activeTab: "parameters",+ previewMode: "preview",+ });++ H.modal().within(() => {+ // Set the Name parameter to enabled so we can test searching+ cy.findByText("Name")+ .parent()+ .within(() => {+ cy.findByText("Disabled").click();+ });+ });++ H.popover().findByText("Editable").click();++ // Test the preview iframe parameter search functionality+ H.getIframeBody().within(() => {+ // Open the Name filter dropdown+ cy.findByTestId("dashboard-parameters-widget-container")+ .findByText("Name")+ .click();++ // Test searching for names containing specific text+ cy.findByPlaceholderText("Search by Name").type("Af");++ // Verify that search results are filtered+ H.popover().within(() => {+ // Should show names containing "Af"+ cy.findByText("Afton Lesch").should("be.visible");+ // Should not show names that don't match the search+ cy.findByText("Lina Heaney").should("not.exist");+ });+ });+ });+it("should render error message when `params` is not an object (metabase#14474)", () => {cy.get("@dashboardId").then((dashboardId) => {cy.request("PUT", `/api/dashboard/${dashboardId}`, {diff --git a/src/metabase/embedding_rest/api/preview_embed.clj b/src/metabase/embedding_rest/api/preview_embed.cljindex f9b5cfc18c7..da572fc5d7c 100644--- a/src/metabase/embedding_rest/api/preview_embed.clj+++ b/src/metabase/embedding_rest/api/preview_embed.clj@@ -86,6 +86,16 @@(api.embed.common/parse-query-params query-params){:preview true}))+(api.macros/defendpoint :get "/dashboard/:token/params/:param-key/search/:prefix"+ "Embedded version of chain filter search endpoint."+ [{:keys [token param-key prefix]}+ query-params]+ (api.embed.common/dashboard-param-values token+ param-key+ prefix+ (api.embed.common/parse-query-params query-params)+ {:preview true}))+(api.macros/defendpoint :get "/dashboard/:token/params/:param-key/remapping""Embedded version of the remapped dashboard param value endpoint."[{:keys [token param-key]}diff --git a/test/metabase/embedding_rest/api/preview_embed_test.clj b/test/metabase/embedding_rest/api/preview_embed_test.cljindex c613b9b6b2d..5fc47427a87 100644--- a/test/metabase/embedding_rest/api/preview_embed_test.clj+++ b/test/metabase/embedding_rest/api/preview_embed_test.clj@@ -567,6 +567,19 @@:has_more_values false}(mt/user-http-request :rasta :get 200 url))))))))))+(deftest dashboard-params-search-test+ (testing "GET /api/preview_embed/dashboard/:token/params/:param-key/search/:prefix"+ (with-embedding-enabled-and-new-secret-key!+ (api.dashboard-test/with-chain-filter-fixtures [{:keys [dashboard]}]+ (t2/update! :model/Dashboard (u/the-id dashboard) {:enable_embedding false ;; works without enabling embedding on the dashboard (#44962)+ :embedding_params {"static_category_label" "enabled"}})+ (let [signed-token (dash-token dashboard)+ search-url (format "preview_embed/dashboard/%s/params/%s/search/%s" signed-token "_STATIC_CATEGORY_LABEL_" "AF")]+ (testing "Should work if the param we're fetching values for is enabled"+ (is (= {:values [["African" "Af"]]+ :has_more_values false}+ (mt/user-http-request :crowberto :get 200 search-url)))))))))+(deftest boolean-parameter-values-test(testing "embedding endpoint supports boolean parameter values (#27643)"(embed-test/with-embedding-enabled-and-new-secret-key!