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 visualizations e2e tests (#84263)
Nemanja Glumac86f5248ffd69
diff --git a/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.jsindex 3d7cddc4fb0..c9d81698bc4 100644--- a/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js@@ -204,82 +204,6 @@ describe("scenarios > visualizations > bar chart", () => {H.getValueLabels().should("contain", "19").and("contain", "20.0M");});-- describe("issue 55853", () => {- const questionDetails = {- name: "55853",- database: WRITABLE_DB_ID,- native: {- query: `select 'Category A' as category, 0.0001 as value union all- select 'Category B' as category, 0.0002 as value union all- select 'Category C' as category, 0.00015 as value union all- select 'Category D' as category, 0.00025 as value`,- "template-tags": {},- },- display: "bar",- visualization_settings: {- "graph.dimensions": ["category"],- "graph.metrics": ["value"],- column_settings: {- '["name","value"]': {- number_style: "percent",- },- },- },- };-- beforeEach(() => {- H.restore("postgres-12");- cy.signInAsAdmin();- });-- it("should not have y-axis labels colliding with very low percentages (metabase#55853)", () => {- H.createNativeQuestion(questionDetails, { visitQuestion: true });-- cy.log("Verify that the chart renders successfully");- H.echartsContainer().should("be.visible");- H.echartsContainer().find("text").should("contain", "%");- H.chartPathWithFillColor("#88BF4D").should("have.length", 4);-- cy.log("Check that axis labels and title don't overlap");- H.echartsContainer()- .find("text")- .then(($texts) => {- const texts = $texts.toArray();- const axisTitle = texts.find(- (el) => el.textContent?.trim() === "value",- );- const percentLabels = texts.filter((el) =>- el.textContent?.includes("%"),- );-- expect(axisTitle, "y-axis title").to.exist;- expect(percentLabels).to.have.length.greaterThan(0);-- const titleRight = axisTitle.getBoundingClientRect().right;- percentLabels.forEach((el) => {- expect(- el.getBoundingClientRect().left - titleRight,- `Label "${el.textContent}" should not overlap with the axis title`,- ).to.be.greaterThan(5);- });- });-- cy.log(- "Verify tooltips show correct percentage values (not incorrectly rounded)",- );- H.chartPathWithFillColor("#88BF4D").first().realHover();- H.assertEChartsTooltip({- header: "Category A",- rows: [- {- name: "value",- value: "0.01%",- },- ],- });- });- });});describe("with x-axis series", () => {@@ -533,6 +457,13 @@ describe("scenarios > visualizations > bar chart", () => {visualization_settings: { "stackable.stack_type": "stacked" },});+ cy.findAllByTestId("legend-item")+ .findByText("Doohickey")+ .should("be.visible");+ cy.findByTestId("development-watermark").should(+ devMode ? "exist" : "not.exist",+ );+cy.findAllByTestId("legend-item").findByText("Doohickey").click();// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("See these Products").click();@@ -1225,10 +1156,7 @@ describe("scenarios > visualizations > bar chart", () => {H.openVizSettingsSidebar();- cy.findAllByTestId("chart-setting-select")- .eq(0)- .as("dimensionSelect")- .click();+ cy.findAllByTestId("chart-setting-select").eq(0).click();H.popover().findByText("ID").click();H.leftSidebar().findByText("Add series breakout").click();@@ -1484,3 +1412,79 @@ function compareValuesInOrder(selector, values) {cy.wrap($item).invoke("text").should("eq", values[index]);});}++describe("scenarios > visualizations > bar chart > issue 55853", () => {+ const questionDetails = {+ name: "55853",+ database: WRITABLE_DB_ID,+ native: {+ query: `select 'Category A' as category, 0.0001 as value union all+ select 'Category B' as category, 0.0002 as value union all+ select 'Category C' as category, 0.00015 as value union all+ select 'Category D' as category, 0.00025 as value`,+ "template-tags": {},+ },+ display: "bar",+ visualization_settings: {+ "graph.dimensions": ["category"],+ "graph.metrics": ["value"],+ column_settings: {+ '["name","value"]': {+ number_style: "percent",+ },+ },+ },+ };++ beforeEach(() => {+ H.restore("postgres-12");+ cy.signInAsAdmin();+ });++ it("should not have y-axis labels colliding with very low percentages (metabase#55853)", () => {+ H.createNativeQuestion(questionDetails, { visitQuestion: true });++ cy.log("Verify that the chart renders successfully");+ H.echartsContainer().should("be.visible");+ H.echartsContainer().find("text").should("contain", "%");+ H.chartPathWithFillColor("#88BF4D").should("have.length", 4);++ cy.log("Check that axis labels and title don't overlap");+ H.echartsContainer()+ .find("text")+ .then(($texts) => {+ const texts = $texts.toArray();+ const axisTitle = texts.find(+ (el) => el.textContent?.trim() === "value",+ );+ const percentLabels = texts.filter((el) =>+ el.textContent?.includes("%"),+ );++ expect(axisTitle, "y-axis title").to.exist;+ expect(percentLabels).to.have.length.greaterThan(0);++ const titleRight = axisTitle.getBoundingClientRect().right;+ percentLabels.forEach((el) => {+ expect(+ el.getBoundingClientRect().left - titleRight,+ `Label "${el.textContent}" should not overlap with the axis title`,+ ).to.be.greaterThan(5);+ });+ });++ cy.log(+ "Verify tooltips show correct percentage values (not incorrectly rounded)",+ );+ H.chartPathWithFillColor("#88BF4D").first().realHover();+ H.assertEChartsTooltip({+ header: "Category A",+ rows: [+ {+ name: "value",+ value: "0.01%",+ },+ ],+ });+ });+});diff --git a/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.js b/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.jsdeleted file mode 100644index 31e54ccfe73..00000000000--- a/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.js+++ /dev/null@@ -1,44 +0,0 @@-const { H } = cy;-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { ORDERS_ID } = SAMPLE_DATABASE;--describe("scenarios > visualizations > gauge chart", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not rerender on gauge arc hover (metabase#15980)", () => {- const questionDetails = {- name: "15980",- query: { "source-table": ORDERS_ID, aggregation: [["count"]] },- display: "gauge",- visualization_settings: {- "gauge.segments": [- { min: 0, max: 10000, color: "#ED6E6E", label: "" },- { min: 10000, max: 30000, color: "#84BB4C", label: "Goal" },- ],- },- };-- // A small dashboard card hides the gauge labels and shows them in a tooltip on hover- H.createQuestionAndDashboard({- questionDetails,- cardDetails: { size_x: 5, size_y: 4 },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });-- // Hover a segment without a label, then a segment with a label- H.getDashboardCard().findByTestId("gauge-arc-0").trigger("mousemove");-- // The value text covers the center of this arc- H.getDashboardCard()- .findByTestId("gauge-arc-1")- .trigger("mousemove", { force: true });- H.tooltip().should("contain", "Goal").and("contain", "10,000 - 30,000");-- H.getDashboardCard().findByTestId("gauge-arc-1").should("be.visible");- });-});diff --git a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.jsindex b4e0886f3f7..77c7fab7afa 100644--- a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js@@ -321,6 +321,9 @@ describe("scenarios > visualizations > pie chart", () => {],["Doohickey", "Gadget", "Gizmo", "Widget"],);+ cy.findByTestId("development-watermark").should(+ devMode ? "exist" : "not.exist",+ );H.echartsContainer().within(() => {cy.findByText("Saturday").as("saturdaySlice").trigger("mousemove");@@ -478,27 +481,51 @@ describe("scenarios > visualizations > pie chart", () => {H.assertQueryBuilderRowCount(835);});- it("should handle click behavior correctly", () => {+ it("should handle card and dashcard click behavior correctly (metabase#15250)", () => {+ const urlClickBehavior = {+ type: "link",+ linkType: "url",+ linkTemplate: "question/{{count}}",+ };+H.createQuestionAndDashboard({questionDetails: {query: threeRingQuery.query,display: "pie",visualization_settings: {- click_behavior: {- type: "link",- linkType: "url",- linkTemplate: "question/{{count}}",- },+ click_behavior: urlClickBehavior,},},- cardDetails: {- size_x: 30,- size_y: 15,- },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);+ }).then(({ body: { card_id, dashboard_id } }) => {+ H.createQuestion({+ name: "15250",+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [["field-id", PRODUCTS.CATEGORY]],+ },+ display: "pie",+ }).then(({ body: { id: categoryCardId } }) => {+ H.updateDashboardCards({+ dashboard_id,+ cards: [+ { card_id, row: 0, col: 0, size_x: 30, size_y: 15 },+ {+ card_id: categoryCardId,+ row: 15,+ col: 0,+ size_x: 21,+ size_y: 10,+ visualization_settings: { click_behavior: urlClickBehavior },+ },+ ],+ });++ H.visitDashboard(dashboard_id);+ });});+ cy.log("card click behavior on a three-ring pie");confirmSliceClickBehavior("2028", 6578);confirmSliceClickBehavior("Affiliate", 1270, 0);confirmSliceClickBehavior("Doohickey", 282, 0);@@ -506,6 +533,27 @@ describe("scenarios > visualizations > pie chart", () => {confirmSliceClickBehavior("2027", 5834);confirmSliceClickBehavior("Organic", 1180, 1);confirmSliceClickBehavior("Gizmo", 354, 8);++ cy.log("dashcard click behavior on the first pie row (metabase#15250)");+ H.getDashboardCard(1).within(() => {+ H.pieSliceWithColor("#88BF4D")+ .first()+ .as("doohickeySlice")+ .trigger("mousemove");+ });++ H.assertEChartsTooltip({+ header: "Category",+ rows: [+ { color: "#88BF4D", name: "Doohickey", value: "42" },+ { color: "#F9D45C", name: "Gadget", value: "53" },+ { color: "#A989C5", name: "Gizmo", value: "51" },+ { color: "#F2A86F", name: "Widget", value: "54" },+ ],+ });++ cy.get("@doohickeySlice").click();+ cy.location("pathname").should("eq", "/question/42");});it("should handle min percentage setting correctly", () => {@@ -780,14 +828,16 @@ function changeRowLimit(from, to) {}function confirmSliceClickBehavior(sliceLabel, value, elementIndex) {- H.echartsContainer().within(() => {- if (elementIndex == null) {- cy.findByText(sliceLabel).click({ force: true });- } else {- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByText(sliceLabel).eq(elementIndex).click({ force: true });- }- });+ H.getDashboardCard(0)+ .findByTestId("chart-container")+ .within(() => {+ if (elementIndex == null) {+ cy.findByText(sliceLabel).click({ force: true });+ } else {+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ cy.findAllByText(sliceLabel).eq(elementIndex).click({ force: true });+ }+ });cy.location("pathname").should("eq", `/question/${value}`);H.main().within(() => {diff --git a/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js b/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.jsindex 8581727e682..8f82abc76b0 100644--- a/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js@@ -9,46 +9,70 @@ describe("scenarios > visualizations > progress chart", () => {cy.signInAsAdmin();});- it("should render progress bar in query builder and dashboard (metabase#40658, metabase#41243)", () => {+ it("should render small progress bar and gauge cards on a dashboard, and the progress bar in query builder (metabase#40658, metabase#41243, metabase#15980)", () => {const QUESTION_NAME = "40658";const questionDetails = {name: QUESTION_NAME,query: { "source-table": ORDERS_ID, aggregation: [["count"]] },display: "progress",};+ const gaugeQuestionDetails = {+ name: "15980",+ query: { "source-table": ORDERS_ID, aggregation: [["count"]] },+ display: "gauge",+ visualization_settings: {+ "gauge.segments": [+ { min: 0, max: 10000, color: "#ED6E6E", label: "" },+ { min: 10000, max: 30000, color: "#84BB4C", label: "Goal" },+ ],+ },+ };- // check dashboard chart render- H.createQuestionAndDashboard({ questionDetails }).then(- ({ body: { id, card_id, dashboard_id } }) => {- // Make dashboard card really small (necessary for this repro as it doesn't show any labels)- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id,- card_id,- row: 0,- col: 0,- size_x: 5,- size_y: 4,- parameter_mappings: [],- },- ],- });-- H.visitDashboard(dashboard_id);+ // Small dashboard cards trigger both regressions. A small gauge shows its+ // segment labels in a tooltip on hover (metabase#15980).+ H.createQuestion(gaugeQuestionDetails).then(+ ({ body: { id: gaugeCardId } }) => {+ H.createQuestionAndDashboard({ questionDetails }).then(+ ({ body: { card_id, dashboard_id } }) => {+ H.updateDashboardCards({+ dashboard_id,+ cards: [+ { card_id, row: 0, col: 0, size_x: 5, size_y: 4 },+ { card_id: gaugeCardId, row: 0, col: 5, size_x: 5, size_y: 4 },+ ],+ });++ H.visitDashboard(dashboard_id);+ },+ );},);- H.dashboardCards()- .first()- .within(() => {- cy.findByText("18,760").should("be.visible");- cy.findByText("Goal 0").should("be.visible");- cy.findByText("Goal exceeded").should("be.visible");- });+ cy.log("gauge: hover a segment without a label, then one with a label");+ H.getDashboardCard(1).findByTestId("gauge-arc-0").trigger("mousemove");++ // The value text covers the center of this arc+ H.getDashboardCard(1)+ .findByTestId("gauge-arc-1")+ .trigger("mousemove", { force: true });+ H.tooltip().should("contain", "Goal").and("contain", "10,000 - 30,000");++ H.getDashboardCard(1).findByTestId("gauge-arc-1").should("be.visible");++ H.getDashboardCard(1)+ .findByTestId("gauge-arc-1")+ .trigger("mouseout", { force: true });+ H.tooltip().should("not.exist");++ cy.log("progress bar: dashboard render");+ H.getDashboardCard(0).within(() => {+ cy.findByText("18,760").should("be.visible");+ cy.findByText("Goal 0").should("be.visible");+ cy.findByText("Goal exceeded").should("be.visible");+ });- // check query builder chart render- H.dashboardCards().first().findByText(QUESTION_NAME).click();+ cy.log("progress bar: query builder render");+ H.getDashboardCard(0).findByText(QUESTION_NAME).click();H.queryBuilderMain().within(() => {cy.findByText("18,760").should("be.visible");cy.findByText("Goal 0").should("be.visible");diff --git a/e2e/test/scenarios/visualizations/custom-viz/custom-viz.cy.spec.ts b/e2e/test/scenarios/visualizations/custom-viz/custom-viz.cy.spec.tsindex 122e9a30f27..233a83cd669 100644--- a/e2e/test/scenarios/visualizations/custom-viz/custom-viz.cy.spec.ts+++ b/e2e/test/scenarios/visualizations/custom-viz/custom-viz.cy.spec.ts@@ -827,7 +827,7 @@ describe("admin > custom visualizations", () => {cy.intercept(bundleMatcher, {statusCode: 503,body: { error: "Bundle not available" },- }).as("bundleUnavailable");+ });H.createQuestion({@@ -2538,6 +2538,16 @@ describe("sandbox", () => {0,);});+});++describe("sandbox > widget settings", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ H.activateToken("bleeding-edge");+ H.updateSetting("csp-img-enabled", true);+ H.updateSetting("custom-viz-enabled", true);+ });it("blocks forbidden apis in widget settings and sandboxes React component setting widgets", () => {H.addCustomVizPlugin(H.CUSTOM_VIZ_FIXTURE_TGZ_3_SECURITY);diff --git a/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js b/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.jsindex 34ad6912564..b24e6efab2e 100644--- a/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js+++ b/e2e/test/scenarios/visualizations/drillthroughs/chart_drill.cy.spec.js@@ -575,72 +575,6 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => {});});- it("should parse value on click through on the first row of pie chart (metabase#15250)", () => {- H.createQuestion({- name: "15250",- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [["field-id", PRODUCTS.CATEGORY]],- },- display: "pie",- }).then(({ body: { id: QUESTION_ID } }) => {- H.createDashboard().then(({ body: { id: DASHBOARD_ID } }) => {- H.addOrUpdateDashboardCard({- card_id: QUESTION_ID,- dashboard_id: DASHBOARD_ID,- card: {- size_x: 21,- size_y: 10,- visualization_settings: {- click_behavior: {- type: "link",- linkType: "url",- linkTemplate: "question/{{count}}",- },- },- },- });-- H.visitDashboard(DASHBOARD_ID);- });- });-- H.pieSliceWithColor("#88BF4D")- .first()- .as("doohickeyChart")- .trigger("mousemove");-- H.assertEChartsTooltip({- header: "Category",- rows: [- {- color: "#88BF4D",- name: "Doohickey",- value: "42",- },- {- color: "#F9D45C",- name: "Gadget",- value: "53",- },- {- color: "#A989C5",- name: "Gizmo",- value: "51",- },- {- color: "#F2A86F",- name: "Widget",- value: "54",- },- ],- });-- cy.get("@doohickeyChart").click();- cy.location("pathname").should("eq", "/question/42");- });-it("should only show the 'See these records' option for the 'Other' pie slice (metabase#5334)", () => {H.visitQuestionAdhoc({name: "5334",diff --git a/e2e/test/scenarios/visualizations/drillthroughs/column_extract_drill.cy.spec.js b/e2e/test/scenarios/visualizations/drillthroughs/column_extract_drill.cy.spec.jsindex fa04a0cd331..172756626bc 100644--- a/e2e/test/scenarios/visualizations/drillthroughs/column_extract_drill.cy.spec.js+++ b/e2e/test/scenarios/visualizations/drillthroughs/column_extract_drill.cy.spec.js@@ -195,7 +195,6 @@ function extractColumnAndCheck({H.tableHeaderClick(column);H.popover().findByText(extraction).click();- cy.wait(1);if (example) {H.popover().findByText(option).should("contain", example);@@ -227,11 +226,9 @@ describe("extract action", { viewportWidth: 1600 }, () => {H.expectNoBadSnowplowEvents();});- it("should create a snowplow event for the column extraction action and allow editing the expression in the notebook editor", () => {+ it("should create a snowplow event for the column extraction action and allow editing and renaming the expression in the notebook editor", () => {H.openOrdersTable({ limit: 1 });- cy.wait(1);-extractColumnAndCheck({column: "Created At",option: "Year",@@ -249,11 +246,13 @@ describe("extract action", { viewportWidth: 1600 }, () => {H.openNotebook();H.getNotebookStep("expression").findByText("Year").click();H.enterCustomColumnDetails({+ name: "custom formula",formula: "year([Created At]) + 2",format: true,});H.popover().button("Update").should("not.be.disabled").click();H.visualize();+ H.tableHeaderColumn("custom formula").should("be.visible");cy.findByRole("gridcell", { name: "2,030" }).should("be.visible");});});diff --git a/e2e/test/scenarios/visualizations/drillthroughs/combine-column.cy.spec.ts b/e2e/test/scenarios/visualizations/drillthroughs/combine-column.cy.spec.tsdeleted file mode 100644index 443201207fa..00000000000--- a/e2e/test/scenarios/visualizations/drillthroughs/combine-column.cy.spec.ts+++ /dev/null@@ -1,105 +0,0 @@-const { H } = cy;-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;--describe("scenarios > visualizations > drillthroughs > table_drills > combine columns", () => {- beforeEach(() => {- H.restore();- H.resetSnowplow();- cy.signInAsAdmin();- });-- afterEach(() => {- H.expectNoBadSnowplowEvents();- });-- it("should be possible to combine columns from a table header and handle duplicate column names", () => {- H.createQuestion(- {- query: {- "source-table": PEOPLE_ID,- fields: [- ["field", PEOPLE.ID, { "base-type": "type/Number" }],- ["field", PEOPLE.EMAIL, { "base-type": "type/Text" }],- ],- limit: 3,- },- },- { visitQuestion: true },- );-- H.tableHeaderClick("Email");- H.popover().findByText("Combine columns").click();-- H.popover().within(() => {- cy.findByTestId("combine-example").should(- "contain",- "[email protected]",- );- cy.findByText("ID").click();- });-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- H.popover().last().findByText("Name").click();-- H.popover().within(() => {- cy.findByText("Separated by (empty)").click();- cy.findByLabelText("Separator").type("__");- cy.findByTestId("combine-example").should(- "have.text",- "[email protected]__text",- );-- cy.findByText("Add column").click();- cy.findByTestId("combine-example").should(- "have.text",- "[email protected]__text__12345",- );-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByRole("textbox").last().clear();- cy.findByTestId("combine-example").should(- "have.text",- "[email protected]__text12345",- );-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByRole("textbox").last().clear().type("+");- cy.findByTestId("combine-example").should(- "have.text",- "[email protected]__text+12345",- );-- cy.findByText("Done").click();- });-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByTestId("header-cell")- .last()- .should("have.text", "Combined Email, Name, ID");-- H.expectUnstructuredSnowplowEvent({- event: "column_combine_via_column_header",- custom_expressions_used: ["concat"],- database_id: SAMPLE_DB_ID,- });-- cy.log("Duplicate column names");- // first combine (email + ID)- H.tableHeaderClick("Email");- H.popover().findByText("Combine columns").click();- H.popover().findByText("Done").click();-- // second combine (email + ID)- H.tableHeaderClick("Email");- H.popover().findByText("Combine columns").click();- H.popover().findByText("Done").click();-- cy.findByTestId("table-header").within(() => {- cy.findByText("Combined Email, ID").should("be.visible");- cy.findByText("Combined Email, ID_2").should("be.visible");- });- });-});diff --git a/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts b/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.tsindex 2ad7fe2b2ee..a04a79a61aa 100644--- a/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts+++ b/e2e/test/scenarios/visualizations/tabular/column-shortcuts.cy.spec.ts@@ -124,26 +124,6 @@ describe("extract shortcut", () => {newColumn: "Hour of day_2",});});-- it("should be able to modify the expression in the notebook editor", () => {- H.openOrdersTable({ limit: 1 });- extractColumnAndCheck({- column: "Created At",- option: "Year",- value: "2,028",- });- H.openNotebook();- H.getNotebookStep("expression").findByText("Year").click();- H.enterCustomColumnDetails({- name: "custom formula",- formula: "year([Created At]) + 2",- blur: true,- });- H.popover().button("Update").should("not.be.disabled").click();- H.visualize();- H.tableHeaderColumn("custom formula").should("be.visible");- cy.findByRole("gridcell", { name: "2,030" }).should("be.visible");- });});it("should add a url expression for each option", () => {@@ -368,7 +348,7 @@ describe("scenarios > visualizations > combine shortcut", () => {H.expectNoBadSnowplowEvents();});- it("should be possible add a new column through the combine columns shortcut", () => {+ it("should combine columns via the plus modal and the column header and handle duplicate column names", () => {H.createQuestion({query: {@@ -385,6 +365,7 @@ describe("scenarios > visualizations > combine shortcut", () => {},);+ // Runs first: its gridcell check needs a single combined column.combineColumns({columns: ["Email", "ID"],newColumn: "Combined Email, ID",@@ -397,6 +378,77 @@ describe("scenarios > visualizations > combine shortcut", () => {custom_expressions_used: ["concat"],database_id: SAMPLE_DB_ID,});++ cy.log("Combine columns from the column header");+ H.tableHeaderClick("Email");+ H.popover().findByText("Combine columns").click();++ H.popover()+ .findByTestId("combine-example")+ .should("contain", "[email protected]");+ selectColumn(0, "Name");++ H.popover().within(() => {+ cy.findByText("Separated by (empty)").click();+ cy.findByLabelText("Separator").type("__");+ cy.findByTestId("combine-example").should(+ "have.text",+ "[email protected]__text",+ );++ cy.findByText("Add column").click();+ cy.findByTestId("combine-example").should(+ "have.text",+ "[email protected]__text__12345",+ );++ cy.findAllByLabelText("Separator")+ .should("have.length", 2)+ .last()+ .clear();+ cy.findByTestId("combine-example").should(+ "have.text",+ "[email protected]__text12345",+ );++ cy.findAllByLabelText("Separator")+ .should("have.length", 2)+ .last()+ .clear()+ .type("+");+ cy.findByTestId("combine-example").should(+ "have.text",+ "[email protected]__text+12345",+ );++ cy.findByText("Done").click();+ });++ cy.findAllByTestId("header-cell")+ .should("have.length", 4)+ .last()+ .should("have.text", "Combined Email, Name, ID");++ H.expectUnstructuredSnowplowEvent({+ event: "column_combine_via_column_header",+ custom_expressions_used: ["concat"],+ database_id: SAMPLE_DB_ID,+ });++ cy.log("Duplicate column names");+ H.tableHeaderClick("Email");+ H.popover().findByText("Combine columns").click();+ H.popover().findByText("Done").click();++ H.tableHeaderClick("Email");+ H.popover().findByText("Combine columns").click();+ H.popover().findByText("Done").click();++ cy.findByTestId("table-header").within(() => {+ cy.findByText("Combined Email, ID").should("be.visible");+ cy.findByText("Combined Email, ID_2").should("be.visible");+ cy.findByText("Combined Email, ID_3").should("be.visible");+ });});it("should allow combining columns when aggregating", function () {diff --git a/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.jsindex 9f2cfb6c718..42fc60bb2a8 100644--- a/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/table-column-settings.cy.spec.js@@ -1109,7 +1109,7 @@ describe("scenarios > visualizations > table column settings", () => {res.send();});- }).as("cardQuery");+ });// A dirty question runs through /api/dataset, so give it the same named field ref.cy.intercept("POST", "/api/dataset", (req) => {diff --git a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.jsindex efc5fde3759..25de5fb7e2a 100644--- a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js@@ -12,7 +12,6 @@ describe("scenarios > visualizations > table", () => {beforeEach(() => {H.restore();cy.signInAsNormalUser();- cy.intercept("GET", "/api/field/*/search/*").as("findSuggestions");});function joinTable(table) {@@ -436,6 +435,7 @@ describe("scenarios > visualizations > table", () => {});it("popover should not be scrollable horizontally (metabase#31339)", () => {+ cy.intercept("GET", "/api/field/*/search/*").as("findSuggestions");H.openPeopleTable();H.tableHeaderClick("Password");@@ -695,6 +695,35 @@ describe("scenarios > visualizations > table", () => {cy.findByTestId("visualization-root").icon("warning").should("not.exist");});});++ it("should preserve DOM elements for visible rows during scrolling", () => {+ H.openOrdersTable();++ const targetDatasetIndex = 15;+ const firstRowSelector = '[role=row][data-dataset-index="0"]';++ H.tableInteractiveBody().find(firstRowSelector).should("exist");+ H.tableInteractiveBody()+ .find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`)+ .then(($row) => {+ const originalElement = $row[0];++ H.tableInteractiveScrollContainer().then(($container) => {+ const currentScroll = $container[0].scrollTop;+ $container[0].scrollTop =+ currentScroll + 36 * (targetDatasetIndex - 1);+ });++ H.tableInteractiveBody().find(firstRowSelector).should("not.exist");+ H.tableInteractiveBody()+ .find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`)+ .should("exist")+ .then(($rowAfterScroll) => {+ // Row has always been visible so it should use the same html node+ expect($rowAfterScroll[0]).to.equal(originalElement);+ });+ });+ });});describe("scenarios > visualizations > table > dashboards context", () => {@@ -1429,35 +1458,6 @@ describe("scenarios > visualizations > table > time formatting (#11398)", () =>// And you should find the resultcy.findByRole("gridcell", { name: "6:34:00.000 PM" });});-- it("should preserve DOM elements for visible rows during scrolling", () => {- H.openOrdersTable();-- const targetDatasetIndex = 15;- const firstRowSelector = '[role=row][data-dataset-index="0"]';-- H.tableInteractiveBody().find(firstRowSelector).should("exist");- H.tableInteractiveBody()- .find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`)- .then(($row) => {- const originalElement = $row[0];-- H.tableInteractiveScrollContainer().then(($container) => {- const currentScroll = $container[0].scrollTop;- $container[0].scrollTop =- currentScroll + 36 * (targetDatasetIndex - 1);- });-- H.tableInteractiveBody().find(firstRowSelector).should("not.exist");- H.tableInteractiveBody()- .find(`[role=row][data-dataset-index="${targetDatasetIndex}"]`)- .should("exist")- .then(($rowAfterScroll) => {- // Row has always been visible so it should use the same html node- expect($rowAfterScroll[0]).to.equal(originalElement);- });- });- });});function assertColumnNotSortable(columnName) {