Skip to content
Snippets Groups Projects
Unverified Commit 8651009e authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Repro #33427 - Question editor does not work if model joins the same table more than once (#44884)


* Add repro for #33427

* Update e2e/test/scenarios/models/reproductions.cy.spec.ts

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>

---------

Co-authored-by: default avatarNemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
parent da0c9cb6
Branches
Tags
No related merge requests found
......@@ -292,7 +292,7 @@ function dashboardHasQuestions(cards) {
}
export function interceptIfNotPreviouslyDefined({ method, url, alias } = {}) {
const aliases = Object.keys(cy.state("aliases"));
const aliases = Object.keys(cy.state("aliases") ?? {});
const isAlreadyDefined = aliases.find(a => a === alias);
......
......@@ -25,7 +25,7 @@ export function openColumnOptions(column) {
}
export function renameColumn(oldName, newName) {
cy.findByDisplayValue(oldName).clear().type(newName);
cy.findByDisplayValue(oldName).clear().type(newName).blur();
}
export function setColumnType(oldType, newType) {
......
......@@ -8,12 +8,16 @@ import {
getNotebookStep,
hovercard,
join,
mapColumnTo,
modal,
openColumnOptions,
openNotebook,
openQuestionActions,
popover,
queryBuilderMain,
renameColumn,
restore,
saveMetadataChanges,
saveQuestion,
startNewModel,
startNewQuestion,
......@@ -551,3 +555,58 @@ describe.skip("issue 40635", () => {
cy.button("Done").click();
}
});
describe("issue 33427", () => {
beforeEach(() => {
restore();
cy.signInAsNormalUser();
});
it("does not confuse the names of various native model columns mapped to the same database field (metabase#33427)", () => {
createNativeQuestion(
{
type: "model",
native: {
query: `
select o.ID, p1.title as created_by, p2.title as updated_by
from ORDERS o
join PRODUCTS p1 on p1.ID = o.PRODUCT_ID
join PRODUCTS p2 on p2.ID = o.USER_ID;
`,
},
},
{ visitQuestion: true },
);
assertColumnHeaders();
cy.findByLabelText("Move, trash, and more...").click();
popover().findByText("Edit metadata").click();
openColumnOptions("CREATED_BY");
mapColumnTo({ table: "Products", column: "Title" });
renameColumn("Title", "CREATED_BY");
openColumnOptions("UPDATED_BY");
mapColumnTo({ table: "Products", column: "Title" });
renameColumn("Title", "UPDATED_BY");
assertColumnHeaders();
saveMetadataChanges();
assertColumnHeaders();
openNotebook();
getNotebookStep("data").button("Pick columns").click();
popover().within(() => {
cy.findByText("CREATED_BY").should("be.visible");
cy.findByText("UPDATED_BY").should("be.visible");
});
});
function assertColumnHeaders() {
cy.findAllByTestId("header-cell")
.should("contain", "CREATED_BY")
.and("contain", "UPDATED_BY");
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment