From ddb15a6e6edba43b1868ae1f2af5a35fe9e930be Mon Sep 17 00:00:00 2001 From: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com> Date: Wed, 25 May 2022 19:33:41 +0200 Subject: [PATCH] Repro #22715: Model's column identifier is not respected (#22927) --- ...lues-override-column-identifier.cy.spec.js | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 frontend/test/metabase/scenarios/models/reproductions/22715-remapped-values-override-column-identifier.cy.spec.js diff --git a/frontend/test/metabase/scenarios/models/reproductions/22715-remapped-values-override-column-identifier.cy.spec.js b/frontend/test/metabase/scenarios/models/reproductions/22715-remapped-values-override-column-identifier.cy.spec.js new file mode 100644 index 00000000000..dc56f9d6ef1 --- /dev/null +++ b/frontend/test/metabase/scenarios/models/reproductions/22715-remapped-values-override-column-identifier.cy.spec.js @@ -0,0 +1,75 @@ +import { + restore, + visitQuestion, + popover, + filter, +} from "__support__/e2e/cypress"; + +describe.skip("issue 22715 ", () => { + beforeEach(() => { + cy.intercept("POST", "/api/dataset").as("dataset"); + cy.intercept("PUT", "/api/card/*").as("updateModel"); + + restore(); + cy.signInAsAdmin(); + }); + + it("fitlering based on the remapped column name should result in a correct query (metabase#22715)", () => { + cy.createNativeQuestion({ + native: { + query: `select 1 as "ID", current_timestamp::datetime as "ALIAS_CREATED_AT"`, + }, + }).then(({ body: { id } }) => { + // Visit the question to first load metadata + visitQuestion(id); + + // Turn the question into a model + cy.request("PUT", `/api/card/${id}`, { dataset: true }); + + // Let's go straight to the model metadata editor + cy.visit(`/model/${id}/metadata`); + + // The first column `ID` is automatically selected + mapColumnTo({ table: "Orders", column: "ID" }); + + cy.findByText("ALIAS_CREATED_AT").click(); + mapColumnTo({ table: "Orders", column: "Created At" }); + + // Make sure the column name updated before saving + cy.findByDisplayValue("Created At"); + + cy.button("Save changes").click(); + cy.wait("@updateModel"); + + cy.visit(`/model/${id}`); + cy.wait("@dataset"); + }); + + filter(); + + cy.findByTestId("sidebar-right").within(() => { + cy.findByText("Created At").click(); + cy.findByText("Today").click(); + }); + + cy.wait("@dataset"); + + cy.get(".cellData") + .should("have.length", 4) + .and("contain", "Created At"); + }); +}); + +function mapColumnTo({ table, column } = {}) { + cy.findByText("Database column this maps to") + .closest(".Form-field") + .contains("None") + .click(); + + popover() + .findByText(table) + .click(); + popover() + .findByText(column) + .click(); +} -- GitLab