From bdbaee5a2acc5b852a2da166d02b3567e9fdc7b7 Mon Sep 17 00:00:00 2001 From: Alexander Polyankin <alexander.polyankin@metabase.com> Date: Tue, 18 Jun 2024 10:09:27 -0400 Subject: [PATCH] E2E repro for "Fix field values remapping with models & custom dropdown source in public dashboards" (#44315) --- ...dashboard-filters-reproductions.cy.spec.js | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js index a185fea3eb1..b78dc8c8985 100644 --- a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js +++ b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions.cy.spec.js @@ -2784,3 +2784,127 @@ describe("issue 44231", () => { verifyFilterByRemappedValue(); }); }); + +describe("44047", () => { + const questionDetails = { + name: "Question", + type: "question", + query: { + "source-table": REVIEWS_ID, + limit: 100, + }, + }; + + const modelDetails = { + name: "Model", + type: "model", + query: { + "source-table": REVIEWS_ID, + limit: 100, + }, + }; + + const sourceQuestionDetails = { + name: "Source question", + type: "question", + query: { + "source-table": REVIEWS_ID, + fields: [ + ["field", REVIEWS.ID, { "base-type": "type/BigInteger" }], + ["field", REVIEWS.RATING, { "base-type": "type/Integer" }], + ], + }, + }; + + const parameterDetails = { + name: "Text", + slug: "text", + id: "5a425670", + type: "string/=", + sectionId: "string", + }; + + const dashboardDetails = { + parameters: [parameterDetails], + }; + + function getQuestionDashcardDetails(dashboard, card) { + return { + dashboard_id: dashboard.id, + card_id: card.id, + parameter_mappings: [ + { + card_id: card.id, + parameter_id: parameterDetails.id, + target: [ + "dimension", + ["field", REVIEWS.RATING, { type: "type/Integer" }], + ], + }, + ], + }; + } + + function getModelDashcardDetails(dashboard, card) { + return { + dashboard_id: dashboard.id, + card_id: card.id, + parameter_mappings: [ + { + card_id: card.id, + parameter_id: parameterDetails.id, + target: ["dimension", ["field", "RATING", { type: "type/Integer" }]], + }, + ], + }; + } + + function verifyFilterWithRemapping() { + filterWidget().click(); + popover().within(() => { + cy.findByPlaceholderText("Search the list").type("Remapped"); + cy.findByText("Remapped").click(); + cy.button("Add filter").click(); + }); + } + + beforeEach(() => { + restore(); + cy.signInAsAdmin(); + cy.request("PUT", `/api/field/${REVIEWS.RATING}`, { + semantic_type: "type/Category", + }); + cy.request("POST", `/api/field/${REVIEWS.RATING}/dimension`, { + type: "internal", + name: "Rating", + }); + cy.request("POST", `/api/field/${REVIEWS.RATING}/values`, { + values: [[1, "Remapped"]], + }); + }); + + it("should be able to use remapped values from an integer field with an overridden semantic type used for a custom dropdown source in public dashboards (metabase#44047)", () => { + createQuestion(sourceQuestionDetails); + cy.createDashboardWithQuestions({ + dashboardDetails, + questions: [questionDetails, modelDetails], + }).then(({ dashboard, questions: cards }) => { + updateDashboardCards({ + dashboard_id: dashboard.id, + cards: [ + getQuestionDashcardDetails(dashboard, cards[0]), + getModelDashcardDetails(dashboard, cards[1]), + ], + }); + cy.wrap(dashboard.id).as("dashboardId"); + }); + + cy.log("verify filtering works in a regular dashboard"); + visitDashboard("@dashboardId"); + verifyFilterWithRemapping(); + + cy.log("verify filtering works in a public dashboard"); + cy.get("@dashboardId").then(visitPublicDashboard); + verifyFilterWithRemapping(); + }); +}); -- GitLab