Skip to content
Snippets Groups Projects
Unverified Commit 5bf50a21 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Add E2E reproduction for #39150 (#43610)

* Add E2E reproduction for #39150

* Fix typo in the test title

* Move the viewport config to the `describe` block

* Add the second repro scenario as per the review comment

* Scope the variable to the relevant test
parent c7c5b356
No related branches found
No related tags found
No related merge requests found
......@@ -7,10 +7,14 @@ import {
hovercard,
createNativeQuestion,
tableHeaderClick,
openNotebook,
enterCustomColumnDetails,
visualize,
saveQuestion,
} from "e2e/support/helpers";
import type { FieldReference } from "metabase-types/api";
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
describe("issue 29943", () => {
function reorderTotalAndCustomColumns() {
......@@ -289,3 +293,143 @@ describe("issue 23103", () => {
hovercard().findByText("4 distinct values").should("exist");
});
});
describe("issue 39150", { viewportWidth: 1600 }, () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
});
it("allows custom columns with the same name in nested models (metabase#39150-1)", () => {
const ccName = "CC Rating";
createQuestion({
name: "Source Model",
type: "model",
query: {
"source-table": PRODUCTS_ID,
expressions: {
[ccName]: [
"ceil",
[
"field",
PRODUCTS.RATING,
{
"base-type": "type/Float",
},
],
],
},
limit: 2,
},
}).then(({ body: { id: sourceModelId } }) => {
createQuestion(
{
name: "Nested Model",
type: "model",
query: {
"source-table": `card__${sourceModelId}`,
},
},
{ visitQuestion: true },
);
});
openNotebook();
cy.findByTestId("action-buttons").findByText("Custom column").click();
enterCustomColumnDetails({
formula: "floor([Rating])",
name: ccName,
blur: true,
});
cy.button("Done").click();
visualize();
cy.findAllByTestId("header-cell")
.filter(`:contains('${ccName}')`)
.should("have.length", 2);
});
it("allows custom columns with the same name as the aggregation column from the souce model (metabase#39150-2)", () => {
createQuestion({
name: "Source Model",
type: "model",
query: {
"source-table": PRODUCTS_ID,
aggregation: [["count"]],
breakout: [
[
"field",
PRODUCTS.CATEGORY,
{
"base-type": "type/Text",
},
],
],
limit: 2,
},
}).then(({ body: { id: sourceModelId } }) => {
createQuestion(
{
type: "model",
query: {
"source-table": `card__${sourceModelId}`,
},
},
{ visitQuestion: true },
);
});
openNotebook();
cy.findByTestId("action-buttons").findByText("Custom column").click();
enterCustomColumnDetails({
formula: "[Count] + 1",
name: "Count",
blur: true,
});
cy.button("Done").click();
visualize();
cy.findAllByTestId("header-cell")
.filter(":contains('Count')")
.should("have.length", 2);
saveQuestion("Nested Model", { wrapId: true, idAlias: "nestedModelId" });
cy.log("Make sure this works for the deeply nested models as well");
cy.get("@nestedModelId").then(nestedModelId => {
createQuestion(
{
type: "model",
query: {
"source-table": `card__${nestedModelId}`,
},
},
{ visitQuestion: true },
);
});
openNotebook();
cy.findByTestId("action-buttons").findByText("Custom column").click();
enterCustomColumnDetails({
formula: "[Count] + 5",
name: "Count",
blur: true,
});
cy.button("Done").click();
visualize();
cy.findAllByTestId("header-cell")
.filter(":contains('Count')")
.should("have.length", 3);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment