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
Consolidate custom column e2e tests (#83253)
Nemanja Glumac7fd3b8d58930
diff --git a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.tsindex 8306b78b11d..eb2eec0ec60 100644--- a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts+++ b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts@@ -362,10 +362,6 @@ describe("scenarios > custom column > boolean functions", () => {);}- beforeEach(() => {- cy.signInAsNormalUser();- });-it("should be able setup an 'open question' click behavior", () => {createDashboardWithQuestion().then((dashboard) =>H.visitDashboard(dashboard.id),diff --git a/e2e/test/scenarios/custom-column/cc-fields.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-fields.cy.spec.tsindex 470b6df8a4b..68f70fc554e 100644--- a/e2e/test/scenarios/custom-column/cc-fields.cy.spec.ts+++ b/e2e/test/scenarios/custom-column/cc-fields.cy.spec.ts@@ -8,7 +8,6 @@ describe("scenarios > custom column > field resolution", () => {beforeEach(() => {H.restore();cy.signInAsNormalUser();- H.openOrdersTable({ mode: "notebook" });});it("should be possible to resolve fields in custom columns", () => {diff --git a/e2e/test/scenarios/custom-column/cc-shortcuts-combine.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-shortcuts-combine.cy.spec.tsindex ae2c13e115c..91f9a6a48a7 100644--- a/e2e/test/scenarios/custom-column/cc-shortcuts-combine.cy.spec.ts+++ b/e2e/test/scenarios/custom-column/cc-shortcuts-combine.cy.spec.ts@@ -88,21 +88,6 @@ describe("scenarios > question > custom column > expression shortcuts > combine");});- it("should pick the correct default separator based on the type of the first column", () => {- H.openOrdersTable({ mode: "notebook" });- H.addCustomColumn();- selectCombineColumns();-- selectColumn(0, "User", "Email");-- H.expressionEditorWidget().within(() => {- cy.findByText("Separated by (empty)").should("exist");- cy.findByText(/Separated by/).click();-- cy.findByLabelText("Separator").should("have.value", "");- });- });-it("should be possible to edit a previous stages' columns when there is an aggregation (metabase#43226)", () => {H.openOrdersTable({ mode: "notebook" });@@ -142,6 +127,14 @@ describe("scenarios > question > custom column > combine shortcuts", () => {selectCombineColumns();selectColumn(0, "User", "Email");++ cy.log("a text column as the first column defaults to an empty separator");+ H.expressionEditorWidget().within(() => {+ cy.findByText("Separated by (empty)").should("be.visible");+ cy.findByText(/Separated by/).click();+ cy.findByLabelText("Separator").should("have.value", "");+ });+selectColumn(1, "User", "Email");H.expressionEditorWidget().button("Done").click();diff --git a/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js b/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.jsindex 47f0d675681..b408fa41d7d 100644--- a/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js+++ b/e2e/test/scenarios/custom-column/cc-typing-suggestion.cy.spec.js@@ -14,8 +14,14 @@ describe("scenarios > question > custom column > typing suggestion", () => {it("should not suggest arithmetic operators", () => {addCustomColumn();- H.enterCustomColumnDetails({ formula: "[Price] " });- cy.findByTestId("expression-suggestions-list").should("not.exist");+ H.enterCustomColumnDetails({ formula: "[Pri", blur: false });+ H.CustomExpressionEditor.completion("Price").should("be.visible");++ H.CustomExpressionEditor.type("ce] ", { focus: false });+ H.CustomExpressionEditor.value().should("equal", "[Price] ");+ // Suggestions render as role=option in the same list that showed "Price"+ // above, so this fails as soon as an operator is offered as a suggestion+ cy.findByRole("option", { name: /^\s*[-+*/](\s|$)/ }).should("not.exist");});it("should correctly accept the chosen field suggestion", () => {@@ -34,17 +40,6 @@ describe("scenarios > question > custom column > typing suggestion", () => {H.CustomExpressionEditor.value().should("equal", "[Rating]");});- it("should correctly accept the chosen function suggestion", () => {- addCustomColumn();- H.enterCustomColumnDetails({ formula: "le", blur: false });-- H.CustomExpressionEditor.acceptCompletion();-- H.CustomExpressionEditor.helpText()- .should("be.visible")- .should("contain", "length([Comment])");- });-it("should correctly insert function suggestion with the template", () => {addCustomColumn();H.enterCustomColumnDetails({ formula: "bet", blur: false });@@ -53,10 +48,8 @@ describe("scenarios > question > custom column > typing suggestion", () => {"equal","between(column, start, end)",);- });- it("should correctly insert function suggestion with the template when it has no arguments", () => {- addCustomColumn();+ cy.log("function without arguments");H.enterCustomColumnDetails({ formula: "now", blur: false });H.CustomExpressionEditor.acceptCompletion();H.CustomExpressionEditor.value().should("equal", "now()");@@ -85,7 +78,10 @@ describe("scenarios > question > custom column > typing suggestion", () => {it("should not show suggestions for an unfocused field (metabase#31643)", () => {H.summarize({ mode: "notebook" });H.popover().findByText("Custom Expression").click();- H.enterCustomColumnDetails({ formula: "Count{enter}", blur: true });+ H.enterCustomColumnDetails({ formula: "Count", blur: false });+ H.CustomExpressionEditor.completion("Count").should("be.visible");+ H.CustomExpressionEditor.type("{enter}", { focus: false });+ H.CustomExpressionEditor.blur();H.CustomExpressionEditor.completions().should("not.exist");});@@ -120,16 +116,12 @@ describe("scenarios > question > custom column > typing suggestion", () => {cy.findByText("Learn more").trigger("mousemove");});H.CustomExpressionEditor.helpText().should("be.visible");- });- it("should be possible to collapse the help text popover", () => {- addCustomColumn();- H.enterCustomColumnDetails({ formula: "concat(", blur: false });-- H.CustomExpressionEditor.helpText().should("be.visible");- H.CustomExpressionEditor.helpTextHeader().click();- H.CustomExpressionEditor.helpText().should("not.exist");- H.CustomExpressionEditor.helpTextHeader().click();+ cy.log("right-clicking the help text should not close it (metabase#41305)");+ H.CustomExpressionEditor.helpText()+ .findByText("Combine two or more strings of text together.")+ .rightclick();+ H.popover().should("have.length", 2);H.CustomExpressionEditor.helpText().should("be.visible");});diff --git a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.jsindex 7f8c2c05afe..a35e70f5972 100644--- a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js@@ -31,32 +31,22 @@ describe("scenarios > question > custom column", () => {},{ visitQuestion: true },);+ cy.intercept("GET", "/api/automagic-dashboards/**/cell/**/compare/**").as(+ "xray",+ );+H.cartesianChartCircle().eq(5).click();H.popover().findByText(/Automatic Insights/i).click();- H.popover().findByText(/X-ray/i);+ H.popover().findByText(/X-ray/i).should("be.visible");H.popover().findByText(/Compare to the rest/i).click();- });-- it("can create a custom column (metabase#13241)", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();-- H.enterCustomColumnDetails({- formula: "1 + 1",- name: "Math",- format: true,- });- cy.button("Done").click();-- H.visualize();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("There was a problem with your question").should("not.exist");- cy.findByTestId("query-visualization-root").contains("Math");+ cy.wait("@xray").its("response.statusCode").should("eq", 200);+ cy.location("pathname").should("match", /^\/auto\/dashboard\//);+ cy.findAllByTestId("dashcard-container").should("have.length.gt", 0);});it("should not show default period in date column name (metabase#36631)", () => {@@ -78,71 +68,25 @@ describe("scenarios > question > custom column", () => {.and("not.contain.text", "Default period");});- it("should not show binning for a numeric custom column", () => {+ it("should only show bucketing options that fit the type of a custom column", () => {H.openOrdersTable({ mode: "notebook" });cy.findByLabelText("Custom column").click();-H.enterCustomColumnDetails({formula: "[Product.Price] / 2",name: "Half Price",});cy.button("Done").click();- cy.button("Summarize").click();- H.popover().findByText("Count of rows").click();-- H.getNotebookStep("summarize")- .findByText("Pick a column to group by")- .click();-- H.popover()- .findByRole("option", { name: "Half Price" })- .within(() => {- cy.findByLabelText("Binning strategy").should("not.exist");- cy.findByLabelText("Temporal bucket").should("not.exist");- })- .click();-- H.getNotebookStep("summarize")- .findByText("Half Price")- .should("be.visible");- });-- it("should show temporal units for a date/time custom column", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();-+ H.getNotebookStep("expression").icon("add").click();H.enterCustomColumnDetails({formula: "[Product.Created At]",name: "Product Date",});cy.button("Done").click();- cy.button("Summarize").click();- H.popover().findByText("Count of rows").click();-- H.getNotebookStep("summarize")- .findByText("Pick a column to group by")- .click();- H.popover()- .findByRole("option", { name: "Product Date" })- .within(() => {- cy.findByLabelText("Binning strategy").should("not.exist");- cy.findByLabelText("Temporal bucket").should("exist");- })- .click();-- H.getNotebookStep("summarize")- .findByText("Product Date: Month")- .should("be.visible");- });-- it("should not show binning options for a coordinate custom column", () => {- H.openPeopleTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();-+ H.getNotebookStep("expression").icon("add").click();H.enterCustomColumnDetails({- formula: "[Latitude]",+ formula: "[User.Latitude]",name: "UserLAT",});cy.button("Done").click();@@ -153,40 +97,46 @@ describe("scenarios > question > custom column", () => {H.getNotebookStep("summarize").findByText("Pick a column to group by").click();- H.popover()- .findByRole("option", { name: "UserLAT" })- .within(() => {+ H.popover().within(() => {+ cy.log("a regular numeric column shows binning options");+ cy.findByRole("option", { name: "Total" })+ .findByLabelText("Binning strategy")+ .should("exist");++ cy.log("numeric custom column");+ cy.findByRole("option", { name: "Half Price" }).within(() => {cy.findByLabelText("Binning strategy").should("not.exist");cy.findByLabelText("Temporal bucket").should("not.exist");- })- .click();-- H.getNotebookStep("summarize").findByText("UserLAT").should("be.visible");- });-- it("can create a custom column with an existing column name", () => {- const customFormulas = [- {- formula: "[Quantity] * 2",- name: "Double Qt",- },- {- formula: "[Quantity] * [Product.Price]",- name: "Sum Total",- },- ];+ });- customFormulas.forEach(({ formula, name }) => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();+ cy.log("coordinate custom column");+ cy.findByRole("option", { name: "UserLAT" }).within(() => {+ cy.findByLabelText("Binning strategy").should("not.exist");+ cy.findByLabelText("Temporal bucket").should("not.exist");+ });- H.enterCustomColumnDetails({ formula, name });- cy.button("Done").click();+ cy.log("date/time custom column");+ cy.findByRole("option", { name: "Product Date" })+ .within(() => {+ cy.findByLabelText("Binning strategy").should("not.exist");+ cy.findByLabelText("Temporal bucket").should("exist");+ })+ .click();+ });+ H.getNotebookStep("summarize")+ .findByText("Product Date: Month")+ .should("be.visible");- H.visualize();+ cy.log("each custom column can be picked as the breakout");+ H.getNotebookStep("summarize").findByText("Product Date: Month").click();+ H.popover().findByRole("option", { name: "Half Price" }).click();+ H.getNotebookStep("summarize")+ .findByText("Half Price")+ .should("be.visible");- cy.findByTestId("query-visualization-root").contains(name);- });+ H.getNotebookStep("summarize").findByText("Half Price").click();+ H.popover().findByRole("option", { name: "UserLAT" }).click();+ H.getNotebookStep("summarize").findByText("UserLAT").should("be.visible");});it("should create custom column with fields from aggregated data (metabase#12762)", () => {@@ -227,10 +177,10 @@ describe("scenarios > question > custom column", () => {});cy.button("Done").click();- H.visualize();+ H.visualize(({ body }) => {+ expect(body.error).to.not.exist;+ });- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("There was a problem with your question").should("not.exist");// This is a pre-save state of the question but the column name should appear// both in tabular and graph views (regardless of which one is currently selected)cy.findByTestId("query-visualization-root").contains(columnName);@@ -267,41 +217,6 @@ describe("scenarios > question > custom column", () => {.findByText("1");});- it("should be able to use custom expression after aggregation (metabase#13857)", () => {- const CE_NAME = "13857_CE";- const CC_NAME = "13857_CC";-- cy.signInAsAdmin();-- H.createQuestion(- {- name: "13857",- query: {- expressions: {- [CC_NAME]: ["*", ["field-literal", CE_NAME, "type/Float"], 1234],- },- "source-query": {- aggregation: [- [- "aggregation-options",- ["*", ["count"], 1],- { name: CE_NAME, "display-name": CE_NAME },- ],- ],- breakout: [- ["datetime-field", ["field-id", ORDERS.CREATED_AT], "month"],- ],- "source-table": ORDERS_ID,- },- },- },- { visitQuestion: true },- );-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(CC_NAME);- });-it("should work with implicit joins (metabase#14080)", () => {const CC_NAME = "OneisOne";cy.signInAsAdmin();@@ -366,8 +281,10 @@ describe("scenarios > question > custom column", () => {cy.findAllByText("57,911");});- it("should not be dropped if filter is changed after aggregation (metaabase#14193)", () => {+ it("should use custom expressions after aggregation, and not drop them if filter is changed (metabase#13857, metabase#14193)", () => {const CC_NAME = "Double the fun";+ const CE_NAME = "13857_CE";+ const CE_CC_NAME = "13857_CC";H.createQuestion({@@ -376,18 +293,37 @@ describe("scenarios > question > custom column", () => {"source-query": {"source-table": ORDERS_ID,filter: [">", ["field-id", ORDERS.SUBTOTAL], 0],- aggregation: [["sum", ["field-id", ORDERS.TOTAL]]],+ aggregation: [+ ["sum", ["field-id", ORDERS.TOTAL]],+ [+ "aggregation-options",+ ["*", ["count"], 1],+ { name: CE_NAME, "display-name": CE_NAME },+ ],+ ],breakout: [["datetime-field", ["field-id", ORDERS.CREATED_AT], "year"],],},expressions: {[CC_NAME]: ["*", ["field-literal", "sum", "type/Float"], 2],+ [CE_CC_NAME]: ["*", ["field-literal", CE_NAME, "type/Float"], 1234],},},},{ visitQuestion: true },);++ H.assertTableData({+ columns: [+ "Created At: Year",+ "Sum of Total",+ CE_NAME,+ CC_NAME,+ CE_CC_NAME,+ ],+ firstRows: [["2025", "42,156.87", "744", "84,313.74", "918,096"]],+ });// Test displays collapsed filter - click on number 1 to expand and show the filter namecy.findByTestId("filters-visibility-control").should("have.text", "1")@@ -399,8 +335,18 @@ describe("scenarios > question > custom column", () => {.find(".Icon-close").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText(CC_NAME);+ cy.wait("@dataset").its("response.body.error").should("not.exist");+ cy.findByTestId("filters-visibility-control").should("not.exist");+ H.assertTableData({+ columns: [+ "Created At: Year",+ "Sum of Total",+ CE_NAME,+ CC_NAME,+ CE_CC_NAME,+ ],+ firstRows: [["2025", "42,156.87", "744", "84,313.74", "918,096"]],+ });});it("should handle identical custom column and table column names (metabase#14255)", () => {@@ -609,40 +555,27 @@ describe("scenarios > question > custom column", () => {.should("be.visible");});- it("should allow indenting using Tab", () => {+ it("should format expression when clicking the format button", () => {H.openOrdersTable({ mode: "notebook" });cy.findByLabelText("Custom column").click();- H.enterCustomColumnDetails({ formula: "1 + 2", blur: false });-- // Tab should insert indentation- cy.realPress("Tab");- H.CustomExpressionEditor.value().should("equal", "1 + 2 ");- });-- it("should not format expression when pressing tab in the editor", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();+ cy.log("The format button is hidden while the editor is empty");+ H.CustomExpressionEditor.get().should("be.visible");+ H.CustomExpressionEditor.formatButton().should("not.exist");H.enterCustomColumnDetails({ formula: "1+1" });+ cy.log("Leaving the editor does not format the expression");+ H.CustomExpressionEditor.value().should("equal", "1+1");++ cy.log(+ "Moving focus with Tab and Shift+Tab does not format the expression",+ );cy.realPress("Tab");cy.realPress(["Shift", "Tab"]);-- // `1+1` (3 chars) is reformatted to `1 + 1` (5 chars)H.CustomExpressionEditor.value().should("equal", "1+1");H.CustomExpressionEditor.type("2");-- // Fix prevents display value from being `1 +2 1` due to cursor position- // being wrong after formatting.- // That's because the caret position after refocusing on textarea- // would still be after the 3rd characterH.CustomExpressionEditor.value().should("equal", "1+12");- });-- it("should format expression when clicking the format button", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();H.enterCustomColumnDetails({ formula: "1+1" });@@ -713,85 +646,50 @@ describe("scenarios > question > custom column", () => {);});- it("should not allow formatting when the expression contains an error", () => {+ it("should not allow formatting or saving an invalid expression, and validate it when typing", () => {H.openOrdersTable({ mode: "notebook" });cy.findByLabelText("Custom column").click();+ cy.log("non-existent field reference");H.enterCustomColumnDetails({- formula: "concat('foo', ",- });- H.CustomExpressionEditor.formatButton().should("not.exist");- });-- it("should show the format button when the expression editor is empty", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();- H.CustomExpressionEditor.formatButton().should("not.exist");- });-- it("should not allow saving the expression when it is invalid", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();-- H.enterCustomColumnDetails({- formula: "concat('foo', ",+ formula: "abcdef",name: "A custom expression",});+ H.popover()+ .contains(/^Unknown column: abcdef/i)+ .should("be.visible");+ H.expressionEditorWidget().button("Done").should("be.disabled");+ cy.log("argument validation");+ H.enterCustomColumnDetails({ formula: "SUBSTRING('foo', 0, 1)" });+ H.popover().should("contain", "Expected positive integer but found 0");H.expressionEditorWidget().button("Done").should("be.disabled");- H.CustomExpressionEditor.nameInput().focus().type("{enter}");- H.expressionEditorWidget().should("be.visible");- });- it("should validate the expression when typing", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();+ cy.log("incomplete expression");+ H.enterCustomColumnDetails({ formula: "concat('foo', " });- H.enterCustomColumnDetails({- formula: "concat('foo', ",- name: "A custom expression",- });+ H.CustomExpressionEditor.formatButton().should("not.exist");H.expressionEditorWidget().button("Done").should("be.disabled");+ H.CustomExpressionEditor.nameInput().focus().type("{enter}");+ H.expressionEditorWidget().should("be.visible");cy.log("Fix the expression");H.CustomExpressionEditor.type("{leftarrow}'bar')", { focus: true });H.expressionEditorWidget().button("Done").should("not.be.disabled");+ H.CustomExpressionEditor.formatButton().should("be.visible");});- it("should allow choosing a suggestion with Tab", () => {- H.openOrdersTable({ mode: "notebook" });- cy.findByLabelText("Custom column").click();-- H.enterCustomColumnDetails({ formula: "[Cre", blur: false });-- H.CustomExpressionEditor.completions().should("be.visible");-- // Suggestion popover shows up and this select the first one- cy.realPress("Tab");-- // Focus remains on the expression editor- cy.focused().should("have.attr", "role", "textbox");- });-- it("should be possible to use the suggestion snippet arguments", () => {- H.openOrdersTable({ mode: "notebook" });- H.addCustomColumn();-- H.CustomExpressionEditor.type("coalesc{tab}[Tax]{tab}[User ID]", {- delay: 50,- });- H.CustomExpressionEditor.value().should(- "equal",- "coalesce([Tax], [User ID])",- );- });-- it("should be possible to use the suggestion templates", () => {+ it("should be possible to fill in snippet arguments after validation runs (metabase#55164)", () => {H.openOrdersTable({ mode: "notebook" });H.addCustomColumn();H.CustomExpressionEditor.type("coalesc{tab}", { delay: 50 });+ // Let the debounced validation (DEBOUNCE_VALIDATION_MS = 1000) run while the+ // snippet is active; it must not break the snippet's argument placeholders.+ // The error is hidden while the snippet is active, so there's nothing to wait on.+ cy.wait(1300);+H.CustomExpressionEditor.type("[Tax]{tab}[User ID]", {focus: false,delay: 50,diff --git a/e2e/test/scenarios/custom-column/custom-column-2.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-2.cy.spec.jsindex f3fe9c52e6a..c6bcf414fca 100644--- a/e2e/test/scenarios/custom-column/custom-column-2.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-2.cy.spec.js@@ -4,52 +4,81 @@ import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";const { ORDERS_ID, PRODUCTS_ID, PEOPLE_ID } = SAMPLE_DATABASE;-describe(- "scenarios > question > custom column > data type",- { tags: "@external" },- () => {- function addCustomColumns(columns) {- cy.wrap(columns).each((column, index) => {- if (index) {- H.getNotebookStep("expression").icon("add").click();- } else {- cy.findByLabelText("Custom column").click();- }-- H.enterCustomColumnDetails(column);- cy.button("Done").click({ force: true });- });+function addCustomColumns(columns) {+ cy.wrap(columns).each((column, index) => {+ if (index) {+ H.getNotebookStep("expression").icon("add").click();+ } else {+ cy.findByLabelText("Custom column").click();}- function openCustomColumnInTable(table) {- H.openTable({ table, mode: "notebook" });- cy.findByText("Custom column").click();- }+ H.enterCustomColumnDetails(column);+ H.expressionEditorWidget().button("Done").click();+ });+}- beforeEach(() => {- H.restore();- H.restore("postgres-12");+describe("scenarios > question > custom column > data type", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });- cy.signInAsAdmin();+ it("should understand string functions (metabase#13217)", () => {+ H.openTable({ table: PRODUCTS_ID, mode: "notebook" });+ cy.findByLabelText("Custom column").click();++ H.enterCustomColumnDetails({+ formula: "concat([Category], [Title])",+ name: "CategoryTitle",});- it("should understand string functions (metabase#13217)", () => {- openCustomColumnInTable(PRODUCTS_ID);+ cy.button("Done").click();- H.enterCustomColumnDetails({- formula: "concat([Category], [Title])",- name: "CategoryTitle",- });+ H.filter({ mode: "notebook" });- cy.button("Done").click();+ H.popover().within(() => {+ cy.findByText("CategoryTitle").click();+ cy.findByPlaceholderText("Enter a number").should("not.exist");+ cy.findByPlaceholderText("Enter some text").should("be.visible");+ });+ });- H.filter({ mode: "notebook" });+ it("should relay the type of a date field", () => {+ H.openTable({ table: PEOPLE_ID, mode: "notebook" });+ addCustomColumns([{ name: "DoB", formula: "[Birth Date]" }]);+ assertRelativeDateFilter("DoB");+ });- H.popover().within(() => {- cy.findByText("CategoryTitle").click();- cy.findByPlaceholderText("Enter a number").should("not.exist");- cy.findByPlaceholderText("Enter some text").should("be.visible");- });+ it("should handle COALESCE", () => {+ H.openTable({ table: ORDERS_ID, mode: "notebook" });+ addCustomColumns([+ {+ name: "MiscDate",+ formula: "COALESCE([Product → Created At], [Created At])",+ },+ ]);+ assertRelativeDateFilter("MiscDate");+ });++ function assertRelativeDateFilter(columnName) {+ H.filter({ mode: "notebook" });+ H.popover().within(() => {+ cy.findByText(columnName).click();+ cy.findByPlaceholderText("Enter a number").should("not.exist");+ cy.findByText("Relative date range…").click();+ cy.findByText("Previous").click();+ cy.findByDisplayValue("days").should("be.visible");+ });+ }+});++describe(+ "scenarios > question > custom column > data type > date functions",+ { tags: "@external" },+ () => {+ beforeEach(() => {+ H.restore("postgres-12");+ cy.signInAsAdmin();});it("should understand date functions", () => {@@ -59,7 +88,7 @@ describe(cy.findByText("Orders").click();});- addCustomColumns([+ const dateColumns = [{ name: "Year", formula: "year([Created At])" },{ name: "Quarter", formula: "quarter([Created At])" },{ name: "Month", formula: "month([Created At])" },@@ -78,106 +107,31 @@ describe(formula: 'datetimeSubtract([Created At], 1, "month")',},{- name: "ConvertTimezone 3 args",+ // Created At has no timezone on this database, so the source timezone is required+ name: "ConvertTimezone",formula: 'convertTimezone([Created At], "Asia/Ho_Chi_Minh", "UTC")',},- {- name: "ConvertTimezone 2 args",- formula: 'convertTimezone([Created At], "Asia/Ho_Chi_Minh")',- },- ]);-- H.visualize();- });-- it("should relay the type of a date field", () => {- openCustomColumnInTable(PEOPLE_ID);-- H.enterCustomColumnDetails({ formula: "[Birth Date]", name: "DoB" });- cy.button("Done").click();-- H.filter({ mode: "notebook" });- H.popover().within(() => {- cy.findByText("DoB").click();- cy.findByPlaceholderText("Enter a number").should("not.exist");- cy.findByText("Relative date range…").click();- cy.findByText("Previous").click();- cy.findByDisplayValue("days").should("be.visible");- });- });-- it("should handle CASE (metabase#13122)", () => {- openCustomColumnInTable(ORDERS_ID);+ ];+ addCustomColumns(dateColumns);+ cy.log(+ "the editor accepts convertTimezone without the optional source timezone",+ );+ H.getNotebookStep("expression").icon("add").click();H.enterCustomColumnDetails({- formula: "case([Discount] > 0, [Created At], [Product → Created At])",- name: "MiscDate",+ formula: 'convertTimezone([Created At], "Asia/Ho_Chi_Minh")',+ name: "ConvertTimezone 2 args",});- cy.button("Done").click();+ H.expressionEditorWidget().button("Done").should("be.enabled");+ H.expressionEditorWidget().button("Cancel").click();- H.filter({ mode: "notebook" });- H.popover().within(() => {- cy.findByText("MiscDate").click();- cy.findByPlaceholderText("Enter a number").should("not.exist");-- cy.findByText("Relative date range…").click();- cy.findByText("Previous").click();- cy.findByDisplayValue("days").should("be.visible");- });- });-- it("should handle COALESCE", () => {- openCustomColumnInTable(ORDERS_ID);-- H.enterCustomColumnDetails({- formula: "COALESCE([Product → Created At], [Created At])",- name: "MiscDate",- });- cy.button("Done").click();-- H.filter({ mode: "notebook" });- H.popover().within(() => {- cy.findByText("MiscDate").click();- cy.findByPlaceholderText("Enter a number").should("not.exist");- cy.findByText("Relative date range…").click();- cy.findByText("Previous").click();- cy.findByDisplayValue("days").should("be.visible");+ H.visualize(({ body }) => {+ expect(body.error).to.not.exist;});});},);-describe("scenarios > question > custom column > error feedback", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.openProductsTable({ mode: "notebook" });- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Custom column").click();- });-- it("should catch non-existent field reference", () => {- H.enterCustomColumnDetails({- formula: "abcdef",- name: "Non-existent",- });-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains(/^Unknown column: abcdef/i);- });-- it("should fail on expression validation errors", () => {- H.enterCustomColumnDetails({- formula: "SUBSTRING('foo', 0, 1)",- name: "BadSubstring",- });-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains(/positive integer/i);- });-});-// ExpressionEditorTextfield jsx componentdescribe("scenarios > question > custom column > expression editor", () => {beforeEach(() => {@@ -198,12 +152,18 @@ describe("scenarios > question > custom column > expression editor", () => {cy.button("Done").should("not.be.disabled");});- it("should not accidentally delete Custom Column formula value and/or Custom Column name (metabase#15734)", () => {+ it("should not erase Custom Column formula and Custom Column name on cursor moves or window resize (metabase#15734, metabase#16127)", () => {H.CustomExpressionEditor.type("{movetoend}{leftarrow}{movetostart}{rightarrow}{rightarrow}",);cy.findByDisplayValue("Math").focus();cy.button("Done").should("not.be.disabled");+ H.CustomExpressionEditor.value().should("equal", "1+1");++ cy.viewport(1260, 800);+ cy.findByDisplayValue("Math").should("be.visible");+ H.CustomExpressionEditor.value().should("equal", "1+1");+ cy.button("Done").should("not.be.disabled");});it("should not erase Custom column formula and Custom column name when expression is incomplete (metabase#16126)", () => {@@ -213,12 +173,6 @@ describe("scenarios > question > custom column > expression editor", () => {cy.findByText("Expected expression");cy.button("Done").should("be.disabled");});-- it("should not erase Custom Column formula and Custom Column name on window resize (metabase#16127)", () => {- cy.viewport(1260, 800);- cy.findByDisplayValue("Math");- cy.button("Done").should("not.be.disabled");- });});describe("scenarios > question > custom column > help text", () => {@@ -231,64 +185,42 @@ describe("scenarios > question > custom column > help text", () => {cy.findByText("Custom column").click();});- it("should appear while inside a function", () => {- H.enterCustomColumnDetails({ formula: "lower(", blur: false });- H.CustomExpressionEditor.helpTextHeader()- .should("be.visible")- .should("contain", "lower(value)");- });-- it("should appear after a field reference", () => {+ it("should appear after a field reference and disappear outside the function", () => {H.enterCustomColumnDetails({ formula: "lower([Category]", blur: false });H.CustomExpressionEditor.helpTextHeader().should("be.visible").should("contain", "lower(value)");- });- it("should not appear while outside a function", () => {- H.enterCustomColumnDetails({ formula: "lower([Category])", blur: false });+ H.CustomExpressionEditor.type(")", { focus: false });+ H.CustomExpressionEditor.value().should("equal", "lower([Category])");H.CustomExpressionEditor.helpTextHeader().should("not.exist");});it("should not appear when formula field is not in focus (metabase#15891)", () => {- H.enterCustomColumnDetails({- formula: "rou{enter}1.5{leftArrow}",- blur: false,- });+ H.enterCustomColumnDetails({ formula: "rou{enter}", blur: false });+ cy.log("Accepting a function suggestion should show its help text");H.CustomExpressionEditor.helpText().should("be.visible").should("contain", "round([Temperature])");- cy.log("Blur event should remove the expression helper popover");- H.CustomExpressionEditor.blur();- H.CustomExpressionEditor.helpText().should("not.exist");-- H.CustomExpressionEditor.focus().type("{leftArrow}");+ H.CustomExpressionEditor.type("1.5{leftArrow}", { focus: false });H.CustomExpressionEditor.helpText().should("be.visible").should("contain", "round([Temperature])");- cy.log(- "Pressing `escape` key should also remove the expression helper popover",- );+ cy.log("Blur event should remove the expression helper popover");H.CustomExpressionEditor.blur();H.CustomExpressionEditor.helpText().should("not.exist");- });-- it("should not disappear when clicked on (metabase#17548)", () => {- H.enterCustomColumnDetails({ formula: "round(", blur: false });+ H.CustomExpressionEditor.focus().type("{leftArrow}");H.CustomExpressionEditor.helpText().should("be.visible").should("contain", "round([Temperature])");- // Shouldn't hide on click- H.CustomExpressionEditor.helpText().click();-- H.CustomExpressionEditor.helpText()- .should("be.visible")- .should("contain", "round([Temperature])");+ cy.log("Blurring again should remove the expression helper popover again");+ H.CustomExpressionEditor.blur();+ H.CustomExpressionEditor.helpText().should("not.exist");});describe("scenarios > question > custom column > help text > visibility", () => {@@ -359,7 +291,7 @@ describe("scenarios > question > custom column > help text", () => {H.CustomExpressionEditor.helpTextHeader().click();assertSuggestionsAreVisible();- cy.log("help text should remain shown after finishing typing");+ cy.log("neither should be shown after finishing typing");H.CustomExpressionEditor.type("ing], ", { focus: false });assertNeitherAreVisible();});@@ -397,35 +329,44 @@ describe("scenarios > question > custom column > exiting the editor", () => {cy.findByText("Custom column").click();});- it("should be possible to close the custom expression editor by pressing Escape when it is empty", () => {+ it("should only be possible to close the custom expression editor by pressing Escape when it is empty", () => {+ cy.log("untouched editor");// The editor loads lazily. Escape sent before it takes focus does not reach the popover.H.CustomExpressionEditor.get().get(".cm-editor").should("have.class", "cm-focused");cy.realPress("Escape");- H.CustomExpressionEditor.get().should("not.exist");- });+ H.expressionEditorWidget().should("not.exist");+ H.getNotebookStep("expression").icon("add").click();- it("should not be possible to close the custom expression editor by pressing Escape when it is not empty", () => {+ cy.log("editor with text");H.CustomExpressionEditor.type("count(");cy.realPress("Escape");H.CustomExpressionEditor.get().should("be.visible");++ H.CustomExpressionEditor.clear();+ H.CustomExpressionEditor.value().should("equal", "");+ cy.realPress("Escape");+ H.CustomExpressionEditor.get().should("not.exist");});it("should be possible to exit the editor by clicking outside of it when there is no text", () => {+ cy.log("clicking a non-interactive element");+ H.CustomExpressionEditor.get().should("be.visible");H.getNotebookStep("data").click();H.modal().should("not.exist");H.expressionEditorWidget().should("not.exist");- });+ H.getNotebookStep("expression").icon("add").click();- it("should be possible to exit the editor by clicking outside of it when there is no text, by clicking an interactive element", () => {+ cy.log("clicking an interactive element");+ H.CustomExpressionEditor.get().should("be.visible");H.getNotebookStep("data").button("Pick columns").click();H.modal().should("not.exist");H.expressionEditorWidget().should("not.exist");H.popover().findByText("Select all").should("be.visible");});- it("should not be possible to exit the editor by clicking outside of it when there is an unsaved expression", () => {+ it("should ask to keep editing or discard changes when clicking outside of the editor with an unsaved expression", () => {H.enterCustomColumnDetails({ formula: "1+1", blur: false });H.getNotebookStep("data").button("Pick columns").click();H.popover().findByText("Select all").should("not.exist");@@ -441,10 +382,9 @@ describe("scenarios > question > custom column > exiting the editor", () => {H.modal().should("not.exist");H.expressionEditorWidget().should("exist");- });+ H.CustomExpressionEditor.value().should("equal", "1+1");- it("should be possible to discard changes when clicking outside of the editor", () => {- H.enterCustomColumnDetails({ formula: "1+1", blur: false });+ cy.log("Discard changes");H.getNotebookStep("data").button("Pick columns").click();H.expressionEditorWidget().should("exist");H.popover().findByText("Select all").should("not.exist");@@ -472,16 +412,17 @@ describe("scenarios > question > custom column > exiting the editor", () => {it("should be possible to close the popover when navigating away from the expression editor", () => {H.expressionEditorWidget().button("Cancel").click();cy.button("Summarize").click();- H.popover().as("popover").findByText("Custom Expression").click();+ H.popover().findByText("Custom Expression").click();H.enterCustomColumnDetails({ formula: "1+1" });cy.log("Go back to summarize modal");H.popover().findByText("Custom Expression").click();+ H.popover().findByText("Count of rows").should("be.visible");cy.log("Close summarize modal by clicking outside");cy.findByLabelText("View SQL").click();H.modal().should("not.exist");- cy.get("popover").should("not.exist");+ cy.get(H.POPOVER_ELEMENT).should("not.exist");});});diff --git a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.jsindex fd6b15e02c1..4c38cf110ae 100644--- a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js@@ -150,6 +150,14 @@ describe("scenarios > question > custom column > function browser", () => {"equal",'datetimeAdd(day("foo"), day())',);++ cy.log("parens are inserted even when the clause has no arguments");+ H.CustomExpressionEditor.clear();+ H.CustomExpressionEditor.functionBrowser().within(() => {+ cy.findByPlaceholderText("Search functions…").type("now");+ cy.findByText("now").click();+ });+ H.CustomExpressionEditor.value().should("equal", "now()");});it("should be possible to replace text when inserting functions", () => {@@ -179,14 +187,17 @@ describe("scenarios > question > custom column > function browser", () => {//cy.findByPlaceholderText("Search functions…").clear();cy.findByText("datetimeAdd").should("exist");- });- });- it("should not show functions that are not supported by the current database", () => {- H.expressionEditorWidget().button("Function browser").click();+ cy.log("show a message when no functions match the filter");+ cy.findByPlaceholderText("Search functions…").type("foobar");+ cy.findByText("Didn't find any results").should("be.visible");- H.CustomExpressionEditor.functionBrowser().within(() => {- cy.findByPlaceholderText("Search functions…").type("convertTimezone");+ cy.log("functions unsupported by the current database are hidden");+ cy.findByPlaceholderText("Search functions…")+ .clear()+ .type("convertTimezone")+ .should("have.value", "convertTimezone");+ cy.findByText("Didn't find any results").should("be.visible");cy.findByText("convertTimezone").should("not.exist");});});@@ -208,23 +219,6 @@ describe("scenarios > question > custom column > function browser", () => {cy.findByText("Count").should("be.visible");});});-- it("show a message when no functions match the filter", () => {- H.expressionEditorWidget().button("Function browser").click();- H.CustomExpressionEditor.functionBrowser().within(() => {- cy.findByPlaceholderText("Search functions…").type("foobar");- cy.findByText("Didn't find any results").should("be.visible");- });- });-- it("should insert parens even when the clause has no arguments", () => {- H.expressionEditorWidget().button("Function browser").click();- H.CustomExpressionEditor.functionBrowser().within(() => {- cy.findByPlaceholderText("Search functions…").type("now");- cy.findByText("now").click();- });- H.CustomExpressionEditor.value().should("equal", "now()");- });});describe("scenarios > question > custom column > splitPart", () => {@@ -258,6 +252,14 @@ describe("scenarios > question > custom column > splitPart", () => {it("should be possible to split a custom column", () => {const CC_NAME = "Split Title";+ cy.log("index below 1 is invalid");+ H.enterCustomColumnDetails({+ formula: "splitPart([Name], ' ', 0)",+ name: CC_NAME,+ });+ H.popover().button("Done").should("be.disabled");+ H.popover().should("contain", "Expected positive integer but found 0");+H.enterCustomColumnDetails({formula: "splitPart([Name], ' ', 1)",name: CC_NAME,@@ -272,15 +274,6 @@ describe("scenarios > question > custom column > splitPart", () => {H.tableInteractiveScrollContainer().scrollTo("right");assertTableData({ title: CC_NAME, value: "Hudson" });});-- it("should show a message when index is below 1", () => {- H.enterCustomColumnDetails({- formula: "splitPart([Name], ' ', 0)",- });-- H.popover().button("Done").should("be.disabled");- H.popover().should("contain", "Expected positive integer but found 0");- });});describe("exercise today() function", () => {@@ -325,10 +318,9 @@ describe("scenarios > question > custom column > aggregation", () => {beforeEach(() => {H.restore();cy.signInAsNormalUser();- H.openOrdersTable({ mode: "notebook" });});- it("should be possible to resolve aggregations from the question", () => {+ it("should be possible to resolve aggregations from the question directly", () => {H.createQuestion({query: {@@ -357,55 +349,24 @@ describe("scenarios > question > custom column > aggregation", () => {.should("be.visible").click();H.CustomExpressionEditor.value().should("eq", "[Custom Sum]");++ cy.log("keep typing after picking the completion");H.CustomExpressionEditor.type("+ 1");H.CustomExpressionEditor.format();-+ H.CustomExpressionEditor.value().should("eq", "[Custom Sum] + 1");H.CustomExpressionEditor.nameInput().type("Derived");- H.popover().button("Done").click();+ H.popover().button("Done").should("be.enabled");- H.visualize();- H.assertTableData({- columns: ["Custom Sum", "Derived"],- });- });-- it("should be possible to resolve aggregations from the question directly", () => {- H.createQuestion(- {- query: {- "source-table": ORDERS_ID,- aggregation: [- [- "aggregation-options",- ["sum", ["field", ORDERS.TOTAL, null]],- {- name: "Custom Sum",- "display-name": "Custom Sum",- },- ],- ],- },- },- { visitQuestion: true },- );- H.openNotebook();-- H.getNotebookStep("summarize").icon("add").click();- H.popover().findByText("Custom Expression").scrollIntoView().click();-- H.CustomExpressionEditor.type("[Custom");- H.CustomExpressionEditor.completion("Custom Sum")- .should("be.visible")- .click();+ cy.log("reference the aggregation on its own");+ H.CustomExpressionEditor.type("{backspace}".repeat(4));H.CustomExpressionEditor.value().should("eq", "[Custom Sum]");H.CustomExpressionEditor.format();-- H.CustomExpressionEditor.nameInput().type("Derived");H.popover().button("Done").click();H.visualize();H.assertTableData({columns: ["Custom Sum", "Derived"],+ firstRows: [["1,510,621.68", "1,510,621.68"]],});});@@ -444,6 +405,7 @@ describe("scenarios > question > custom column > aggregation", () => {H.visualize();H.assertTableData({columns: ["Custom Sum", "Derived"],+ firstRows: [["1,510,621.68", "1,510,621.68"]],});});@@ -483,38 +445,6 @@ describe("scenarios > question > custom column > aggregation", () => {.should("be.visible");});- it("should be possible to create aggregations with the same name", () => {- H.createQuestion(- {- query: {- "source-table": ORDERS_ID,- aggregation: [- [- "aggregation-options",- ["sum", ["field", ORDERS.TOTAL, null]],- {- name: "Foo",- "display-name": "Foo",- },- ],- ],- },- },- { visitQuestion: true },- );- H.openNotebook();-- H.getNotebookStep("summarize").icon("add").click();- H.popover().findByText("Custom Expression").scrollIntoView().click();- H.CustomExpressionEditor.type("Min([Total])");- H.CustomExpressionEditor.nameInput().type("Foo");- H.popover().button("Done").click();-- H.getNotebookStep("summarize").within(() => {- cy.findAllByText("Foo").should("have.length", 2);- });- });-it("should be possible to reorder aggregations with the same name", () => {H.createQuestion({@@ -804,7 +734,7 @@ describe("scenarios > question > custom column > aggregation", () => {});});- it("should be possible to use nested aggregations in breakout of a follow up stage", () => {+ it("should be possible to summarize nested aggregations in a follow up stage", () => {H.getNotebookStep("summarize").within(() => {H.summarize({ mode: "notebook" });});@@ -817,79 +747,79 @@ describe("scenarios > question > custom column > aggregation", () => {firstRows: [["49"]],});});+ });- it("should be possible reference both aggregations with same name in follow up stage", () => {- H.openOrdersTable({ mode: "notebook" });+ it("should be possible reference both aggregations with same name in follow up stage", () => {+ H.openOrdersTable({ mode: "notebook" });- H.summarize({ mode: "notebook" });+ H.summarize({ mode: "notebook" });- H.popover().findByText("Custom Expression").scrollIntoView().click();- H.CustomExpressionEditor.type("Count() + 1");- H.CustomExpressionEditor.nameInput().type("Count");- H.popover().button("Done").click();+ H.popover().findByText("Custom Expression").scrollIntoView().click();+ H.CustomExpressionEditor.type("Count() + 1");+ H.CustomExpressionEditor.nameInput().type("Count");+ H.popover().button("Done").click();- H.getNotebookStep("summarize").icon("add").click();- H.popover().findByText("Custom Expression").scrollIntoView().click();- H.CustomExpressionEditor.type("[Count] + 1");- H.CustomExpressionEditor.nameInput().type("Count");- H.popover().button("Done").click();+ H.getNotebookStep("summarize").icon("add").click();+ H.popover().findByText("Custom Expression").scrollIntoView().click();+ H.CustomExpressionEditor.type("[Count] + 1");+ H.CustomExpressionEditor.nameInput().type("Count");+ H.popover().button("Done").click();- H.getNotebookStep("summarize")- .findByText("Pick a column to group by")- .click();- H.popover().findByText("Created At").click();+ H.getNotebookStep("summarize")+ .findByText("Pick a column to group by")+ .click();+ H.popover().findByText("Created At").click();- cy.log("Filter by the first Count");- H.getNotebookStep("summarize").within(() => {- H.filter({ mode: "notebook" });- });- H.popover().within(() => {- cy.findAllByText("Count").should("have.length", 2);+ cy.log("Filter by the first Count");+ H.getNotebookStep("summarize").within(() => {+ H.filter({ mode: "notebook" });+ });+ H.popover().within(() => {+ cy.findAllByText("Count").should("have.length", 2);- cy.findAllByText("Count").eq(0).click();+ cy.findAllByText("Count").eq(0).click();- // if this was referencing the second Count, it would filter out all rows- cy.findByPlaceholderText("Max").type("2.5");- cy.button("Add filter").click();- });+ // if this was referencing the second Count, it would filter out all rows+ cy.findByPlaceholderText("Max").type("2.5");+ cy.button("Add filter").click();+ });- cy.log("Filter by the second Count");- H.getNotebookStep("filter", { stage: 1 }).icon("add").click();- H.popover().within(() => {- cy.findAllByText("Count").should("have.length", 2);+ cy.log("Filter by the second Count");+ H.getNotebookStep("filter", { stage: 1 }).icon("add").click();+ H.popover().within(() => {+ cy.findAllByText("Count").should("have.length", 2);- cy.findAllByText("Count").eq(1).click();+ cy.findAllByText("Count").eq(1).click();- // if this was referencing the first Count, it would filter out all rows- cy.findByPlaceholderText("Min").type("2.5");- cy.button("Add filter").click();- });+ // if this was referencing the first Count, it would filter out all rows+ cy.findByPlaceholderText("Min").type("2.5");+ cy.button("Add filter").click();+ });- H.visualize();- H.assertTableData({- columns: ["Created At: Month", "Count", "Count"],- firstRows: [["April 2025", "2", "3"]],- });+ H.visualize();+ H.assertTableData({+ columns: ["Created At: Month", "Count", "Count"],+ firstRows: [["April 2025", "2", "3"]],+ });- cy.log(- "Swapping the aggregation clauses should not change the results, but the column order will be different",- );- H.openNotebook();- H.getNotebookStep("summarize")- .findAllByText("Count")- .should("have.length", 2)- .last()- .as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- horizontal: -400,- useMouseEvents: true,- });+ cy.log(+ "Swapping the aggregation clauses should not change the results, but the column order will be different",+ );+ H.openNotebook();+ H.getNotebookStep("summarize")+ .findAllByText("Count")+ .should("have.length", 2)+ .last()+ .as("dragElement");+ H.moveDnDKitElementByAlias("@dragElement", {+ horizontal: -400,+ useMouseEvents: true,+ });- H.visualize();- H.assertTableData({- columns: ["Created At: Month", "Count", "Count"],- firstRows: [["April 2025", "3", "2"]],- });+ H.visualize();+ H.assertTableData({+ columns: ["Created At: Month", "Count", "Count"],+ firstRows: [["April 2025", "3", "2"]],});});diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.jsindex f9400a3cf36..50a78ce1436 100644--- a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js@@ -80,6 +80,8 @@ describe("issue 14843", () => {// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText(`${CC_NAME} is not equal to 3`);+ // Rye (length 3) is the city of the 4th person, so it would render without the filter+ H.tableInteractiveBody().findByText("Hudson Borer").should("be.visible");// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Rye").should("not.exist");});@@ -596,9 +598,20 @@ describe("issue 24922", () => {H.enterCustomColumnDetails(customColumnDetails);cy.button("Done").click();- H.visualize();+ H.visualize(({ body }) => {+ expect(body.error).to.not.exist;+ });// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("CustomColumn").should("be.visible");+ // The first order's total is under 100, the second one's is not+ H.tableInteractiveBody()+ .findAllByText("Segment")+ .first()+ .should("be.visible");+ H.tableInteractiveBody()+ .findAllByText("Other")+ .first()+ .should("be.visible");});});@@ -775,6 +788,7 @@ describe("issue 49882", () => {H.CustomExpressionEditor.acceptCompletion("tab");H.CustomExpressionEditor.value().should("equal", "[Product → Rating]");+ cy.focused().should("have.attr", "role", "textbox");});});@@ -883,25 +897,6 @@ describe("issue 49304", () => {});});-describe("issue 41305", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should allow to right click in the suggestion popover without closing it (metabase#41305)", () => {- H.openProductsTable({ mode: "notebook" });- H.addCustomColumn();- H.enterCustomColumnDetails({ formula: "contains(", blur: false });- H.popover()- .should("have.length", 2)- .last()- .findByText("The column or text to check.")- .rightclick();- H.popover().should("have.length", 2);- });-});-describe("issue 49305", () => {beforeEach(() => {H.restore();@@ -1031,16 +1026,18 @@ describe("issue 50925", () => {H.getNotebookStep("expression").findByText("Custom").click();H.CustomExpressionEditor.focus()- .type("{leftarrow}".repeat(9))- .type(" [Pr", { focus: false });+ .type("{leftarrow}".repeat(8))+ .type("[Pr", { focus: false });- cy.wait(300);H.CustomExpressionEditor.completions().should("be.visible");H.CustomExpressionEditor.get().realPress("Enter", { pressDelay: 10 });H.CustomExpressionEditor.blur().value()- .should("equal", "case([ID] = 1, [Price] * 1.21, [Price] [Price])");+ .should(+ "match",+ /^case\(\[ID\] = 1, \[Price\] \* 1\.21, \[Price\]\s*\[Price\]\)$/,+ );});});@@ -1062,6 +1059,14 @@ describe("issue 53682", () => {);cy.button("Done").should("be.disabled");});++ cy.log("Editing the name should not crash the editor");+ H.CustomExpressionEditor.nameInput().click().type("Name");+ H.expressionEditorWidget().should("be.visible");+ H.CustomExpressionEditor.nameInput().should("have.value", "Name");+ H.popover()+ .findByText("Function contains expects at least 2 arguments")+ .should("be.visible");});});diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.jsindex 246438972db..6406a4efe28 100644--- a/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions-2.cy.spec.js@@ -37,7 +37,7 @@ describe("issue #31964", () => {H.openOrdersTable({ mode: "notebook" });});- it("should focus the editor when opening it (metabase#54722)", () => {+ it("should apply a completion on a new line inside case (metabase#31964)", () => {H.addCustomColumn();H.CustomExpressionEditor.type('case([Product -> Category] = "Widget", 1,');cy.realPress("Enter");@@ -94,36 +94,28 @@ describe("issue #55984", () => {H.openOrdersTable({ mode: "notebook" });});- it("should not overflow the suggestion tooltip when a suggestion name is too long (metabase#55984)", () => {+ it("should not overflow the suggestion tooltip when a suggestion name is too long, with or without spaces (metabase#55984)", () => {+ const longName =+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt";+ const longNameWithoutSpaces = longName.replaceAll(" ", "_");+H.addCustomColumn();- H.enterCustomColumnDetails({- formula: "[Total]",- name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt",- });+ H.enterCustomColumnDetails({ formula: "[Total]", name: longName });cy.button("Done").click();- H.summarize({ mode: "notebook" });- H.popover().findByText("Custom Expression").click();- H.CustomExpressionEditor.type("[lo");- H.CustomExpressionEditor.completions().should(($el) => {- expect(H.isScrollableHorizontally($el[0])).to.be.false;- });- });-- it("should not overflow the suggestion tooltip when a suggestion name is too long and has no spaces (metabase#55984)", () => {- H.addCustomColumn();+ H.getNotebookStep("expression").icon("add").click();H.enterCustomColumnDetails({formula: "[Total]",- name: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt".replaceAll(- " ",- "_",- ),+ name: longNameWithoutSpaces,});cy.button("Done").click();H.summarize({ mode: "notebook" });H.popover().findByText("Custom Expression").click();H.CustomExpressionEditor.type("[lo");+ // The list scrolls vertically, so the second long suggestion can be out of view+ H.CustomExpressionEditor.completion(longName).should("exist");+ H.CustomExpressionEditor.completion(longNameWithoutSpaces).should("exist");H.CustomExpressionEditor.completions().should(($el) => {expect(H.isScrollableHorizontally($el[0])).to.be.false;});@@ -335,11 +327,11 @@ describe("issue 55300", () => {H.CustomExpressionEditor.type("Sum(case(Count, Count(), 0))");- cy.log("Move cursor over now()");+ cy.log("Move cursor over Count()");H.CustomExpressionEditor.type("{leftarrow}".repeat(7));H.CustomExpressionEditor.helpTextHeader().should("contain", "Count()");- cy.log("Move cursor over now");+ cy.log("Move cursor over Count");H.CustomExpressionEditor.type("{leftarrow}".repeat(18));H.CustomExpressionEditor.helpTextHeader().should("contain", "case");@@ -487,14 +479,22 @@ describe("issue 57674", () => {it("should not show an error when using a case or if expression with compatible types (metabase#57674)", () => {H.getNotebookStep("data").button("Custom column").click();- H.CustomExpressionEditor.clear();- H.popover().findByText("Types are incompatible.").should("not.exist");-- H.CustomExpressionEditor.type('case([Total] > 100, "foo", "bar")', {+ H.CustomExpressionEditor.type('year("a string")', {allowFastSet: true,}).blur();+ H.popover()+ .findByText(/Types are incompatible/)+ .should("be.visible");++ H.CustomExpressionEditor.clear()+ .type('case([Total] > 100, "foo", "bar")', { allowFastSet: true })+ .blur();+ H.popover()+ .findByText(/Types are incompatible/)+ .should("not.exist");- H.popover().findByText("Types are incompatible.").should("not.exist");+ H.CustomExpressionEditor.nameInput().type("Foo");+ H.popover().button("Done").should("be.enabled");});});@@ -506,36 +506,46 @@ describe("Issue 12938", () => {});it("should be possible to concat number with string (metabase#12938)", () => {+ H.getNotebookStep("data").button("Pick columns").click();+ H.popover().within(() => {+ // "Select all" on a fully selected list keeps only the first column (ID)+ cy.findByText("Select all").click();+ cy.findByText("Title").click();+ cy.findByText("ID").click();+ });+ cy.realPress("Escape");+H.addCustomColumn();H.enterCustomColumnDetails({formula: "concat(floor([Rating]), [Title])",- name: "MyCustom",+ name: "RatingTitle",clickDone: true,});- H.visualize();- cy.get("main")- .findByText("There was a problem with your question")- .should("not.exist");- });-- it("should be possible to concat number with string (metabase#12938)", () => {- H.addCustomColumn();+ H.getNotebookStep("expression").icon("add").click();H.enterCustomColumnDetails({formula: 'concat(hour([Created At]), ":", minute([Created At]))',- name: "MyCustom",+ name: "HourMinute",clickDone: true,});- H.visualize();- cy.get("main")- .findByText("There was a problem with your question")- .should("not.exist");+ H.visualize(({ body }) => {+ expect(body.error).to.not.exist;+ });+ H.assertTableData({+ columns: ["Title", "RatingTitle", "HourMinute"],+ firstRows: [+ ["Rustic Paper Wallet", "4.0Rustic Paper Wallet", "19:44"],+ ["Small Marble Shoes", "0.0Small Marble Shoes", "8:49"],+ ],+ });});});describe("Issue 25189", () => {beforeEach(() => {+ cy.intercept("POST", "/api/dataset").as("dataset");+H.restore();cy.signInAsNormalUser();});@@ -575,6 +585,10 @@ describe("Issue 25189", () => {cy.findByText("Today").click();});+ cy.wait("@dataset").its("response.body.error").should("not.exist");+ cy.findAllByTestId("filter-pill")+ .should("have.length", 1)+ .and("contain.text", "CCreated At");cy.findAllByTestId("header-cell").contains("CCreated At").should("be.visible");@@ -618,13 +632,16 @@ describe("Issue 25189", () => {cy.findAllByText("Created At").should("have.length", 2).first().click();cy.findByText("Today").click();});+ cy.wait("@dataset").its("response.body.error").should("not.exist");H.filter();H.popover().within(() => {cy.findAllByText("Created At").should("have.length", 2).last().click();cy.findByText("Today").click();});+ cy.wait("@dataset").its("response.body.error").should("not.exist");+ cy.findAllByTestId("filter-pill").should("have.length", 2);cy.findAllByTestId("header-cell").contains("Created At").should("be.visible");@@ -692,7 +709,7 @@ describe("Issue 38498", { tags: "@external" }, () => {});});- it("should not be possible to use convertTimezone with an invalid timezone (metabse#38498)", () => {+ it("should not be possible to use convertTimezone with an invalid timezone (metabase#38498)", () => {H.addCustomColumn();H.CustomExpressionEditor.type('convertTimezone([Created At], "Asia/Ho_Chi_Mihn", "UTC")',