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
Move visualizations reproduction tests into feature specs (#83744)
Nemanja Glumacef21299b5a88
diff --git a/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.jsindex 699a3f2efde..7e6243e78f6 100644--- a/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/bar_chart.cy.spec.js@@ -1,8 +1,16 @@const { H } = cy;-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";+import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-const { ORDERS, ORDERS_ID, PEOPLE, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;+const {+ ORDERS,+ ORDERS_ID,+ PEOPLE,+ PRODUCTS,+ PRODUCTS_ID,+ REVIEWS,+ REVIEWS_ID,+} = SAMPLE_DATABASE;const breakoutBarChart = {display: "bar",@@ -70,6 +78,30 @@ describe("scenarios > visualizations > bar chart", () => {// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("(empty)");});++ it("should not freeze when opening a timeseries chart with sparse data and without the X-axis (metabase#18776)", () => {+ const questionDetails = {+ dataset_query: {+ type: "native",+ native: {+ query: `+ select 101002 as "id", 1 as "rate"+ union all select 103017, 2+ union all select 210002, 3`,+ },+ database: SAMPLE_DB_ID,+ },+ display: "bar",+ visualization_settings: {+ "graph.dimensions": ["id"],+ "graph.metrics": ["rate"],+ "graph.x_axis.axis_enabled": false,+ },+ };++ H.visitQuestionAdhoc(questionDetails);+ H.chartPathWithFillColor("#509EE3").should("have.length", 3);+ });});describe("with binned dimension (histogram)", () => {@@ -94,6 +126,57 @@ describe("scenarios > visualizations > bar chart", () => {// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("16,000").should("not.exist"); // If nulls are included the y-axis stretches much higher});++ it("should display bar chart for binned column distribution after applying filter (metabase#10493)", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ },+ database: SAMPLE_DB_ID,+ },+ });++ cy.log("Click on Quantity column header and select Distribution");+ H.tableHeaderClick("Quantity");+ H.popover().findByText("Distribution").click();+ cy.wait("@dataset");++ cy.log("Verify bar chart is displayed with binned quantity as dimension");+ cy.findByTestId("visualization-root").should(+ "have.attr",+ "data-viz-ui-name",+ "Bar",+ );+ H.chartPathWithFillColor("#509EE3").should("have.length", 9);++ cy.log("Apply filter: count >= 20");+ cy.findByTestId("qb-header-action-panel").findByText("Filter").click();+ H.popover().within(() => {+ cy.findByText("Summaries").click();+ cy.findByText("Count").click();+ });+ H.selectFilterOperator("Greater than or equal to");+ H.popover().within(() => {+ cy.findByPlaceholderText("Enter a number").type("20");+ cy.button("Apply filter").click();+ });++ cy.wait("@dataset");++ cy.log(+ "Verify bar chart is still displayed (binned column should still be treated as dimension)",+ );+ H.assertQueryBuilderRowCount(5);+ cy.findByTestId("visualization-placeholder").should("not.exist");+ cy.findByTestId("visualization-root").should(+ "have.attr",+ "data-viz-ui-name",+ "Bar",+ );+ H.chartPathWithFillColor("#509EE3").should("have.length", 5);+ });});describe("with very low and high values", () => {@@ -124,6 +207,82 @@ describe("scenarios > visualizations > bar chart", () => {.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", () => {@@ -300,6 +459,51 @@ describe("scenarios > visualizations > bar chart", () => {cy.get("text").contains("m2").should("exist");});});++ it("when two axis should show only one related to the hovered series (metabase#49874, metabase#48847)", () => {+ const question = {+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["sum", ["field", ORDERS.QUANTITY, null]],+ ["sum", ["field", ORDERS.TOTAL, null]],+ ],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ database: 1,+ },+ display: "bar",+ };++ H.visitQuestionAdhoc(question);++ H.echartsContainer().within(() => {+ cy.findByText("Sum of Quantity").should("be.visible");+ cy.findByText("Sum of Total").should("be.visible");+ });++ H.chartGridLines().should("exist");++ H.chartPathWithFillColor("#88BF4D").first().realHover();++ H.echartsContainer().within(() => {+ cy.findByText("Sum of Quantity").should("be.visible");+ cy.findByText("Sum of Total").should("not.exist");+ });+ H.chartGridLines().should("exist");++ H.chartPathWithFillColor("#98D9D9").first().realHover();++ H.echartsContainer().within(() => {+ cy.findByText("Sum of Quantity").should("not.exist");+ cy.findByText("Sum of Total").should("be.visible");+ });+ H.chartGridLines().should("exist");+ });});describe("with stacked bars", () => {@@ -335,6 +539,62 @@ describe("scenarios > visualizations > bar chart", () => {cy.findByText("Category is Doohickey").should("be.visible");});});++ it("should not crash when renaming an aggregation changes sibling column deduplication (metabase#68819)", () => {+ // Create a question with two Sum of Total aggregations+ // These will be deduplicated as "sum" and "sum_2"+ const questionDetails = {+ display: "bar",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["sum", ["field", ORDERS.TOTAL, null]],+ ["sum", ["field", ORDERS.TOTAL, null]],+ ],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],+ ],+ },+ visualization_settings: {+ "stackable.stack_type": "stacked",+ "graph.dimensions": ["CREATED_AT", "CATEGORY"],+ "graph.metrics": ["sum", "sum_2"],+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });++ H.echartsContainer().should("be.visible");++ H.openNotebook();++ H.getNotebookStep("summarize")+ .findByTestId("aggregate-step")+ .findAllByTestId("notebook-cell-item")+ .first()+ .click();++ cy.findByLabelText("Back").click();++ H.popover().findByText("Custom Expression").click();++ H.CustomExpressionEditor.nameInput().clear().type("Sum");+ H.popover().button("Update").click();++ H.saveSavedQuestion();++ cy.button("Visualize").click();++ // The bug would cause: TypeError: cannot read properties of undefined (reading 'name')+ H.echartsContainer().should("be.visible");+ cy.findByTestId("query-builder-main")+ .findByText(/error/i)+ .should("not.exist");++ cy.reload();+ H.echartsContainer().should("be.visible");+ });});it("supports gray series colors", () => {@@ -951,4 +1211,283 @@ describe("scenarios > visualizations > bar chart", () => {.and("match", /matrix/);});});++ it("should allow selecting breakout dimension before metrics (metabase#49529)", () => {+ const question = {+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ },+ database: 1,+ },+ display: "bar",+ };++ H.visitQuestionAdhoc(question);++ H.openVizSettingsSidebar();++ cy.findAllByTestId("chart-setting-select")+ .eq(0)+ .as("dimensionSelect")+ .click();+ H.popover().findByText("ID").click();++ H.leftSidebar().findByText("Add series breakout").click();+ H.popover().findByText("Quantity").click();++ H.leftSidebar().within(() => {+ cy.findByText("Y-axis");+ cy.findByText("Nothing to order");+ });+ });++ it("should handle invalid x-axis scale (metabase#25156)", () => {+ const questionDetails = {+ name: "25156",+ query: {+ "source-table": REVIEWS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", REVIEWS.CREATED_AT, { "temporal-unit": "year" }],+ ["field", REVIEWS.RATING, null],+ ],+ },+ display: "bar",+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT", "RATING"],+ "graph.metrics": ["count"],+ "graph.x_axis.scale": "linear",+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });++ H.echartsContainer()+ .should("contain", "2025")+ .and("contain", "2026")+ .and("contain", "2027")+ .and("contain", "2028");+ });++ it("should reflect/apply sorting to the x-axis (metabase#27279)", () => {+ const questionDetails = {+ name: "27279",+ native: {+ query:+ "select -3 o, 'F2021' k, 1 v\nunion all select -2, 'V2021', 2\nunion all select -1, 'S2022', 3\nunion all select 0, 'F2022', 4",+ "template-tags": {},+ },+ visualization_settings: {+ "table.pivot_column": "O",+ "table.cell_column": "V",+ },+ };++ H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": `card__${id}`,+ aggregation: [+ ["sum", ["field", "V", { "base-type": "type/Integer" }]],+ ],+ breakout: [+ ["field", "K", { "base-type": "type/Text" }],+ ["field", "O", { "base-type": "type/Integer" }],+ ],+ "order-by": [+ ["asc", ["field", "O", { "base-type": "type/Integer" }]],+ ],+ },+ database: SAMPLE_DB_ID,+ },+ display: "bar",+ visualization_settings: {+ "graph.dimensions": ["K", "O"],+ "graph.metrics": ["sum"],+ },+ });+ });++ const legendItems = ["-3", "-2", "-1", "0"];+ compareValuesInOrder(cy.findAllByTestId("legend-item"), legendItems);++ // ECharts pads the tick labels with spaces, so trim them before the comparison+ H.echartsContainer()+ .find("text")+ .filter((_, el) =>+ /^(F2021|V2021|S2022|F2022)$/.test(el.textContent.trim()),+ )+ .should(($ticks) => {+ expect(+ $ticks.toArray().map((el) => el.textContent.trim()),+ ).to.deep.equal(["F2021", "V2021", "S2022", "F2022"]);+ });++ // Extra step, just to be overly cautious+ H.chartPathWithFillColor("#98D9D9").realHover();++ H.assertEChartsTooltip({+ header: "F2021",+ rows: [+ {+ color: "#98D9D9",+ name: "-3",+ value: "1",+ },+ {+ color: "#F2A86F",+ name: "-2",+ value: "(empty)",+ },+ {+ color: "#F9D45C",+ name: "-1",+ value: "(empty)",+ },+ {+ color: "#509EE3",+ name: "0",+ value: "(empty)",+ },+ ],+ });++ H.chartPathWithFillColor("#509EE3").realHover();+ H.assertEChartsTooltip({+ header: "F2022",+ rows: [+ {+ color: "#98D9D9",+ name: "-3",+ value: "(empty)",+ },+ {+ color: "#F2A86F",+ name: "-2",+ value: "(empty)",+ },+ {+ color: "#F9D45C",+ name: "-1",+ value: "(empty)",+ },+ {+ color: "#509EE3",+ name: "0",+ value: "4",+ },+ ],+ });+ });++ describe("issue 20548", () => {+ const questionDetails = {+ name: "20548",+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["sum", ["field", PRODUCTS.PRICE, null]], ["count"]],+ breakout: [["field", PRODUCTS.CATEGORY, null]],+ },+ display: "bar",+ // We are reversing the order of metrics via API+ visualization_settings: {+ "graph.metrics": ["count", "sum"],+ "graph.dimensions": ["CATEGORY"],+ },+ };++ function removeAggregationItem(item) {+ cy.findAllByTestId("aggregation-item")+ .contains(item)+ .siblings(".Icon-close")+ .click();++ cy.wait("@dataset");+ }++ function addAggregationItem(item) {+ cy.findByTestId("add-aggregation-button").click();+ H.popover().contains(item).click();++ cy.wait("@dataset");+ }++ /**+ * @param {string} item+ * @param {number} frequency+ */+ function assertOnLegendItemFrequency(item, frequency) {+ cy.findAllByTestId("legend-item")+ .filter(`:contains("${item}")`)+ .should("have.length", frequency);+ }++ beforeEach(() => {+ H.createQuestion(questionDetails, { visitQuestion: true });+ H.summarize();+ });++ it("should not display duplicate Y-axis after modifying/reordering metrics (metabase#20548)", () => {+ removeAggregationItem("Count");+ // Ensure bars of only one series exist+ H.chartPathWithFillColor("#88BF4D").should("have.length", 4);+ H.chartPathWithFillColor("#509EE3").should("not.exist");++ addAggregationItem("Count");+ // Ensure bars of two series exist+ H.chartPathWithFillColor("#88BF4D").should("have.length", 4);+ H.chartPathWithFillColor("#509EE3").should("have.length", 4);++ // Although the test already fails on the previous step, let's add some more assertions to prevent future regressions+ assertOnLegendItemFrequency("Count", 1);+ assertOnLegendItemFrequency("Sum of Price", 1);++ H.openVizSettingsSidebar();+ H.sidebar().findByDisplayValue("Count").should("be.visible");+ });+ });++ describe("issue 63671", () => {+ beforeEach(() => {+ H.createQuestion(+ {+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ PRODUCTS.CREATED_AT,+ {+ "temporal-unit": "year",+ },+ ],+ ],+ filter: [+ "between",+ ["field", PRODUCTS.CREATED_AT, null],+ "2028-01-01",+ "2028-12-31",+ ],+ },+ display: "bar",+ },+ { visitQuestion: true },+ );+ });++ it("should not show an extra value on bar charts when there is only value on the x axis (metabase#63671)", () => {+ cy.findByTestId("query-visualization-root").findByText("2028");+ });+ });});++function compareValuesInOrder(selector, values) {+ selector.each(($item, index) => {+ cy.wrap($item).invoke("text").should("eq", values[index]);+ });+}diff --git a/e2e/test/scenarios/visualizations/charts/combo.cy.spec.js b/e2e/test/scenarios/visualizations/charts/combo.cy.spec.jsindex 6b3d36fab28..2b35aae7a5f 100644--- a/e2e/test/scenarios/visualizations/charts/combo.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/combo.cy.spec.js@@ -162,4 +162,59 @@ describe("scenarios > visualizations > combo", () => {// Ensure y-axis has 100% tickH.echartsContainer().findByText("100%");});++ it("should apply per-series display type on a question and dashcard (metabase#69882)", () => {+ const DOOHICKEY_BAR_COLOR = "#227FD2";+ const GADGET_LINE_COLOR = "#689636";++ const questionDetails = {+ name: "69882",+ display: "combo",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],+ ],+ },+ visualization_settings: {+ series_settings: {+ Doohickey: {+ color: DOOHICKEY_BAR_COLOR,+ title: "_Doohickey",+ display: "bar",+ },+ Gadget: {+ color: GADGET_LINE_COLOR,+ title: "_Gadget",+ display: "line",+ },+ },+ "graph.x_axis.scale": "timeseries",+ "graph.dimensions": ["CREATED_AT", "CATEGORY"],+ "graph.metrics": ["count"],+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true, wrapId: true });++ H.echartsContainer().should("be.visible");+ H.chartPathWithFillColor(DOOHICKEY_BAR_COLOR).should("exist");+ H.cartesianChartCircleWithColor(GADGET_LINE_COLOR);++ H.createDashboard({ name: "Test Dashboard" }, { wrapId: true });+ cy.get("@questionId").then((cardId) => {+ cy.get("@dashboardId").then((dashboardId) => {+ H.addQuestionToDashboard({ dashboardId, cardId });+ H.visitDashboard(dashboardId);+ });+ });++ cy.findByTestId("dashcard").within(() => {+ H.echartsContainer().should("be.visible");+ H.chartPathWithFillColor(DOOHICKEY_BAR_COLOR).should("exist");+ H.cartesianChartCircleWithColor(GADGET_LINE_COLOR);+ });+ });});diff --git a/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js b/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.jsindex 6a0fb3b4766..fd6b9dce200 100644--- a/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js@@ -2,7 +2,7 @@ const { H } = cy;import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-const { PEOPLE_ID, PEOPLE } = SAMPLE_DATABASE;+const { PEOPLE_ID, PEOPLE, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;describe("scenarios > visualizations > funnel chart", () => {beforeEach(() => {@@ -110,3 +110,123 @@ describe("scenarios > visualizations > funnel chart", () => {H.getDraggableElements().eq(4).should("have.text", "Facebook");});});++describe("scenarios > visualizations > funnel chart > filters and empty values", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ describe("issue 17524", () => {+ const nativeQuestionDetails = {+ native: {+ query:+ "select * from (\nselect 'A' step, 41 users, 42 median union all\nselect 'B' step, 31 users, 32 median union all\nselect 'C' step, 21 users, 22 median union all\nselect 'D' step, 11 users, 12 median\n) x\n[[where users>{{num}}]]\n",+ "template-tags": {+ num: {+ id: "d7f1fb15-c7b8-6051-443d-604b6ed5457b",+ name: "num",+ "display-name": "Num",+ type: "number",+ default: null,+ },+ },+ },+ display: "funnel",+ visualization_settings: {+ "funnel.dimension": "STEP",+ "funnel.metric": "USERS",+ },+ };++ const questionDetails = {+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"], ["sum", ["field", PRODUCTS.PRICE, null]]],+ breakout: [["field", PRODUCTS.CATEGORY, null]],+ },+ display: "funnel",+ visualization_settings: {+ "funnel.metric": "count",+ "funnel.dimension": "CATEGORY",+ },+ };++ describe("scenario 1", () => {+ beforeEach(() => {+ H.createNativeQuestion(nativeQuestionDetails, { visitQuestion: true });+ });++ it("should not alter visualization type when applying filter on a native question (metabase#17524-1)", () => {+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");++ H.filterWidget().type("20");++ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ cy.icon("play").last().click();+ cy.wait("@cardQuery");++ cy.findAllByTestId("funnel-chart-header").should("have.length", 3);+ H.queryBuilderHeader().button("Save").should("not.exist");+ });+ });++ describe("scenario 2", () => {+ beforeEach(() => {+ H.createQuestion(questionDetails, { visitQuestion: true });+ });++ it("should not alter visualization type when applying filter on a QB question (metabase#17524-2)", () => {+ cy.intercept("POST", "/api/dataset").as("dataset");+ cy.findAllByTestId("funnel-chart-header").should("have.length", 4);++ H.filter();+ H.popover().findByText("Category").click();+ H.selectFilterOperator("Is not");+ H.popover().within(() => {+ cy.findByText("Gadget").click();+ cy.button("Apply filter").click();+ });+ cy.wait("@dataset");++ cy.findAllByTestId("funnel-chart-header").should("have.length", 3);+ });+ });+ });++ describe("issue 45255", () => {+ beforeEach(() => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "native",+ native: {+ query:+ "select 'foo' step, 10 v union all select 'baz', 8 union all select null, 6 union all select 'bar', 4",+ "template-tags": {},+ },+ database: SAMPLE_DB_ID,+ },+ display: "funnel",+ });+ });++ it("should work on native queries with null dimension values (metabase#45255)", () => {+ H.openVizSettingsSidebar();++ // Has (empty) in the settings sidebar+ H.sidebar().findByText("(empty)");++ // Can reorder (empty)+ H.getDraggableElements().eq(2).should("have.text", "(empty)");+ H.getDraggableElements().first().as("dragElement");+ H.moveDnDKitElementByAlias("@dragElement", {+ vertical: 100,+ useMouseEvents: true,+ });+ H.getDraggableElements().eq(1).should("have.text", "(empty)");++ // Has (empty) in the chart+ cy.findByTestId("funnel-chart").findByText("(empty)");+ });+ });+});diff --git a/e2e/test/scenarios/visualizations/charts/legend.cy.spec.js b/e2e/test/scenarios/visualizations/charts/legend.cy.spec.jsindex 3da36d637cf..ccc53d6141b 100644--- a/e2e/test/scenarios/visualizations/charts/legend.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/legend.cy.spec.js@@ -555,6 +555,74 @@ describe("scenarios > visualizations > legend", () => {blurAfter: true,});});++ it("should not fire an invalid API request when clicking a legend item on a cartesian chart with multiple aggregations (metabase#43077)", () => {+ const cartesianQuestionDetails = {+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["sum", ["field", ORDERS.QUANTITY, null]],+ ["sum", ["field", ORDERS.TOTAL, null]],+ ],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ database: 1,+ },+ display: "line",+ };+ const cardRequestSpy = cy.spy();+ cy.intercept("/api/card/*", cardRequestSpy);++ H.visitQuestionAdhoc(cartesianQuestionDetails);++ // Click the title, because a click on the dot toggles the series visibility+ cy.findAllByTestId("legend-item")+ .first()+ .findByText(/^Sum of/)+ .click();++ cy.wait(500);+ cy.location("pathname").should("eq", "/question");+ cy.then(() => expect(cardRequestSpy).not.to.have.been.called);+ });++ it("should not fire an invalid API request when clicking a legend item on a row chart with multiple aggregations (metabase#43077)", () => {+ const rowQuestionDetails = {+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["sum", ["field", ORDERS.QUANTITY, null]],+ ["sum", ["field", ORDERS.TOTAL, null]],+ ],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ database: 1,+ },+ display: "row",+ };+ const cardRequestSpy = cy.spy();+ cy.intercept("/api/card/*", cardRequestSpy);++ H.visitQuestionAdhoc(rowQuestionDetails);++ // Click the title, because a click on the dot toggles the series visibility+ cy.findAllByTestId("legend-item")+ .first()+ .findByText(/^Sum of/)+ .click();++ cy.wait(500);+ cy.location("pathname").should("eq", "/question");+ cy.then(() => expect(cardRequestSpy).not.to.have.been.called);+ });});function hideSeries(legendItemIndex) {diff --git a/e2e/test/scenarios/visualizations/charts/line-bar-tooltips.cy.spec.js b/e2e/test/scenarios/visualizations/charts/line-bar-tooltips.cy.spec.jsindex 18b06c8ef70..aa18814bada 100644--- a/e2e/test/scenarios/visualizations/charts/line-bar-tooltips.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/line-bar-tooltips.cy.spec.js@@ -253,6 +253,162 @@ describe("scenarios > visualizations > line/bar chart > tooltips", () => {.should("be.visible");});+ it("should show correct tooltips for interpolated data points (metabase#47757)", () => {+ H.visitQuestionAdhoc({+ visualization_settings: {+ "graph.dimensions": ["X"],+ "graph.metrics": ["Y"],+ series_settings: { Y: { "line.missing": "zero" } },+ },+ dataset_query: {+ type: "native",+ native: {+ query: `select '2020-01-01' x, 10 y+union all select '2020-03-01' x, 30 y+union all select '2020-04-01' x, 40 y`,+ },+ database: SAMPLE_DB_ID,+ },+ display: "line",+ });++ H.cartesianChartCircleWithColor("#88BF4D").eq(0).trigger("mousemove");+ H.assertEChartsTooltip({+ header: "January 2020",+ rows: [+ {+ color: "#88BF4D",+ name: "Y",+ value: 10,+ },+ ],+ footer: null,+ blurAfter: true,+ });++ H.cartesianChartCircleWithColor("#88BF4D").eq(1).trigger("mousemove");+ H.assertEChartsTooltip({+ header: "February 2020",+ rows: [+ {+ color: "#88BF4D",+ name: "Y",+ value: 0,+ secondaryValue: "-100%",+ },+ ],+ footer: null,+ blurAfter: true,+ });++ H.cartesianChartCircleWithColor("#88BF4D").eq(2).trigger("mousemove");+ H.assertEChartsTooltip({+ header: "March 2020",+ rows: [+ {+ color: "#88BF4D",+ name: "Y",+ value: 30,+ secondaryValue: "+∞%",+ },+ ],+ footer: null,+ blurAfter: true,+ });+ });++ it("should wrap long values without expanding the tooltip beyond the viewport (metabase#68337)", () => {+ const longTooltipValue = "a".repeat(10000);++ H.visitQuestionAdhoc({+ display: "line",+ dataset_query: {+ type: "native",+ native: {+ query: `select 1 as x, 10 as metric_value, '${longTooltipValue}' as details+union all select 2, 20, 'short value'`,+ },+ database: SAMPLE_DB_ID,+ },+ visualization_settings: {+ "graph.dimensions": ["X"],+ "graph.metrics": ["METRIC_VALUE"],+ "graph.tooltip_columns": [JSON.stringify(["name", "DETAILS"])],+ },+ });++ H.cartesianChartCircle()+ .should("have.length", 2)+ .first()+ .trigger("mousemove");++ cy.window().then((appWindow) => {+ H.echartsTooltip().then(($tooltip) => {+ const tooltipRoot = $tooltip[0].parentElement;+ expect(tooltipRoot).not.to.be.null;+ if (tooltipRoot == null) {+ return;+ }++ const tooltipBounds = tooltipRoot.getBoundingClientRect();++ expect(tooltipBounds.left).to.be.at.least(0);+ expect(tooltipBounds.right).to.be.at.most(appWindow.innerWidth);+ expect(tooltipBounds.height).to.be.at.most(appWindow.innerHeight * 0.8);+ expect(tooltipRoot.scrollHeight).to.be.greaterThan(+ tooltipRoot.clientHeight,+ );+ });+ });++ H.echartsTooltip()+ .findByText(longTooltipValue)+ .should(($value) => {+ const value = $value[0];+ const fontSize = Number.parseFloat(getComputedStyle(value).fontSize);++ expect(value.scrollWidth).to.be.at.most(value.clientWidth);+ expect(value.clientHeight).to.be.greaterThan(fontSize * 2);+ });+ });++ it("should use time formatting settings in tooltips for native questions (metabase#11435)", () => {+ const questionDetails = {+ name: "11435",+ display: "line",+ native: {+ query: `+ SELECT "PUBLIC"."ORDERS"."ID" AS "ID", "PUBLIC"."ORDERS"."USER_ID" AS "USER_ID", "PUBLIC"."ORDERS"."PRODUCT_ID" AS "PRODUCT_ID", "PUBLIC"."ORDERS"."SUBTOTAL" AS "SUBTOTAL", "PUBLIC"."ORDERS"."TAX" AS "TAX", "PUBLIC"."ORDERS"."TOTAL" AS "TOTAL", "PUBLIC"."ORDERS"."DISCOUNT" AS "DISCOUNT", "PUBLIC"."ORDERS"."CREATED_AT" AS "CREATED_AT", "PUBLIC"."ORDERS"."QUANTITY" AS "QUANTITY"+ FROM "PUBLIC"."ORDERS"+ WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone '2028-03-12 00:00:00.000+03:00'+ AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone '2028-03-13 00:00:00.000+03:00')+ LIMIT 1048575`,+ },+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT"],+ "graph.metrics": ["TOTAL"],+ column_settings: {+ '["name","CREATED_AT"]': {+ time_enabled: "milliseconds",+ },+ },+ },+ };++ H.createNativeQuestion(questionDetails, { visitQuestion: true });+ H.cartesianChartCircle().eq(1).realHover();+ H.assertEChartsTooltip({+ header: "March 11, 2028, 5:55:36.759 PM",+ rows: [+ {+ color: "#F9D45C",+ name: "TOTAL",+ value: "135.23",+ },+ ],+ });+ });+describe("> additional columns setting", () => {const COUNT = "Count";const SUM_OF_TOTAL = "Sum of Total";diff --git a/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.jsindex f73e481ddee..9671d57811f 100644--- a/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/line_chart.cy.spec.js@@ -2,8 +2,18 @@ const { H } = cy;import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =- SAMPLE_DATABASE;+const {+ ORDERS,+ ORDERS_ID,+ PRODUCTS,+ PRODUCTS_ID,+ PEOPLE,+ PEOPLE_ID,+ REVIEWS,+ REVIEWS_ID,+} = SAMPLE_DATABASE;++const externalDatabaseId = 2;const testQuery = {type: "query",@@ -89,6 +99,16 @@ describe("scenarios > visualizations > line chart", () => {});H.openVizSettingsSidebar();++ cy.log("x-axis column settings (metabase#51952)");+ cy.findByTestId("settings-CREATED_AT").click();+ H.popover().findByText("Abbreviate days and months").click();+ H.echartsContainer().findByText("Jan 2027");+ cy.realPress("Escape");+ cy.get("[data-element-id=mantine-popover]")+ .filter(":visible")+ .should("not.exist");+H.openSeriesSettings("Count");H.popover().within(() => {@@ -218,6 +238,174 @@ describe("scenarios > visualizations > line chart", () => {H.echartsContainer().findByText("0");});+ describe("UXW-2696", () => {+ const getChartPoints = () =>+ H.echartsContainer().find("path[fill='hsla(0, 0%, 100%, 1.00)']");+ const getNoPointsMessage = () =>+ cy.findByRole("dialog", { name: /data points are off screen/i });++ const assertNoPoints = (assertMessage = true) => {+ getChartPoints().should("have.length", 0);+ if (assertMessage) {+ getNoPointsMessage().should("exist");+ }+ };++ const assertDataVisible = () => {+ getChartPoints().should("have.length.greaterThan", 0);+ getNoPointsMessage().should("not.exist");+ };++ const QUESTION_NAME = "Count of orders by month";++ beforeEach(() => {+ cy.signInAsAdmin();++ H.createQuestion(+ {+ name: QUESTION_NAME,+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ display: "line",+ visualization_settings: {+ "graph.y_axis.min": 700,+ "graph.y_axis.max": 1000,+ "graph.y_axis.auto_range": false,+ },+ },+ { wrapId: true },+ );+ });++ it("should show you a popover when all data points are outside the y-axis range in the notebook editor", () => {+ cy.get("@questionId").then((id) => H.visitQuestion(id));++ assertNoPoints();++ // Check that message is displayed+ cy.findByRole("dialog", { name: /data points are off screen/i });++ H.openVizSettingsSidebar();++ H.vizSettingsSidebar().findByText("Axes").click();+ H.vizSettingsSidebar().findByLabelText("Min").clear().type("70").blur();++ assertDataVisible();++ H.vizSettingsSidebar().findByLabelText("Min").clear().type("700").blur();++ assertNoPoints();++ cy.findByRole("switch", { name: /auto y-axis range/i }).click({+ force: true,+ });++ assertDataVisible();+ });++ it("should be able to open the menu on pinned cards", () => {+ H.visitCollection("root");+ H.openCollectionItemMenu(QUESTION_NAME);+ H.popover().findByText("Pin this").click();++ // assert that the menu trigger is not covered+ H.openPinnedItemMenu(QUESTION_NAME);+ H.popover().should("exist");+ });++ it("should show the message in documents", () => {+ //setup a document+ cy.visit("/document/new");+ H.documentContent().click();++ H.addToDocument("/ord", false);+ H.commandSuggestionItem(new RegExp(QUESTION_NAME)).click();++ H.getDocumentCard(QUESTION_NAME).within(() => {+ assertNoPoints();+ });++ H.openDocumentCardMenu(QUESTION_NAME);+ H.popover().findByText("Edit Visualization").click();++ H.getDocumentSidebar().within(() => {+ cy.findByRole("tab", { name: /axes/i }).click({ force: true });+ cy.findByLabelText("Auto y-axis range").should(+ "have.attr",+ "data-checked",+ "false",+ );++ cy.findByLabelText("Min").clear().type("70");+ });++ H.getDocumentCard(QUESTION_NAME).within(() => {+ assertDataVisible();+ });+ });++ describe("dashcard", () => {+ beforeEach(() => {+ cy.get("@questionId").then((cardId) => {+ H.createDashboard(+ {+ name: "Test Dashboard",+ },+ {+ wrapId: true,+ },+ );++ cy.get("@dashboardId").then((dashboardId) =>+ H.addQuestionToDashboard({ dashboardId, cardId }),+ );+ });+ });++ it("should show you a message on a dashboard", () => {+ cy.get("@dashboardId").then((id) => H.visitDashboard(id));++ cy.findByTestId("dashcard").within(() => {+ assertNoPoints();+ });++ H.editDashboard();+ H.showDashcardVisualizerModalSettings(0, { isVisualizerCard: false });++ H.modal().within(() => {+ cy.findByRole("tab", { name: /axes/i }).click({ force: true });+ cy.findByLabelText("Auto y-axis range").should(+ "have.attr",+ "data-checked",+ "false",+ );++ H.echartsContainer().find("svg").should("exist");+ assertNoPoints(false);+ getNoPointsMessage().should("not.exist");++ cy.findByLabelText("Min").clear().type("70").blur();++ assertDataVisible();+ });+ H.saveDashcardVisualizerModal();++ H.dashboardSaveButton().click();++ cy.findByTestId("edit-bar").should("not.exist");++ cy.findByTestId("dashcard").within(() => {+ getChartPoints().should("have.length.greaterThan", 0);+ });+ });+ });+ });+it("should display an error message when there are more series than the chart supports", () => {H.visitQuestionAdhoc({display: "line",@@ -245,6 +433,67 @@ describe("scenarios > visualizations > line chart", () => {);});+ it("should not allow adding more series when all columns are used (metabase#11249)", () => {+ H.visitQuestionAdhoc({+ name: "13960",+ display: "line",+ dataset_query: {+ type: "query",+ database: 1,+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"], ["avg", ["field", ORDERS.TOTAL, null]]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ },+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT"],+ "graph.metrics": ["avg"],+ },+ });++ H.openVizSettingsSidebar();++ cy.findByTestId("sidebar-left").within(() => {+ cy.findByText("Data").click();+ cy.findByDisplayValue("Count").should("not.exist");++ cy.findByText("Add another series").click();+ cy.findByDisplayValue("Count").should("be.visible");+ cy.findByText("Add another series").should("not.exist");+ });+ });++ it("should render a chart with many columns without freezing (metabase#21392)", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "native",+ native: {+ query: `+ WITH+ L0 AS (SELECT c FROM (SELECT 1 UNION ALL SELECT 1) AS D(c)) -- 2^1+ ,L1 AS (SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B) -- 2^2+ ,L2 AS (SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B) -- 2^4+ ,L3 AS (SELECT 1 AS c FROM L2 AS A CROSS JOIN L0 AS B) -- 2^5++ SELECT ROWNUM() id, DATEADD('DAY', ROWNUM(), CURRENT_DATE)::DATE date,+ RAND() c00, RAND() c01, RAND() c02, RAND() c03, RAND() c04, RAND() c05, RAND() c06, RAND() c07, RAND() c08, RAND() c09,+ RAND() c10, RAND() c11, RAND() c12, RAND() c13, RAND() c14, RAND() c15, RAND() c16, RAND() c17, RAND() c18, RAND() c19,+ RAND() c20, RAND() c21, RAND() c22, RAND() c23, RAND() c24, RAND() c25, RAND() c26, RAND() c27, RAND() c28, RAND() c29,+ RAND() c30, RAND() c31+ FROM L3+ `,+ },+ database: SAMPLE_DB_ID,+ },+ display: "line",+ });+ H.echartsContainer().should("be.visible");+ H.ensureEchartsContainerHasSvg();+ });+it("should correctly display tooltip values when X-axis is numeric and style is 'Ordinal' (metabase#15998)", () => {H.visitQuestionAdhoc({dataset_query: {@@ -293,6 +542,39 @@ describe("scenarios > visualizations > line chart", () => {});});+ it("should show chart tooltip on narrow ordinal line charts (metabase#47847)", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "week" }]],+ },+ database: SAMPLE_DB_ID,+ },+ display: "line",+ visualization_settings: {+ "graph.x_axis.scale": "ordinal",+ "graph.show_values": true,+ },+ });++ H.cartesianChartCircleWithColor("#509EE3").eq(0).trigger("mousemove");+ H.assertEChartsTooltip({+ header: "April 27 – May 3, 2025", // expect this to break when we shift years in the Sample Database+ blurAfter: false,+ footer: null,+ rows: [+ {+ color: "#509EE3",+ name: "Count",+ value: "1",+ },+ ],+ });+ });+it("should be possible to update/change label for an empty row value (metabase#12128)", () => {H.visitQuestionAdhoc({dataset_query: {@@ -804,6 +1086,153 @@ describe("scenarios > visualizations > line chart", () => {});});+ it("should not crash when removing dimension aggregation column from the query (metabase#59671)", () => {+ const questionDetails = {+ display: "line",+ query: {+ "source-table": ORDERS_ID,+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],+ aggregation: [["count"]],+ },+ visualization_settings: {+ "graph.dimensions": ["CREATED_AT"],+ "graph.metrics": ["count"],+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ H.openNotebook();+ H.removeSummaryGroupingField({+ field: "Created At: Month",+ stage: 0,+ index: 0,+ });+ H.visualize();++ cy.findByTestId("visualization-placeholder").should("be.visible");+ cy.icon("warning").should("not.exist");+ });++ it("should not crash when saved dimension settings refer to a non-existent column (metabase#59830)", () => {+ const questionDetails = {+ display: "line",+ query: {+ "source-table": ORDERS_ID,+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],+ ],+ aggregation: [["count"], ["avg", ["field", ORDERS.TOTAL, null]]],+ },+ visualization_settings: {+ "graph.dimensions": ["DOES_NOT_EXIST"],+ "graph.metrics": ["count"],+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ cy.icon("warning").should("not.exist");+ cy.findByTestId("chart-container").should("be.visible");+ });++ it("should show an empty state when no dimensions are available (metabase#54755)", () => {+ const questionDetails = {+ display: "line",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ },+ visualization_settings: {+ "graph.dimensions": [],+ "graph.metrics": ["count"],+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ cy.icon("warning").should("not.exist");+ cy.findByTestId("visualization-placeholder").should("be.visible");+ });++ it("should not crash the app when rendering a line chart with broken viz settings and table metadata (metabase#54271)", () => {+ cy.signInAsAdmin();++ cy.log("broken semantic type - the field cannot be parsed as a date");+ cy.request("PUT", `/api/field/${REVIEWS.REVIEWER}`, {+ semantic_type: "type/CreationDate",+ });++ cy.log("broken viz settings - dimensions cannot have a text column");+ H.createQuestion(+ {+ query: {+ "source-table": REVIEWS_ID,+ aggregation: [["count"]],+ breakout: [["field", REVIEWS.REVIEWER, null]],+ },+ display: "line",+ visualization_settings: {+ "graph.dimensions": ["REVIEWER"],+ "graph.metrics": [["count"]],+ },+ },+ { visitQuestion: true },+ );++ cy.log("no clear expectations but the app should not crash");+ H.assertQueryBuilderRowCount(1076);+ });++ describe("issue 21452", () => {+ beforeEach(() => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["cum-sum", ["field", ORDERS.QUANTITY, null]]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],+ ],+ },+ database: 1,+ },+ display: "line",+ });++ H.openVizSettingsSidebar();+ });++ it("should not fire POST request after every character during display name change (metabase#21452)", () => {+ H.openSeriesSettings("Cumulative sum of Quantity");+ H.popover()+ .findByDisplayValue("Cumulative sum of Quantity")+ .clear()+ .type("Foo");++ H.popover().findByText("Display type").click();++ cy.log("Dismiss the popup and close settings");+ H.leftSidebar().button("Done").click();++ // trigger("mousemove") is more reliable than realHover+ // maybe related to https://github.com/dmtrKovalenko/cypress-real-events/issues/691+ H.cartesianChartCircle().first().trigger("mousemove");++ H.assertEChartsTooltip({+ header: "2025",+ rows: [+ {+ color: "#88BF4D",+ name: "Foo",+ value: "3,236",+ },+ ],+ });++ cy.get("@dataset.all").should("have.length", 1);+ });+ });+describe("with tracking", () => {beforeEach(() => {cy.signInAsAdmin();@@ -908,3 +1337,76 @@ describe("scenarios > visualizations > line chart", () => {});});});++describe(+ "scenarios > visualizations > line chart (Mongo)",+ { tags: "@mongo" },+ () => {+ function replaceMissingValuesWith(value) {+ cy.get('[data-field-title="Replace missing values with"]').within(() => {+ cy.findByTestId("chart-setting-select").click();+ });++ H.popover().contains(value).click();+ H.popover().findByDisplayValue(value);++ // click outside popover+ cy.findByTestId("chartsettings-list-container").click();+ }++ function assertOnTheYAxis() {+ H.echartsContainer().find("text").contains("Count");++ H.echartsContainer().find("text").contains("6,000");+ }++ beforeEach(() => {+ H.restore("mongo-5");+ cy.signInAsAdmin();++ H.withDatabase(externalDatabaseId, ({ ORDERS, ORDERS_ID }) => {+ const questionDetails = {+ name: "16170",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],+ ],+ },+ database: externalDatabaseId,+ display: "line",+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ });+ });++ ["Zero", "Nothing"].forEach((replacementValue) => {+ it(`replace missing values with "${replacementValue}" should work on Mongo (metabase#16170)`, () => {+ H.openVizSettingsSidebar();++ H.openSeriesSettings("Count");++ replaceMissingValuesWith(replacementValue);++ assertOnTheYAxis();++ H.cartesianChartCircle()+ .should("have.length", 6)+ .eq(-2)+ .trigger("mousemove");++ H.assertEChartsTooltip({+ header: "2019",+ rows: [+ {+ name: "Count",+ value: "6,524",+ },+ ],+ });+ });+ });+ },+);diff --git a/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js b/e2e/test/scenarios/visualizations/charts/maps.cy.spec.jsindex d9d5f61e294..8ebb196253d 100644--- a/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js@@ -478,6 +478,329 @@ describe("scenarios > visualizations > maps", () => {});},);++ describe("issue 18061", () => {+ const questionDetails = {+ name: "18061",+ query: {+ "source-table": PEOPLE_ID,+ expressions: {+ CClat: [+ "case",+ [+ [+ [">", ["field", PEOPLE.ID, null], 1],+ ["field", PEOPLE.LATITUDE, null],+ ],+ ],+ ],+ CClong: [+ "case",+ [+ [+ [">", ["field", PEOPLE.ID, null], 1],+ ["field", PEOPLE.LONGITUDE, null],+ ],+ ],+ ],+ },+ filter: ["<", ["field", PEOPLE.ID, null], 3],+ },+ display: "map",+ visualization_settings: {+ "map.latitude_column": "CClat",+ "map.longitude_column": "CClong",+ },+ };++ const filter = {+ name: "Category",+ slug: "category",+ id: "749a03b5",+ type: "category",+ };++ const dashboardDetails = { name: "18061D", parameters: [filter] };++ function addFilter(filter) {+ H.filterWidget().click();+ H.popover().contains(filter).click();+ cy.button("Add filter").click();+ }++ beforeEach(() => {+ H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(+ ({ body: dashboardCard }) => {+ const { dashboard_id, card_id } = dashboardCard;++ // Enable sharing+ cy.request("POST", `/api/dashboard/${dashboard_id}/public_link`).then(+ ({ body: { uuid } }) => {+ cy.wrap(`/public/dashboard/${uuid}`).as("publicLink");+ },+ );++ cy.wrap(`/question/${card_id}`).as("questionUrl");+ cy.wrap(`/dashboard/${dashboard_id}`).as("dashboardUrl");++ cy.intercept("POST", `/api/card/${card_id}/query`).as("cardQuery");+ cy.intercept(+ "POST",+ `/api/dashboard/${dashboard_id}/dashcard/*/card/${card_id}/query`,+ ).as("dashCardQuery");+ cy.intercept("GET", `/api/card/${card_id}`).as("getCard");++ const mapFilterToCard = {+ parameter_mappings: [+ {+ parameter_id: filter.id,+ card_id,+ target: ["dimension", ["field", PEOPLE.SOURCE, null]],+ },+ ],+ };++ H.editDashboardCard(dashboardCard, mapFilterToCard);+ },+ );+ });++ context("scenario 1: question with a filter", () => {+ it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-1)", () => {+ H.visitAlias("@questionUrl");++ cy.wait("@getCard");+ cy.wait("@cardQuery");++ cy.intercept("POST", "/api/dataset").as("dataset");+ cy.window().then((w) => (w.beforeReload = true));++ H.queryBuilderHeader()+ .findByTestId("filters-visibility-control")+ .click();+ cy.findByTestId("qb-filters-panel")+ .findByText("ID is less than 3")+ .click();+ H.popover().within(() => {+ cy.findByDisplayValue("3").type("{backspace}2");+ cy.button("Update filter").click();+ });+ cy.wait("@dataset");++ H.assertQueryBuilderRowCount(1);+ H.queryBuilderMain()+ .findByText("Something went wrong")+ .should("not.exist");++ cy.findByTestId("qb-filters-panel")+ .findByText("ID is less than 2")+ .should("be.visible");+ cy.get("[data-element-id=pin-map]").should("be.visible");++ cy.window().should("have.prop", "beforeReload", true);+ });+ });++ context("scenario 2: dashboard with a filter", () => {+ it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-2)", () => {+ H.visitAlias("@dashboardUrl");++ cy.wait("@dashCardQuery");+ cy.window().then((w) => (w.beforeReload = true));++ addFilter("Twitter");++ cy.wait("@dashCardQuery");+ cy.location("search").should("eq", "?category=Twitter");++ // The only matching row has null coordinates, so the dashcard shows no results.+ H.getDashboardCard(0).findByTestId("no-results-image").should("exist");+ H.getDashboardCard(0)+ .findByText("Something went wrong")+ .should("not.exist");+ cy.window().should("have.prop", "beforeReload", true);+ });+ });++ context("scenario 3: publicly shared dashboard with a filter", () => {+ it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-3)", () => {+ H.visitAlias("@publicLink");++ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("18061D");+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("18061");+ cy.get("[data-element-id=pin-map]");++ addFilter("Twitter");+ cy.location("search").should("eq", "?category=Twitter");+ cy.findAllByTestId("no-results-image");+ cy.get("[data-element-id=pin-map]").should("not.exist");+ });+ });+ });++ describe("issue 18063", () => {+ const questionDetails = {+ name: "18063",+ native: {+ query:+ 'select null "LATITUDE", null "LONGITUDE", null "COUNT", \'NULL ROW\' "NAME"\nunion all select 55.6761, 12.5683, 1, \'Copenhagen\'\n',+ "template-tags": {},+ },+ display: "map",+ };++ function selectFieldValue(field, value) {+ toggleFieldSelectElement(field);+ H.popover().findByText(value).click();+ }++ beforeEach(() => {+ H.createNativeQuestion(questionDetails, { visitQuestion: true });++ // Select a Pin map+ H.openVizSettingsSidebar();+ cy.findByTestId("chart-settings-widget-map.type")+ .findByDisplayValue("Region map")+ .click();+ H.popover().contains("Pin map").click();++ // Click on the popovers to close both popovers that open automatically.+ // Please see: https://github.com/metabase/metabase/issues/18063#issuecomment-927836691+ ["Latitude field", "Longitude field"].forEach((field) =>+ H.leftSidebar().within(() => {+ cy.get(`[data-field-title="${field}"]`)+ .findByPlaceholderText("Select a field")+ .should("exist");+ toggleFieldSelectElement(field);+ }),+ );+ });++ it("should show the correct tooltip details for pin map even when some locations are null (metabase#18063)", () => {+ selectFieldValue("Latitude field", "LATITUDE");+ selectFieldValue("Longitude field", "LONGITUDE");++ cy.get(".leaflet-marker-icon").trigger("mousemove");++ H.tooltip().within(() => {+ H.testPairedTooltipValues("LATITUDE", "55.68");+ H.testPairedTooltipValues("LONGITUDE", "12.57");+ H.testPairedTooltipValues("COUNT", "1");+ H.testPairedTooltipValues("NAME", "Copenhagen");+ });+ });+ });++ describe("issues 32075, 30058", () => {+ const testQuery = {+ type: "query",+ query: {+ "source-query": {+ "source-table": PEOPLE_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ PEOPLE.LATITUDE,+ { "base-type": "type/Float", binning: { strategy: "default" } },+ ],+ [+ "field",+ PEOPLE.LONGITUDE,+ { "base-type": "type/Float", binning: { strategy: "default" } },+ ],+ ],+ },+ },+ database: SAMPLE_DB_ID,+ };++ const addCountGreaterThan2Filter = () => {+ H.openNotebook();+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ cy.findAllByTestId("action-buttons").last().button("Filter").click();+ H.popover().findByText("Count").click();+ H.selectFilterOperator("Greater than");+ H.popover().within(() => {+ cy.findByPlaceholderText("Enter a number").type("2");+ cy.button("Add filter").click();+ });+ };++ beforeEach(() => {+ cy.signInAsNormalUser();+ });++ it("should still display visualization as a map after adding a filter (metabase#32075)", () => {+ H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });++ H.visualize();+ addCountGreaterThan2Filter();+ H.visualize();++ H.assertQueryBuilderRowCount(21);+ H.tableInteractive().should("not.exist");+ cy.get("[data-element-id=pin-map]").should("exist");+ });++ it("should still display visualization as a map after adding another column to group by", () => {+ H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });++ H.visualize();+ H.openNotebook();+ H.addSummaryGroupingField({ field: "Birth Date" });+ H.visualize();++ H.assertQueryBuilderRowCount(1965);+ H.tableInteractive().should("not.exist");+ cy.get("[data-element-id=pin-map]").should("exist");+ });++ it("should still display visualization as a map after adding another aggregation", () => {+ H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });++ H.visualize();+ H.openNotebook();+ H.addSummaryField({ metric: "Average of ...", field: "Longitude" });+ H.visualize();++ // The row count does not change, so wait until the query stops running+ H.queryBuilderMain()+ .findByText(/^Doing science/)+ .should("not.exist");+ H.tableInteractive().should("not.exist");+ cy.get("[data-element-id=pin-map]").should("exist");+ });++ it("should change display to default after removing a column to group by when map is not sensible anymore", () => {+ H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });++ H.visualize();+ H.openNotebook();+ H.removeSummaryGroupingField({ field: "Latitude: Auto binned" });+ H.visualize();++ cy.get("[data-element-id=pin-map]").should("not.exist");+ H.echartsContainer().should("exist");+ });++ it("should not crash visualization after adding a filter (metabase#30058)", () => {+ H.visitQuestionAdhoc({+ dataset_query: testQuery,+ display: "map",+ displayIsLocked: true,+ });++ addCountGreaterThan2Filter();+ H.visualize();++ H.assertQueryBuilderRowCount(21);+ cy.get("[data-element-id=pin-map]").should("exist");+ cy.get(".Icon-warning").should("not.exist");+ });+ });});function toggleFieldSelectElement(field) {diff --git a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.jsindex 9d09425a1d9..d7cf58d746e 100644--- a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js@@ -667,6 +667,104 @@ describe("scenarios > visualizations > pie chart", () => {},});});++ it("should format pie chart settings (metabase#21504)", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ database: SAMPLE_DB_ID,+ },+ display: "pie",+ });++ H.openVizSettingsSidebar();++ H.leftSidebar().within(() => {+ cy.findByText("January 2028").should("be.visible");+ });+ });++ it("pie chart should have a placeholder", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": PRODUCTS_ID,+ },+ database: SAMPLE_DB_ID,+ },+ display: "pie",+ });++ cy.log("Shows an empty state that can open the summarize sidebar");+ cy.findByAltText("pie chart example illustration").should("be.visible");+ cy.findByLabelText("Open summarize sidebar").click();++ cy.findByLabelText("Rating").click();+ H.echartsContainer().findByText("200").should("be.visible");+ H.echartsContainer().findByText("Total").should("be.visible");+ });++ it("pie chart should work when instance colors have overrides", () => {+ cy.signInAsAdmin();+ H.activateToken("pro-self-hosted");+ H.updateSetting("application-colors", { "accent0-light": "#98b4ce" });++ H.visitQuestionAdhoc({+ dataset_query: {+ type: "query",+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [["field", PRODUCTS.CATEGORY, null]],+ },+ database: SAMPLE_DB_ID,+ },+ display: "pie",+ });++ H.echartsContainer().findByText("200").should("be.visible");++ H.openVizSettingsSidebar();++ H.leftSidebar().findByText("Gizmo");+ });++ it("should show tooltips with reasonable width for pie charts with long text labels (metabase#63026)", () => {+ const query = `select '${"a".repeat(1000)}' as category, 45 as count+union all select 'Short name', 25 as count+union all select 'Medium length category', 30 as count`;++ H.visitQuestionAdhoc({+ display: "pie",+ dataset_query: {+ type: "native",+ native: {+ query,+ },+ database: SAMPLE_DB_ID,+ },+ visualization_settings: {+ "pie.show_labels": true,+ },+ });++ H.chartPathWithFillColor("#88BF4D").trigger("mousemove");++ cy.get("[data-testid='echarts-tooltip']")+ .should("be.visible")+ .then(($tooltip) => {+ const width = $tooltip.width();+ expect(width).to.be.lte(550);+ });+ });});function ensurePieChartRendered(rows, middleRows, outerRows, totalValue) {diff --git a/e2e/test/scenarios/visualizations/charts/scatter.cy.spec.js b/e2e/test/scenarios/visualizations/charts/scatter.cy.spec.jsindex 324a8467f5b..6e180ea8b08 100644--- a/e2e/test/scenarios/visualizations/charts/scatter.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/scatter.cy.spec.js@@ -233,6 +233,53 @@ select 10 as size, 2 as x, 5 as y`,rows: allTooltipRows.slice(0, 2),});});++ it("should render scatter plot with native query data (metabase#55880)", () => {+ H.visitQuestionAdhoc({+ visualization_settings: {+ "graph.dimensions": ["X"],+ "graph.metrics": ["Y"],+ },+ dataset_query: {+ type: "native",+ native: {+ query: `select * from (+ select 1415 x, 1 y+ union all select 20, 2+ union all select 900, 3+ union all select 115, 4+) as subquery+where x < {{param}}`,+ "template-tags": {+ param: {+ type: "number",+ name: "param",+ id: "144103a1-ebd4-4477-a7fa-f08cfd808d5e",+ "display-name": "Param",+ required: true,+ default: "30",+ },+ },+ },+ database: SAMPLE_DB_ID,+ },+ display: "scatter",+ });++ // Renders a scatter chart with numeric x-axis+ H.chartPathWithFillColor("#88BF4D").should("have.length", 1);+ H.echartsContainer().findByText("20");++ H.saveQuestion("55880");++ // Change filter value so values include numbers that can be parsed as valid dates+ cy.findByPlaceholderText("Param").clear().type("1500");+ H.runNativeQuery();++ // Still renders a scatter chart with numeric x-axis+ H.echartsContainer().findByText("1,500");+ H.chartPathWithFillColor("#88BF4D").should("have.length", 4);+ });});// Hack that is needed because of the flakiness caused by adding throttle to the ExplicitSize component.diff --git a/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.jsdeleted file mode 100644index c5a9b55d65f..00000000000--- a/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.js+++ /dev/null@@ -1,1162 +0,0 @@-const { H } = cy;-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;-const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;-const { PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;-const { REVIEWS, REVIEWS_ID } = SAMPLE_DATABASE;--const externalDatabaseId = 2;--describe("issue 16170", { tags: "@mongo" }, () => {- function replaceMissingValuesWith(value) {- cy.get('[data-field-title="Replace missing values with"]').within(() => {- cy.findByTestId("chart-setting-select").click();- });-- H.popover().contains(value).click();- H.popover().findByDisplayValue(value);-- // click outside popover- cy.findByTestId("chartsettings-list-container").click();- }-- function assertOnTheYAxis() {- H.echartsContainer().get("text").contains("Count");-- H.echartsContainer().get("text").contains("6,000");- }-- beforeEach(() => {- H.restore("mongo-5");- cy.signInAsAdmin();-- H.withDatabase(externalDatabaseId, ({ ORDERS, ORDERS_ID }) => {- const questionDetails = {- name: "16170",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],- },- database: externalDatabaseId,- display: "line",- };-- H.createQuestion(questionDetails, { visitQuestion: true });- });- });-- ["Zero", "Nothing"].forEach((replacementValue) => {- it(`replace missing values with "${replacementValue}" should work on Mongo (metabase#16170)`, () => {- H.openVizSettingsSidebar();-- H.openSeriesSettings("Count");-- replaceMissingValuesWith(replacementValue);-- assertOnTheYAxis();-- H.cartesianChartCircle()- .should("have.length", 6)- .eq(-2)- .trigger("mousemove");-- H.assertEChartsTooltip({- header: "2019",- rows: [- {- name: "Count",- value: "6,524",- },- ],- });- });- });-});--describe("issue 17524", () => {- const nativeQuestionDetails = {- native: {- query:- "select * from (\nselect 'A' step, 41 users, 42 median union all\nselect 'B' step, 31 users, 32 median union all\nselect 'C' step, 21 users, 22 median union all\nselect 'D' step, 11 users, 12 median\n) x\n[[where users>{{num}}]]\n",- "template-tags": {- num: {- id: "d7f1fb15-c7b8-6051-443d-604b6ed5457b",- name: "num",- "display-name": "Num",- type: "number",- default: null,- },- },- },- display: "funnel",- visualization_settings: {- "funnel.dimension": "STEP",- "funnel.metric": "USERS",- },- };-- const questionDetails = {- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"], ["sum", ["field", PRODUCTS.PRICE, null]]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- display: "funnel",- visualization_settings: {- "funnel.metric": "count",- "funnel.dimension": "CATEGORY",- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- describe("scenario 1", () => {- beforeEach(() => {- H.createNativeQuestion(nativeQuestionDetails, { visitQuestion: true });- });-- it("should not alter visualization type when applying filter on a native question (metabase#17524-1)", () => {- H.filterWidget().type("1");-- cy.get("polygon");-- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.icon("play").last().click();-- cy.get("polygon");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Save").should("not.exist");- });- });-- describe("scenario 2", () => {- beforeEach(() => {- H.createQuestion(questionDetails, { visitQuestion: true });- });-- it("should not alter visualization type when applying filter on a QB question (metabase#17524-2)", () => {- cy.get("polygon");-- H.filter();- H.popover().findByText("ID").click();- H.selectFilterOperator("Greater than");- H.popover().within(() => {- cy.findByLabelText("Filter value").type("1");- cy.button("Apply filter").click();- });- cy.get("polygon");- });- });-});--describe("issue 18061", () => {- const questionDetails = {- name: "18061",- query: {- "source-table": PEOPLE_ID,- expressions: {- CClat: [- "case",- [- [- [">", ["field", PEOPLE.ID, null], 1],- ["field", PEOPLE.LATITUDE, null],- ],- ],- ],- CClong: [- "case",- [- [- [">", ["field", PEOPLE.ID, null], 1],- ["field", PEOPLE.LONGITUDE, null],- ],- ],- ],- },- filter: ["<", ["field", PEOPLE.ID, null], 3],- },- display: "map",- visualization_settings: {- "map.latitude_column": "CClat",- "map.longitude_column": "CClong",- },- };-- const filter = {- name: "Category",- slug: "category",- id: "749a03b5",- type: "category",- };-- const dashboardDetails = { name: "18061D", parameters: [filter] };-- function addFilter(filter) {- H.filterWidget().click();- H.popover().contains(filter).click();- cy.button("Add filter").click();- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(- ({ body: dashboardCard }) => {- const { dashboard_id, card_id } = dashboardCard;-- // Enable sharing- cy.request("POST", `/api/dashboard/${dashboard_id}/public_link`).then(- ({ body: { uuid } }) => {- cy.wrap(`/public/dashboard/${uuid}`).as("publicLink");- },- );-- cy.wrap(`/question/${card_id}`).as("questionUrl");- cy.wrap(`/dashboard/${dashboard_id}`).as("dashboardUrl");-- cy.intercept("POST", `/api/card/${card_id}/query`).as("cardQuery");- cy.intercept(- "POST",- `/api/dashboard/${dashboard_id}/dashcard/*/card/${card_id}/query`,- ).as("dashCardQuery");- cy.intercept("GET", `/api/card/${card_id}`).as("getCard");-- const mapFilterToCard = {- parameter_mappings: [- {- parameter_id: filter.id,- card_id,- target: ["dimension", ["field", PEOPLE.SOURCE, null]],- },- ],- };-- H.editDashboardCard(dashboardCard, mapFilterToCard);- },- );- });-- context("scenario 1: question with a filter", () => {- it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-1)", () => {- H.visitAlias("@questionUrl");-- cy.wait("@getCard");- cy.wait("@cardQuery");-- cy.window().then((w) => (w.beforeReload = true));-- H.queryBuilderHeader().findByTestId("filters-visibility-control").click();- cy.findByTestId("qb-filters-panel")- .findByText("ID is less than 3")- .click();- H.popover().within(() => {- cy.findByDisplayValue("3").type("{backspace}2");- cy.button("Update filter").click();- });-- H.queryBuilderMain()- .findByText("Something went wrong")- .should("not.exist");-- cy.findByTestId("qb-filters-panel")- .findByText("ID is less than 2")- .should("be.visible");- cy.get("[data-element-id=pin-map]").should("be.visible");-- cy.window().should("have.prop", "beforeReload", true);- });- });-- context("scenario 2: dashboard with a filter", () => {- it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-2)", () => {- H.visitAlias("@dashboardUrl");-- cy.wait("@dashCardQuery");-- addFilter("Twitter");-- cy.wait("@dashCardQuery");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Something went wrong").should("not.exist");-- cy.location("search").should("eq", "?category=Twitter");- });- });-- context("scenario 3: publicly shared dashboard with a filter", () => {- it("should handle data sets that contain only null values for longitude/latitude (metabase#18061-3)", () => {- H.visitAlias("@publicLink");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("18061D");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("18061");- cy.get("[data-element-id=pin-map]");-- addFilter("Twitter");- cy.location("search").should("eq", "?category=Twitter");- cy.findAllByTestId("no-results-image");- cy.get("[data-element-id=pin-map]").should("not.exist");- });- });-});--describe("issue 18063", () => {- const questionDetails = {- name: "18063",- native: {- query:- 'select null "LATITUDE", null "LONGITUDE", null "COUNT", \'NULL ROW\' "NAME"\nunion all select 55.6761, 12.5683, 1, \'Copenhagen\'\n',- "template-tags": {},- },- display: "map",- };-- function toggleFieldSelectElement(field) {- return cy.get(`[data-field-title="${field}"]`).within(() => {- cy.findByPlaceholderText("Select a field").click();- });- }-- function selectFieldValue(field, value) {- toggleFieldSelectElement(field);- H.popover().findByText(value).click();- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createNativeQuestion(questionDetails, { visitQuestion: true });-- // Select a Pin map- H.openVizSettingsSidebar();- cy.findByTestId("chart-settings-widget-map.type")- .findByDisplayValue("Region map")- .click();- H.popover().contains("Pin map").click();-- // Click on the popovers to close both popovers that open automatically.- // Please see: https://github.com/metabase/metabase/issues/18063#issuecomment-927836691- ["Latitude field", "Longitude field"].forEach((field) =>- H.leftSidebar().within(() => {- toggleFieldSelectElement(field);- }),- );- });-- it("should show the correct tooltip details for pin map even when some locations are null (metabase#18063)", () => {- selectFieldValue("Latitude field", "LATITUDE");- selectFieldValue("Longitude field", "LONGITUDE");-- cy.get(".leaflet-marker-icon").trigger("mousemove");-- H.tooltip().within(() => {- H.testPairedTooltipValues("LATITUDE", "55.68");- H.testPairedTooltipValues("LONGITUDE", "12.57");- H.testPairedTooltipValues("COUNT", "1");- H.testPairedTooltipValues("NAME", "Copenhagen");- });- });-});--describe("issue 18776", () => {- const questionDetails = {- dataset_query: {- type: "native",- native: {- query: `- select 101002 as "id", 1 as "rate"- union all select 103017, 2- union all select 210002, 3`,- },- database: SAMPLE_DB_ID,- },- display: "bar",- visualization_settings: {- "graph.dimensions": ["id"],- "graph.metrics": ["rate"],- "graph.x_axis.axis_enabled": false,- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not freeze when opening a timeseries chart with sparse data and without the X-axis", () => {- H.visitQuestionAdhoc(questionDetails);- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Visualization").should("be.visible");- });-});--describe("issue 20548", () => {- const questionDetails = {- name: "20548",- query: {- "source-table": PRODUCTS_ID,- aggregation: [["sum", ["field", PRODUCTS.PRICE, null]], ["count"]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- display: "bar",- // We are reversing the order of metrics via API- visualization_settings: {- "graph.metrics": ["count", "sum"],- "graph.dimensions": ["CATEGORY"],- },- };-- function removeAggregationItem(item) {- cy.findAllByTestId("aggregation-item")- .contains(item)- .siblings(".Icon-close")- .click();-- cy.wait("@dataset");- }-- function addAggregationItem(item) {- cy.findByTestId("add-aggregation-button").click();- H.popover().contains(item).click();-- cy.wait("@dataset");- }-- /**- * @param {string} item- * @param {number} frequency- */- function assertOnLegendItemFrequency(item, frequency) {- cy.findAllByTestId("legend-item")- .contains(item)- .should("have.length", frequency);- }-- beforeEach(() => {- cy.intercept("POST", "/api/dataset").as("dataset");-- H.restore();- cy.signInAsAdmin();-- H.createQuestion(questionDetails, { visitQuestion: true });- H.summarize();- });-- it("should not display duplicate Y-axis after modifying/reordering metrics (metabase#20548)", () => {- removeAggregationItem("Count");- // Ensure bars of only one series exist- H.chartPathWithFillColor("#88BF4D").should("have.length", 4);- H.chartPathWithFillColor("#509EE3").should("not.exist");-- addAggregationItem("Count");- // Ensure bars of two series exist- H.chartPathWithFillColor("#88BF4D").should("have.length", 4);- H.chartPathWithFillColor("#509EE3").should("have.length", 4);-- // Although the test already fails on the previous step, let's add some more assertions to prevent future regressions- assertOnLegendItemFrequency("Count", 1);- assertOnLegendItemFrequency("Sum of Price", 1);-- H.openVizSettingsSidebar();- H.sidebar().findByDisplayValue("Count").should("be.visible");- });-});--describe("issue 21452", () => {- const questionDetails = {- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [["cum-sum", ["field", ORDERS.QUANTITY, null]]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],- },- database: 1,- },- display: "line",- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.visitQuestionAdhoc(questionDetails);-- H.openVizSettingsSidebar();- });-- it("should not fire POST request after every character during display name change (metabase#21452)", () => {- H.openSeriesSettings("Cumulative sum of Quantity");- H.popover()- .findByDisplayValue("Cumulative sum of Quantity")- .clear()- .type("Foo");-- H.popover().findByText("Display type").click();-- cy.log("Dismiss the popup and close settings");- H.leftSidebar().button("Done").click();-- // trigger("mousemove") is more reliable than realHover- // maybe related to https://github.com/dmtrKovalenko/cypress-real-events/issues/691- H.cartesianChartCircle().first().trigger("mousemove");-- H.assertEChartsTooltip({- header: "2025",- rows: [- {- color: "#88BF4D",- name: "Foo",- value: "3,236",- },- ],- });-- cy.get("@dataset.all").should("have.length", 1);- });-});--describe("issue 21504", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should format pie chart settings (metabase#21504)", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- database: SAMPLE_DB_ID,- },- display: "pie",- });-- H.openVizSettingsSidebar();-- H.leftSidebar().within(() => {- cy.findByText("January 2028").should("be.visible");- });- });-});--describe("issue 21665", () => {- const Q1 = {- name: "21665 Q1",- native: { query: "select 1" },- display: "scalar",- };-- const Q2 = {- name: "21665 Q2",- native: { query: "select 2" },- display: "scalar",- };-- function editQ2NativeQuery(query, questionId) {- cy.request("PUT", `/api/card/${questionId}`, {- dataset_query: {- type: "native",- native: { query },- database: 1,- },- });- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- cy.intercept("POST", "/api/card/*/query").as("cardQuery");-- H.createNativeQuestionAndDashboard({- questionDetails: Q1,- dashboardDetails: { name: "21665D" },- }).then(({ dashboardId, questionId }) => {- cy.intercept(- "GET",- `/api/dashboard/${dashboardId}*`,- cy.spy().as("dashboardLoaded"),- ).as("getDashboard");-- cy.wrap(questionId).as("questionId");- cy.log("dashboard id", dashboardId);- cy.wrap(dashboardId).as("dashboardId");-- H.createNativeQuestion(Q2);-- H.visitDashboard(dashboardId);- H.editDashboard();- });-- H.getDashboardCard(0)- .realHover({ scrollBehavior: "bottom" })- .findByLabelText("Visualize another way")- .click();- H.modal().within(() => {- H.switchToAddMoreData();- H.selectDataset(Q2.name);- cy.button("Save").click();- });-- H.saveDashboard();- });-- it("multi-series cards shouldnt cause frontend to reload (metabase#21665)", () => {- cy.get("@questionId").then((questionId) => {- editQ2NativeQuery("select order by --", questionId);- });-- H.visitDashboard("@dashboardId");-- // The dashboard loads twice: once on the initial visit, once on re-visit.- cy.get("@dashboardLoaded").should("have.callCount", 2);- cy.findByTestId("dashcard")- .findByText(- "Some columns are missing, this card might not render correctly.",- )- .should("be.visible");- });-});--describe("issue 25156", () => {- const questionDetails = {- name: "25156",- query: {- "source-table": REVIEWS_ID,- aggregation: [["count"]],- breakout: [- ["field", REVIEWS.CREATED_AT, { "temporal-unit": "year" }],- ["field", REVIEWS.RATING, null],- ],- },- display: "bar",- visualization_settings: {- "graph.dimensions": ["CREATED_AT", "RATING"],- "graph.metrics": ["count"],- "graph.x_axis.scale": "linear",- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should handle invalid x-axis scale (metabase#25156)", () => {- H.createQuestion(questionDetails, { visitQuestion: true });-- H.echartsContainer()- .should("contain", "2025")- .and("contain", "2026")- .and("contain", "2026")- .and("contain", "2027")- .and("contain", "2028");- });-});--describe("issue 27279", () => {- const questionDetails = {- name: "27279",- native: {- query:- "select -3 o, 'F2021' k, 1 v\nunion all select -2, 'V2021', 2\nunion all select -1, 'S2022', 3\nunion all select 0, 'F2022', 4",- "template-tags": {},- },- visualization_settings: {- "table.pivot_column": "O",- "table.cell_column": "V",- },- };- function compareValuesInOrder(selector, values) {- selector.each(($item, index) => {- cy.wrap($item).invoke("text").should("eq", values[index]);- });- }-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should reflect/apply sorting to the x-axis (metabase#27279)", () => {- H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": `card__${id}`,- aggregation: [- ["sum", ["field", "V", { "base-type": "type/Integer" }]],- ],- breakout: [- ["field", "K", { "base-type": "type/Text" }],- ["field", "O", { "base-type": "type/Integer" }],- ],- "order-by": [- ["asc", ["field", "O", { "base-type": "type/Integer" }]],- ],- },- database: SAMPLE_DB_ID,- },- display: "bar",- visualization_settings: {- "graph.dimensions": ["K", "O"],- "graph.metrics": ["sum"],- },- });- });-- const legendItems = ["-3", "-2", "-1", "0"];- compareValuesInOrder(cy.findAllByTestId("legend-item"), legendItems);-- // need to add a single space on either side of the text as it is used as padding- // in ECharts- const xAxisTicks = ["F2021", "V2021", "S2022", "F2022"].map(- (str) => ` ${str} `,- );- compareValuesInOrder(- H.echartsContainer()- .get("text")- .contains(/F2021|V2021|S2022|F2022/),- xAxisTicks,- );-- // Extra step, just to be overly cautious- H.chartPathWithFillColor("#98D9D9").realHover();-- H.assertEChartsTooltip({- header: "F2021",- rows: [- {- color: "#98D9D9",- name: "-3",- value: "1",- },- {- color: "#F2A86F",- name: "-2",- value: "(empty)",- },- {- color: "#F9D45C",- name: "-1",- value: "(empty)",- },- {- color: "#509EE3",- name: "0",- value: "(empty)",- },- ],- });-- H.chartPathWithFillColor("#509EE3").realHover();- H.assertEChartsTooltip({- header: "F2022",- rows: [- {- color: "#98D9D9",- name: "-3",- value: "(empty)",- },- {- color: "#F2A86F",- name: "-2",- value: "(empty)",- },- {- color: "#F9D45C",- name: "-1",- value: "(empty)",- },- {- color: "#509EE3",- name: "0",- value: "4",- },- ],- });- });-});--// Test for issue 27427 (static-viz with unused returned column)-// has been moved to backend test in metabase.channel.render.card-test--const addCountGreaterThan2Filter = () => {- H.openNotebook();- // eslint-disable-next-line metabase/no-unsafe-element-filtering- cy.findAllByTestId("action-buttons").last().button("Filter").click();- H.popover().findByText("Count").click();- H.selectFilterOperator("Greater than");- H.popover().within(() => {- cy.findByPlaceholderText("Enter a number").type("2");- cy.button("Add filter").click();- });-};--describe("issue 32075", () => {- const testQuery = {- type: "query",- query: {- "source-query": {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [- [- "field",- PEOPLE.LATITUDE,- { "base-type": "type/Float", binning: { strategy: "default" } },- ],- [- "field",- PEOPLE.LONGITUDE,- { "base-type": "type/Float", binning: { strategy: "default" } },- ],- ],- },- },- database: SAMPLE_DB_ID,- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should still display visualization as a map after adding a filter (metabase#32075)", () => {- H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });-- H.visualize();- addCountGreaterThan2Filter();- H.visualize();-- H.tableInteractive().should("not.exist");- cy.get("[data-element-id=pin-map]").should("exist");- });-- it("should still display visualization as a map after adding another column to group by", () => {- H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });-- H.visualize();- H.openNotebook();- H.addSummaryGroupingField({ field: "Birth Date" });- H.visualize();-- H.tableInteractive().should("not.exist");- cy.get("[data-element-id=pin-map]").should("exist");- });-- it("should still display visualization as a map after adding another aggregation", () => {- H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });-- H.visualize();- H.openNotebook();- H.addSummaryField({ metric: "Average of ...", field: "Longitude" });- H.visualize();-- H.tableInteractive().should("not.exist");- cy.get("[data-element-id=pin-map]").should("exist");- });-- it("should change display to default after removing a column to group by when map is not sensible anymore", () => {- H.visitQuestionAdhoc({ dataset_query: testQuery }, { mode: "notebook" });-- H.visualize();- H.openNotebook();- H.removeSummaryGroupingField({ field: "Latitude: Auto binned" });- H.visualize();-- cy.get("[data-element-id=pin-map]").should("not.exist");- H.echartsContainer().should("exist");- });-});--describe("issue 30058", () => {- const testQuery = {- type: "query",- query: {- "source-query": {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [- [- "field",- PEOPLE.LATITUDE,- { "base-type": "type/Float", binning: { strategy: "default" } },- ],- [- "field",- PEOPLE.LONGITUDE,- { "base-type": "type/Float", binning: { strategy: "default" } },- ],- ],- },- },- database: SAMPLE_DB_ID,- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not crash visualization after adding a filter (metabase#30058)", () => {- H.visitQuestionAdhoc({- dataset_query: testQuery,- display: "map",- displayIsLocked: true,- });-- addCountGreaterThan2Filter();- H.visualize();-- cy.get(".Icon-warning").should("not.exist");- });-});--describe("issue 33208", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.createNativeQuestion(- {- native: {- query:- "select distinct category from products where {{category}} order by category",- "template-tags": {- category: {- type: "dimension",- name: "category",- id: "82e3e985-5bd8-4503-a628-15201bad321b",- "display-name": "Category",- required: true,- default: ["Doohickey", "Gizmo"],- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/=",- },- },- },- display: "scalar",- },- { visitQuestion: true },- );- });-- it("should not auto-select chart type when opening a saved native question with parameters that have default values (metabase#33208)", () => {- // The default value for the category parameter is ["Doohickey","Gizmo"], which means the query results should have two rows, meaning- // scalar is not a sensible chart type. Normally the chart type would be automatically changed to table, but this shouldn't happen.- cy.findByTestId("scalar-value").should("be.visible");- });-- it("should not auto-select chart type when saving a native question with parameters that have default values", () => {- cy.findByTestId("query-builder-main").findByText("Open Editor").click();- H.NativeEditor.focus().type(" ");- H.saveSavedQuestion("top category");- H.runNativeQuery({ wait: false });- cy.findByTestId("scalar-value").should("be.visible");- });-});--describe("issue 43077", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not fire an invalid API request when clicking a legend item on a cartesian chart with multiple aggregations", () => {- const cartesianQuestionDetails = {- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["sum", ["field", ORDERS.QUANTITY, null]],- ["sum", ["field", ORDERS.TOTAL, null]],- ],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- database: 1,- },- display: "line",- };- const cardRequestSpy = cy.spy();- cy.intercept("/api/card/*", cardRequestSpy);-- H.visitQuestionAdhoc(cartesianQuestionDetails);-- cy.findAllByTestId("legend-item").first().click();-- cy.wait(100).then(() => expect(cardRequestSpy).not.to.have.been.called);- });-- it("should not fire an invalid API request when clicking a legend item on a row chart with multiple aggregations", () => {- const rowQuestionDetails = {- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["sum", ["field", ORDERS.QUANTITY, null]],- ["sum", ["field", ORDERS.TOTAL, null]],- ],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- database: 1,- },- display: "row",- };- const cardRequestSpy = cy.spy();- cy.intercept("/api/card/*", cardRequestSpy);-- H.visitQuestionAdhoc(rowQuestionDetails);-- cy.findAllByTestId("legend-item").first().click();-- cy.wait(100).then(() => expect(cardRequestSpy).not.to.have.been.called);- });-});--describe("issue 49160", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- H.activateToken("pro-self-hosted");- });-- it("pie chart should have a placeholder", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": PRODUCTS_ID,- },- database: SAMPLE_DB_ID,- },- display: "pie",- });-- cy.log("Shows an empty state that can open the summarize sidebar");- cy.findByAltText("pie chart example illustration").should("be.visible");- cy.findByLabelText("Open summarize sidebar").click();-- cy.findByLabelText("Rating").click();- H.echartsContainer().findByText("200").should("be.visible");- H.echartsContainer().findByText("Total").should("be.visible");- });-- it("pie chart should work when instance colors have overrides", () => {- H.updateSetting("application-colors", { "accent0-light": "#98b4ce" });-- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- database: SAMPLE_DB_ID,- },- display: "pie",- });-- H.echartsContainer().findByText("200").should("be.visible");-- H.openVizSettingsSidebar();-- H.leftSidebar().findByText("Gizmo");- });-});--describe("issue 54271", () => {- const questionDetails = {- query: {- "source-table": REVIEWS_ID,- aggregation: [["count"]],- breakout: [["field", REVIEWS.REVIEWER, null]],- },- display: "line",- visualization_settings: {- "graph.dimensions": ["REVIEWER"],- "graph.metrics": [["count"]],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not crash the app when rendering a line chart with broken viz settings and table metadata (metabase#54271)", () => {- cy.log("broken semantic type - the field cannot be parsed as a date");- cy.request("PUT", `/api/field/${REVIEWS.REVIEWER}`, {- semantic_type: "type/CreationDate",- });-- cy.log("broken viz settings - dimensions cannot have a text column");- H.createQuestion(questionDetails, { visitQuestion: true });-- cy.log("no clear expectations but the app should not crash");- H.assertQueryBuilderRowCount(1076);- });-});--describe("issue 63671", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestion(- {- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- PRODUCTS.CREATED_AT,- {- "temporal-unit": "year",- },- ],- ],- filter: [- "between",- ["field", PRODUCTS.CREATED_AT, null],- "2028-01-01",- "2028-12-31",- ],- },- display: "bar",- },- { visitQuestion: true },- );- });-- it("should not show an extra value on bar charts when there is only value on the x axis (metabase#63671)", () => {- cy.findByTestId("query-visualization-root")- .findByText("2028")- .should("have.length", 1);- });-});diff --git a/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.ts b/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.tsdeleted file mode 100644index 7bdd23662fa..00000000000--- a/e2e/test/scenarios/visualizations/charts/visualizations-charts-reproductions.cy.spec.ts+++ /dev/null@@ -1,1010 +0,0 @@-const { H } = cy;-import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-import type { StructuredQuestionDetails } from "e2e/support/helpers";--const { PRODUCTS, PRODUCTS_ID, ORDERS, ORDERS_ID } = SAMPLE_DATABASE;--describe("issue 43075", () => {- const questionDetails: StructuredQuestionDetails = {- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [["field", PRODUCTS.CATEGORY, null]],- },- };-- beforeEach(() => {- cy.viewport(1000, 300);-- H.restore();- cy.signInAsAdmin();-- H.createQuestion(questionDetails, { visitQuestion: true });- });-- it("the breakout popover should fit within the window (metabase#43075)", () => {- cy.findAllByTestId("cell-data").contains("54").click();- H.popover().findByText("Break out by…").click();- H.popover().findByText("Category").click();-- cy.window().then((win) => {- expect(win.document.documentElement.scrollHeight).to.be.lte(- win.document.documentElement.offsetHeight,- );- });- });-});--describe("issue 41133", () => {- const questionDetails: StructuredQuestionDetails = {- query: {- "source-table": PRODUCTS_ID,- },- };-- beforeEach(() => {- cy.viewport(600, 400);- H.restore();- cy.signInAsAdmin();- H.createQuestion(questionDetails, { visitQuestion: true });- });-- it("object detail view should be scrollable on narrow screens (metabase#41133)", () => {- H.openObjectDetail(0);-- H.modal().within(() => {- cy.findByText("Created At").scrollIntoView().should("be.visible");- cy.findByText("is connected to:").scrollIntoView().should("be.visible");- });- });-});--describe("issue 45255", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.visitQuestionAdhoc({- dataset_query: {- type: "native",- native: {- query:- "select 'foo' step, 10 v union all select 'baz', 8 union all select null, 6 union all select 'bar', 4",- "template-tags": {},- },- database: SAMPLE_DB_ID,- },- display: "funnel",- });- });-- it("should work on native queries with null dimension values (metabase#45255)", () => {- H.openVizSettingsSidebar();-- // Has (empty) in the settings sidebar- H.sidebar().findByText("(empty)");-- // Can reorder (empty)- H.getDraggableElements().eq(2).should("have.text", "(empty)");- H.getDraggableElements().first().as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- vertical: 100,- useMouseEvents: true,- });- H.getDraggableElements().eq(1).should("have.text", "(empty)");-- // Has (empty) in the chart- cy.findByTestId("funnel-chart").findByText("(empty)");- });-});--describe("issue 49874, 48847", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("when two axis should show only one related to the hovered series", () => {- const question = {- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["sum", ["field", ORDERS.QUANTITY, null]],- ["sum", ["field", ORDERS.TOTAL, null]],- ],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- database: 1,- },- display: "bar",- };-- H.visitQuestionAdhoc(question);-- H.echartsContainer().within(() => {- cy.findByText("Sum of Quantity").should("be.visible");- cy.findByText("Sum of Total").should("be.visible");- });-- H.chartGridLines().should("exist");-- H.chartPathWithFillColor("#88BF4D").first().realHover();-- H.echartsContainer().within(() => {- cy.findByText("Sum of Quantity").should("be.visible");- cy.findByText("Sum of Total").should("not.exist");- });- H.chartGridLines().should("exist");-- H.chartPathWithFillColor("#98D9D9").first().realHover();-- H.echartsContainer().within(() => {- cy.findByText("Sum of Quantity").should("not.exist");- cy.findByText("Sum of Total").should("be.visible");- });- H.chartGridLines().should("exist");- });-});--describe("issue 49529", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should allow selecting breakout dimension before metrics", () => {- const question = {- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- },- database: 1,- },- display: "bar",- };-- H.visitQuestionAdhoc(question);-- H.openVizSettingsSidebar();-- cy.findAllByTestId("chart-setting-select")- .eq(0)- .as("dimensionSelect")- .click();- H.popover().findByText("ID").click();-- H.leftSidebar().findByText("Add series breakout").click();- H.popover().findByText("Quantity").click();-- H.leftSidebar().within(() => {- cy.findByText("Y-axis");- cy.findByText("Nothing to order");- });- });-});--describe("issue 47847", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should show chart tooltip on narrow ordinal line charts", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "week" }]],- },- database: SAMPLE_DB_ID,- },- display: "line",- visualization_settings: {- "graph.x_axis.scale": "ordinal",- "graph.show_values": true,- },- });-- H.cartesianChartCircleWithColor("#509EE3").eq(0).trigger("mousemove");- H.assertEChartsTooltip({- header: "April 27 – May 3, 2025", // expect this to break when we shift years in the Sample Database- blurAfter: false,- footer: null,- rows: [- {- color: "#509EE3",- name: "Count",- value: "1",- },- ],- });- });-});--describe("issue 51952", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should allow changing column settings for the x-axis column", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- database: SAMPLE_DB_ID,- },- display: "line",- visualization_settings: {},- });-- H.openVizSettingsSidebar();-- cy.findByTestId("settings-CREATED_AT").click();- H.popover().findByText("Abbreviate days and months").click();- H.echartsContainer().findByText("Jan 2027");- });-});--describe("issue 55880", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should render scatter plot with native query data", () => {- H.visitQuestionAdhoc({- visualization_settings: {- "graph.dimensions": ["X"],- "graph.metrics": ["Y"],- },- dataset_query: {- type: "native",- native: {- query: `select * from (- select 1415 x, 1 y- union all select 20, 2- union all select 900, 3- union all select 115, 4-) as subquery-where x < {{param}}`,- "template-tags": {- param: {- type: "number",- name: "param",- id: "144103a1-ebd4-4477-a7fa-f08cfd808d5e",- "display-name": "Param",- required: true,- default: "30",- },- },- },- database: SAMPLE_DB_ID,- },- display: "scatter",- });-- // Renders a scatter chart with numeric x-axis- H.chartPathWithFillColor("#88BF4D").should("have.length", 1);- H.echartsContainer().findByText("20");-- H.saveQuestion("55880");-- // Change filter value so values include numbers that can be parsed as valid dates- cy.findByPlaceholderText("Param").clear().type("1500");- H.runNativeQuery();-- // Still renders a scatter chart with numeric x-axis- H.echartsContainer().findByText("1,500");- H.chartPathWithFillColor("#88BF4D").should("have.length", 4);- });-});--describe("issue 47757", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should show correct tooltips for interpolated data points (metabase#47757)", () => {- H.visitQuestionAdhoc({- visualization_settings: {- "graph.dimensions": ["X"],- "graph.metrics": ["Y"],- series_settings: { Y: { "line.missing": "zero" } },- },- dataset_query: {- type: "native",- native: {- query: `select '2020-01-01' x, 10 y-union all select '2020-03-01' x, 30 y-union all select '2020-04-01' x, 40 y`,- },- database: SAMPLE_DB_ID,- },- display: "line",- });-- H.cartesianChartCircleWithColor("#88BF4D").eq(0).trigger("mousemove");- H.assertEChartsTooltip({- header: "January 2020",- rows: [- {- color: "#88BF4D",- name: "Y",- value: 10,- },- ],- footer: null,- blurAfter: true,- });-- H.cartesianChartCircleWithColor("#88BF4D").eq(1).trigger("mousemove");- H.assertEChartsTooltip({- header: "February 2020",- rows: [- {- color: "#88BF4D",- name: "Y",- value: 0,- secondaryValue: "-100%",- },- ],- footer: null,- blurAfter: true,- });-- H.cartesianChartCircleWithColor("#88BF4D").eq(2).trigger("mousemove");- H.assertEChartsTooltip({- header: "March 2020",- rows: [- {- color: "#88BF4D",- name: "Y",- value: 30,- secondaryValue: "+∞%",- },- ],- footer: null,- blurAfter: true,- });- });-});--describe("issue 59671", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not crash when removing dimension aggregation column from the query (metabase#59671)", () => {- const questionDetails: StructuredQuestionDetails = {- display: "line" as const,- query: {- "source-table": ORDERS_ID,- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],- aggregation: [["count"]],- },- visualization_settings: {- "graph.dimensions": ["CREATED_AT"],- "graph.metrics": ["count"],- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });- H.openNotebook();- H.removeSummaryGroupingField({- field: "Created At: Month",- stage: 0,- index: 0,- });- H.visualize();- });-});--describe("issue 59830", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not crash when saved dimension settings refer to a non-existent column (metabase#59830)", () => {- const questionDetails: StructuredQuestionDetails = {- display: "line" as const,- query: {- "source-table": ORDERS_ID,- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],- ],- aggregation: [["count"], ["avg", ["field", ORDERS.TOTAL, null]]],- },- visualization_settings: {- "graph.dimensions": ["DOES_NOT_EXIST"],- "graph.metrics": ["count"],- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });- cy.icon("warning").should("not.exist");- cy.findByTestId("chart-container").should("be.visible");- });-});--describe("issue 54755", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should show an empty state when no dimensions are available (metabase#54755)", () => {- const questionDetails: StructuredQuestionDetails = {- display: "line" as const,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- },- visualization_settings: {- "graph.dimensions": [],- "graph.metrics": ["count"],- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });- cy.icon("warning").should("not.exist");- cy.findByTestId("visualization-placeholder").should("be.visible");- });-});--describe("issue 63026", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should show tooltips with reasonable width for pie charts with long text labels (metabase#63026)", () => {- const query = `select '${"a".repeat(1000)}' as category, 45 as count-union all select 'Short name', 25 as count-union all select 'Medium length category', 30 as count`;-- H.visitQuestionAdhoc({- display: "pie",- dataset_query: {- type: "native",- native: {- query,- },- database: SAMPLE_DB_ID,- },- visualization_settings: {- "pie.show_labels": true,- },- });-- H.chartPathWithFillColor("#88BF4D").trigger("mousemove");-- cy.get("[data-testid='echarts-tooltip']")- .should("be.visible")- .then(($tooltip) => {- const width = $tooltip.width();- expect(width).to.be.lte(550);- });- });-});--describe("issue 68337", () => {- const longTooltipValue = "a".repeat(10000);-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should wrap long values without expanding the tooltip beyond the viewport (metabase#68337)", () => {- H.visitQuestionAdhoc({- display: "line",- dataset_query: {- type: "native",- native: {- query: `select 1 as x, 10 as metric_value, '${longTooltipValue}' as details-union all select 2, 20, 'short value'`,- },- database: SAMPLE_DB_ID,- },- visualization_settings: {- "graph.dimensions": ["X"],- "graph.metrics": ["METRIC_VALUE"],- "graph.tooltip_columns": [JSON.stringify(["name", "DETAILS"])],- },- });-- H.cartesianChartCircle()- .should("have.length", 2)- .first()- .trigger("mousemove");-- cy.window().then((appWindow) => {- H.echartsTooltip().then(($tooltip) => {- const tooltipRoot = $tooltip[0].parentElement;- expect(tooltipRoot).not.to.be.null;- if (tooltipRoot == null) {- return;- }-- const tooltipBounds = tooltipRoot.getBoundingClientRect();-- expect(tooltipBounds.left).to.be.at.least(0);- expect(tooltipBounds.right).to.be.at.most(appWindow.innerWidth);- expect(tooltipBounds.height).to.be.at.most(appWindow.innerHeight * 0.8);- expect(tooltipRoot.scrollHeight).to.be.greaterThan(- tooltipRoot.clientHeight,- );- });- });-- H.echartsTooltip()- .findByText(longTooltipValue)- .should(($value) => {- const value = $value[0];- const fontSize = Number.parseFloat(getComputedStyle(value).fontSize);-- expect(value.scrollWidth).to.be.at.most(value.clientWidth);- expect(value.clientHeight).to.be.greaterThan(fontSize * 2);- });- });-});--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().get("text").should("contain", "%");- H.chartPathWithFillColor("#88BF4D").should("have.length", 4);-- cy.log("Check that axis labels and title don't overlap");- H.echartsContainer()- .get("text")- .then(($texts) => {- const percentTexts: Array<{ text: string; element: HTMLElement }> = [];- const axisTitle: Array<{ text: string; element: HTMLElement }> = [];-- $texts.each((i, el) => {- const text = el.textContent?.trim() || "";- if (text.includes("%") && text !== "value") {- percentTexts.push({ text, element: el });- }- if (text === "value") {- axisTitle.push({ text, element: el });- }- });-- cy.log("Verify we have percentage labels");- expect(percentTexts.length).to.be.greaterThan(0);-- cy.log("Check that axis labels and title don't overlap");- if (axisTitle.length > 0 && percentTexts.length > 0) {- const titleRect = axisTitle[0].element.getBoundingClientRect();-- percentTexts.forEach(({ text, element }) => {- const labelRect = element.getBoundingClientRect();-- expect(- labelRect.left - titleRect.right,- `Label "${text}" should not overlap with axis title "${axisTitle[0].text}"`,- ).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("issue 10493", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should display bar chart for binned column distribution after applying filter (metabase#10493)", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- },- database: SAMPLE_DB_ID,- },- });-- cy.log("Click on Quantity column header and select Distribution");- H.tableHeaderClick("Quantity");- H.popover().findByText("Distribution").click();-- cy.log("Verify bar chart is displayed with binned quantity as dimension");- cy.findByTestId("visualization-root").should(- "have.attr",- "data-viz-ui-name",- "Bar",- );- H.echartsContainer().should("be.visible");- H.chartPathWithFillColor("#509EE3").should("exist");-- cy.log("Apply filter: count >= 20");- cy.findByTestId("qb-header-action-panel").findByText("Filter").click();- H.popover().within(() => {- cy.findByText("Summaries").click();- cy.findByText("Count").click();- });- H.selectFilterOperator("Greater than or equal to");- H.popover().within(() => {- cy.findByPlaceholderText("Enter a number").type("20");- cy.button("Apply filter").click();- });-- cy.wait("@dataset");-- cy.log(- "Verify bar chart is still displayed (binned column should still be treated as dimension)",- );- cy.findByTestId("query-builder-main")- .findByText(/^Doing science/)- .should("not.exist");- cy.findByTestId("visualization-placeholder").should("not.exist");- cy.findByTestId("visualization-root").should(- "have.attr",- "data-viz-ui-name",- "Bar",- );- H.echartsContainer().should("be.visible");- H.chartPathWithFillColor("#509EE3").should("exist");- });-});--describe("UXW-2696", () => {- const getChartPoints = () =>- H.echartsContainer().get("path[fill='hsla(0, 0%, 100%, 1.00)']");- const getNoPointsMessage = () =>- cy.findByRole("dialog", { name: /data points are off screen/i });-- const assertNoPoints = (assertMessage = true) => {- getChartPoints().should("have.length", 0);- if (assertMessage) {- getNoPointsMessage().should("exist");- }- };-- const assertDataVisible = () => {- getChartPoints().should("have.length.greaterThan", 0);- getNoPointsMessage().should("not.exist");- };-- const QUESTION_NAME = "Count of orders by month";-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createQuestion(- {- name: QUESTION_NAME,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ],- },- display: "line",- visualization_settings: {- "graph.y_axis.min": 700,- "graph.y_axis.max": 1000,- "graph.y_axis.auto_range": false,- },- },- { wrapId: true },- );- });-- it("should show you a popover when all data points are outside the y-axis range in the notebook editor", () => {- cy.get<number>("@questionId").then((id) => H.visitQuestion(id));-- assertNoPoints();-- // Check that message is displayed- cy.findByRole("dialog", { name: /data points are off screen/i });-- H.openVizSettingsSidebar();-- H.vizSettingsSidebar().findByText("Axes").click();- H.vizSettingsSidebar().findByLabelText("Min").clear().type("70").blur();-- assertDataVisible();-- H.vizSettingsSidebar().findByLabelText("Min").clear().type("700").blur();-- assertNoPoints();-- cy.findByRole("switch", { name: /auto y-axis range/i }).click({- force: true,- });-- assertDataVisible();- });-- it("should be able to open the menu on pinned cards", () => {- H.visitCollection("root");- H.openCollectionItemMenu(QUESTION_NAME);- H.popover().findByText("Pin this").click();-- // assert that the menu trigger is not covered- H.openPinnedItemMenu(QUESTION_NAME);- H.popover().should("exist");- });-- it("should show the message in documents", () => {- //setup a document- cy.visit("/document/new");- H.documentContent().click();-- H.addToDocument("/ord", false);- H.commandSuggestionItem(new RegExp(QUESTION_NAME)).click();-- H.getDocumentCard(QUESTION_NAME).within(() => {- assertNoPoints();- });-- H.openDocumentCardMenu(QUESTION_NAME);- H.popover().findByText("Edit Visualization").click();-- H.getDocumentSidebar().within(() => {- cy.findByRole("tab", { name: /axes/i }).click({ force: true });- cy.findByLabelText("Auto y-axis range").should(- "have.attr",- "data-checked",- "false",- );-- cy.findByLabelText("Min").clear().type("70");- });-- H.getDocumentCard(QUESTION_NAME).within(() => {- assertDataVisible();- });- });-- describe("dashcard", () => {- beforeEach(() => {- cy.get<number>("@questionId").then((cardId) => {- H.createDashboard(- {- name: "Test Dashboard",- },- {- wrapId: true,- },- );-- cy.get<number>("@dashboardId").then((dashboardId) =>- H.addQuestionToDashboard({ dashboardId, cardId }),- );- });- });-- it("should show you a message on a dashboard", () => {- cy.get<number>("@dashboardId").then((id) => H.visitDashboard(id));-- cy.findByTestId("dashcard").within(() => {- assertNoPoints();- });-- H.editDashboard();- H.showDashcardVisualizerModalSettings(0, { isVisualizerCard: false });-- H.modal().within(() => {- cy.findByRole("tab", { name: /axes/i }).click({ force: true });- cy.findByLabelText("Auto y-axis range").should(- "have.attr",- "data-checked",- "false",- );-- assertNoPoints(false);- getNoPointsMessage().should("not.exist");-- cy.findByLabelText("Min").clear().type("70").blur();-- assertDataVisible();- });- H.saveDashcardVisualizerModal();-- H.dashboardSaveButton().click();-- cy.findByTestId("edit-bar").should("not.exist");-- cy.findByTestId("dashcard").within(() => {- getChartPoints().should("have.length.greaterThan", 0);- });- });- });-});--describe("issue 69882", () => {- const DOOHICKEY_BAR_COLOR = "#227FD2";- const GADGET_LINE_COLOR = "#689636";-- const questionDetails: StructuredQuestionDetails = {- name: "69882",- display: "combo" as const,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [- ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],- ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],- ],- },- visualization_settings: {- series_settings: {- Doohickey: {- color: DOOHICKEY_BAR_COLOR,- title: "_Doohickey",- display: "bar",- },- Gadget: {- color: GADGET_LINE_COLOR,- title: "_Gadget",- display: "line",- },- },- "graph.x_axis.scale": "timeseries",- "graph.dimensions": ["CREATED_AT", "CATEGORY"],- "graph.metrics": ["count"],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should apply per-series display type on a question and dashcard (metabase#69882)", () => {- H.createQuestion(questionDetails, { visitQuestion: true, wrapId: true });-- H.echartsContainer().should("be.visible");- H.chartPathWithFillColor(DOOHICKEY_BAR_COLOR).should("exist");- H.cartesianChartCircleWithColor(GADGET_LINE_COLOR);-- H.createDashboard({ name: "Test Dashboard" }, { wrapId: true });- cy.get<number>("@questionId").then((cardId) => {- cy.get<number>("@dashboardId").then((dashboardId) => {- H.addQuestionToDashboard({ dashboardId, cardId });- H.visitDashboard(dashboardId);- });- });-- cy.findByTestId("dashcard").within(() => {- H.echartsContainer().should("be.visible");- H.chartPathWithFillColor(DOOHICKEY_BAR_COLOR).should("exist");- H.cartesianChartCircleWithColor(GADGET_LINE_COLOR);- });- });-});--describe("issue #68819", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not crash when renaming an aggregation changes sibling column deduplication (metabase#68819)", () => {- // Create a question with two Sum of Total aggregations- // These will be deduplicated as "sum" and "sum_2"- const questionDetails: StructuredQuestionDetails = {- display: "bar" as const,- query: {- "source-table": ORDERS_ID,- aggregation: [- ["sum", ["field", ORDERS.TOTAL, null]],- ["sum", ["field", ORDERS.TOTAL, null]],- ],- breakout: [- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],- ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],- ],- },- visualization_settings: {- "stackable.stack_type": "stacked",- "graph.dimensions": ["CREATED_AT", "CATEGORY"],- "graph.metrics": ["sum", "sum_2"],- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });-- H.echartsContainer().should("be.visible");-- H.openNotebook();-- H.getNotebookStep("summarize")- .findByTestId("aggregate-step")- .findAllByTestId("notebook-cell-item")- .first()- .click();-- cy.findByLabelText("Back").click();-- H.popover().findByText("Custom Expression").click();-- H.CustomExpressionEditor.nameInput().clear().type("Sum");- H.popover().button("Update").click();-- H.saveSavedQuestion();-- cy.button("Visualize").click();-- // The bug would cause: TypeError: cannot read properties of undefined (reading 'name')- H.echartsContainer().should("be.visible");- cy.findByTestId("query-builder-main")- .findByText(/error/i)- .should("not.exist");-- cy.reload();- H.echartsContainer().should("be.visible");- });-});diff --git a/e2e/test/scenarios/visualizations/drillthroughs/table_drills.cy.spec.js b/e2e/test/scenarios/visualizations/drillthroughs/table_drills.cy.spec.jsindex 5f2a4d1223a..bb20b27976c 100644--- a/e2e/test/scenarios/visualizations/drillthroughs/table_drills.cy.spec.js+++ b/e2e/test/scenarios/visualizations/drillthroughs/table_drills.cy.spec.js@@ -272,6 +272,84 @@ describe("scenarios > visualizations > drillthroughs > table_drills", () => {resultText: "July 31, 2025",});});++ describe("issue 43075", () => {+ const questionDetails = {+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [["field", PRODUCTS.CATEGORY, null]],+ },+ };++ beforeEach(() => {+ cy.viewport(1000, 300);++ H.createQuestion(questionDetails, { visitQuestion: true });+ });++ it("the breakout popover should fit within the window (metabase#43075)", () => {+ cy.findAllByTestId("cell-data").contains("54").click();+ H.popover().findByText("Break out by…").click();+ H.popover().findByText("Category").click();+ H.popover().findByText("Vendor").should("exist");++ cy.document().should((doc) => {+ expect(doc.documentElement.scrollHeight).to.be.lte(+ doc.documentElement.offsetHeight,+ );+ });+ });+ });+ });++ describe("issue 12368", () => {+ const questionDetails = {+ type: "question",+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", PRODUCTS.VENDOR, { "base-type": "type/Text" }],+ ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],+ ],+ },+ visualization_settings: {+ "table.pivot": true,+ "table.pivot_column": "CATEGORY",+ "table.cell_column": "count",+ column_settings: {+ [`["ref",["field",${PRODUCTS.VENDOR},null]]`]: {+ column_title: "Vendor2",+ },+ },+ },+ };++ beforeEach(() => {+ cy.signInAsNormalUser();+ });++ it("should clear pivot settings when doing underlying records drill from a pivot table (metabase#12368)", () => {+ cy.log("drill thru from a pivot table");+ H.createQuestion(questionDetails, { visitQuestion: true });+ cy.findAllByTestId("cell-data").contains("1").first().click();+ H.popover().findByText("See this Product").click();++ cy.log(+ "pivot flag should be cleared but other viz settings are preserved",+ );+ H.tableInteractive().within(() => {+ cy.findByText("Ean").should("be.visible");+ cy.findByText("Vendor2").should("be.visible");+ });+ H.openVizSettingsSidebar();+ cy.findByTestId("chartsettings-sidebar").within(() => {+ cy.button("Add or remove columns").should("be.visible");+ cy.findByText("Pivot column").should("not.exist");+ cy.findByText("Cell column").should("not.exist");+ });+ });});describe("native query", () => {diff --git a/e2e/test/scenarios/visualizations/tabular/object_detail.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/object_detail.cy.spec.jsindex 7e444102a6b..26e3c06237e 100644--- a/e2e/test/scenarios/visualizations/tabular/object_detail.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/object_detail.cy.spec.js@@ -1,4 +1,6 @@const { H } = cy;+import { chunk } from "underscore";+import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";@@ -607,6 +609,141 @@ describe("scenarios > question > object details", { tags: "@slow" }, () => {});});+ describe("issue 30039", () => {+ beforeEach(() => {+ cy.signInAsNormalUser();+ });++ it("should not trigger object detail navigation after the modal was closed (metabase#30039)", () => {+ H.startNewNativeQuestion();+ H.NativeEditor.type("select * from ORDERS LIMIT 2");+ H.runNativeQuery();+ cy.findAllByTestId("detail-shortcut").first().click({ force: true });+ cy.findByTestId("object-detail").should("be.visible");++ cy.realPress("{esc}");+ cy.findByTestId("object-detail").should("not.exist");++ H.NativeEditor.type("{downArrow};");+ H.runNativeQuery();+ cy.findByTestId("object-detail").should("not.exist");+ });+ });++ describe("issue 32718", () => {+ const questionDetails = {+ display: "table",+ query: {+ "source-table": PRODUCTS_ID,+ fields: [+ ["field", PRODUCTS.ID, { "base-type": "type/BigInteger" }],+ ["field", PRODUCTS.EAN, { "base-type": "type/Text" }],+ ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],+ ["field", PRODUCTS.CREATED_AT, { "base-type": "type/DateTime" }],+ ],+ limit: 1,+ },+ visualization_settings: {+ "table.columns": [+ { name: "ID", enabled: true },+ { name: "EAN", enabled: false },+ { name: "CATEGORY", enabled: true },+ { name: "CREATED_AT", enabled: true },+ ],+ },+ };++ beforeEach(() => {+ cy.request("PUT", `/api/field/${PRODUCTS.CATEGORY}`, {+ visibility_type: "details-only",+ });+ });++ it("should honor visibility_type of the field when the question has viz settings (metabase#32718)", () => {+ H.createQuestion(questionDetails, { visitQuestion: true });+ H.tableInteractive().within(() => {+ cy.findByText("ID").should("be.visible");+ cy.findByText("Ean").should("not.exist");+ cy.findByText("Category").should("not.exist");+ cy.findByText("Created At").should("be.visible");+ });+ H.openVizTypeSidebar();+ cy.findByTestId("Detail-button").click();+ cy.findByTestId("object-detail").within(() => {+ cy.findByText("ID").should("be.visible");+ cy.findByText("Ean").should("not.exist");+ cy.findByText("Category").should("be.visible");+ cy.findByText("Created At").should("be.visible");+ });+ });+ });++ describe("issue 41133", () => {+ const questionDetails = {+ query: {+ "source-table": PRODUCTS_ID,+ },+ };++ beforeEach(() => {+ cy.viewport(600, 400);+ H.createQuestion(questionDetails, { visitQuestion: true });+ });++ it("object detail view should be scrollable on narrow screens (metabase#41133)", () => {+ H.openObjectDetail(0);++ // scrollTo fails when the container does not have a scrollable overflow+ H.modal()+ .findByText("is connected to:")+ .parents()+ .filter((_, el) =>+ ["auto", "scroll"].includes(getComputedStyle(el).overflowY),+ )+ .first()+ .scrollTo("bottom");+ H.modal().findByText("is connected to:").should("be.visible");+ });+ });++ it("should display correct data when toggling columns (metabase#63745)", () => {+ H.visitQuestionAdhoc({+ name: "63745",+ display: "object",+ dataset_query: {+ type: "query",+ database: SAMPLE_DB_ID,+ query: {+ "source-table": ORDERS_ID,+ limit: 5,+ },+ },+ });++ H.openVizSettingsSidebar();+ cy.findByTestId("chartsettings-sidebar")+ .button("Add or remove columns")+ .click();++ cy.findAllByTestId("object-details-table-cell").should(($cells) => {+ const cellsFlat = $cells.toArray().map((el) => el.textContent);+ const map = new Map(chunk(cellsFlat, 2));+ expect(map.get("User ID")).to.eq("1");+ expect(map.get("Product ID")).to.eq("14");+ });++ cy.findByTestId("orders-table-columns").findByLabelText("ID").click();++ // A stale mapping shifts each value one label down: "Product ID" then shows the User ID value.+ cy.findAllByTestId("object-details-table-cell").should(($cells) => {+ const cellsFlat = $cells.toArray().map((el) => el.textContent);+ const map = new Map(chunk(cellsFlat, 2));+ expect(map.has("ID")).to.be.false;+ expect(map.get("User ID")).to.eq("1");+ expect(map.get("Product ID")).to.eq("14");+ });+ });+describe("detail page links - questions", () => {it("no primary keys (WRK-900)", () => {H.visitQuestionAdhoc({diff --git a/e2e/test/scenarios/visualizations/tabular/pivot_tables.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/pivot_tables.cy.spec.jsindex 340f5d49a23..3ed2979e462 100644--- a/e2e/test/scenarios/visualizations/tabular/pivot_tables.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/pivot_tables.cy.spec.js@@ -240,6 +240,98 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {cy.findByText("294").should("not.exist"); // the other one is still hidden});+ describe("issue 50346", () => {+ const questionDetails = {+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["count"],+ ["sum", ["field", ORDERS.TOTAL, { "base-type": "type/Float" }]],+ ],+ breakout: [+ [+ "field",+ PRODUCTS.CATEGORY,+ { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },+ ],+ [+ "field",+ PRODUCTS.VENDOR,+ { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },+ ],+ [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ],+ ],+ },+ display: "pivot",+ visualization_settings: {+ "pivot_table.column_split": {+ // mix field refs with and without `base-type` to make sure we support both cases+ rows: [+ ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],+ [+ "field",+ PRODUCTS.VENDOR,+ { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },+ ],+ [+ "field",+ PEOPLE.SOURCE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ],+ ],+ columns: [],+ values: [+ ["aggregation", 0],+ ["aggregation", 1],+ ],+ },+ "pivot_table.column_widths": {+ leftHeaderWidths: [150, 214, 120],+ totalLeftHeaderWidths: 484,+ valueHeaderWidths: {},+ },+ },+ };++ const groupValue = "Annetta Wyman and Sons";+ const totalValue = "1,217.76";++ beforeEach(() => {+ cy.signInAsNormalUser();+ cy.intercept("PUT", "/api/card/*").as("updateCard");+ });++ it("should be able to collapse rows for questions with legacy pivot settings (metabase#50346)", () => {+ H.createQuestion(questionDetails, { visitQuestion: true, wrapId: true });++ cy.log("collapse one of the sections");+ cy.findByTestId("pivot-table").within(() => {+ cy.findByText(totalValue).should("be.visible");+ cy.findByTestId(`${groupValue}-toggle-button`).click();+ cy.findByText(totalValue).should("not.exist");+ });++ cy.log("save and make sure the setting is preserved on reload");+ H.queryBuilderHeader().button("Save").click();+ H.modal().button("Save").click();+ cy.wait("@updateCard");+ H.visitQuestion("@questionId");+ cy.findByTestId("pivot-table").within(() => {+ cy.findByText(totalValue).should("not.exist");+ });++ cy.log("expand the section");+ cy.findByTestId("pivot-table").within(() => {+ cy.findByTestId(`${groupValue}-toggle-button`).click();+ cy.findByText(totalValue).should("be.visible");+ });+ });+ });+it("should show standalone values when collapsed to the sub-level grouping (metabase#25250)", () => {const questionDetails = {name: "25250",@@ -330,6 +422,113 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {cy.findByText("3,520").should("not.exist"); // the subtotal has disappeared!});+ it("pivot table should show subtotals for a group of a single value (metabase#52333)", () => {+ const baseQuery = `+SELECT *+FROM (+ SELECT+ category,+ source,+ state,+ SUM(orders.discount) AS discount,+ SUM(orders.total) AS total,+ SUM(orders.quantity) AS quantity+ FROM+ orders+ LEFT JOIN products ON orders.product_id = products.id+ LEFT JOIN people ON orders.user_id = people.id+ GROUP BY category, source, state+) AS filtered_orders+WHERE NOT (+ category = 'Gizmo'+ AND (+ source IN ('Facebook', 'Google', 'Organic', 'Twitter')+ OR state NOT IN ('AK')+ )+);`;++ const baseQuestionDetails = {+ name: "52333",+ display: "table",+ native: {+ query: baseQuery,+ },+ };++ H.createNativeQuestion(baseQuestionDetails, {+ visitQuestion: true,+ wrapId: true,+ });++ cy.get("@questionId").then((id) => {+ const questionDetails = {+ query: {+ "source-table": `card__${id}`,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ "CATEGORY",+ {+ "base-type": "type/Text",+ },+ ],+ [+ "field",+ "SOURCE",+ {+ "base-type": "type/Text",+ },+ ],+ [+ "field",+ "STATE",+ {+ "base-type": "type/Text",+ },+ ],+ ],+ },+ display: "pivot",+ visualization_settings: {+ "pivot_table.column_split": {+ rows: ["CATEGORY", "SOURCE", "STATE"],+ columns: [],+ values: ["count", "avg"],+ },+ "pivot_table.column_widths": {+ leftHeaderWidths: [104, 92, 80],+ totalLeftHeaderWidths: 276,+ valueHeaderWidths: {},+ },+ "pivot_table.collapsed_rows": {+ value: ['["Doohickey"]', '["Gadget"]', '["Widget"]'],+ rows: ["CATEGORY", "SOURCE", "STATE"],+ },+ },+ };++ H.createQuestion(questionDetails, { visitQuestion: true });+ });++ H.queryBuilderMain().within(() => {+ cy.findByText("Affiliate");+ cy.findByText("AK");++ // Ensure it does not show subtotals for the single value by default+ cy.findByText("Totals for Affiliate").should("not.exist");++ H.openVizSettingsSidebar();+ });++ H.sidebar().findByText("Condense duplicate totals").click();++ // Ensure it shows subtotals for the single value+ H.queryBuilderMain()+ .findByText("Totals for Affiliate")+ .should("be.visible");+ });+it("should uncollapse a value when hiding the subtotals", () => {const rows = ["SOURCE", "CATEGORY"];H.visitQuestionAdhoc({@@ -416,6 +615,38 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {});});+ describe("issue 15353", () => {+ const questionDetails = {+ name: "15353",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],+ },+ display: "pivot",+ };++ beforeEach(() => {+ cy.intercept("POST", "/api/dataset/pivot").as("pivotDataset");++ H.createQuestion(questionDetails, { visitQuestion: true });+ });++ it("should be able to change field name used for values (metabase#15353)", () => {+ H.openVizSettingsSidebar();+ openColumnSettings("Count");++ cy.findByDisplayValue("Count").type(" renamed").blur();++ cy.wait("@pivotDataset");++ cy.findByTestId("query-visualization-root").should(+ "contain",+ "Count renamed",+ );+ });+ });+it("should not allow sorting of value fields", () => {H.visitQuestionAdhoc({ dataset_query: testQuery, display: "pivot" });@@ -608,6 +839,104 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {cy.findByTestId("dashcard").should("not.exist");});++ it("should allow mapping pivot table dashcard fields to click behavior targets (metabase#52339)", () => {+ const questionDetails = {+ name: "Orders, Distinct values of ID, Grouped by Product → Title and Created At (month) and User → ID",++ query: {+ "source-table": ORDERS_ID,+ aggregation: [["distinct", ["field", ORDERS.ID, null]]],+ breakout: [+ ["field", PRODUCTS.TITLE, { "source-field": ORDERS.PRODUCT_ID }],+ ["field", PEOPLE.SOURCE, { "source-field": ORDERS.USER_ID }],+ ],+ },+ display: "pivot",+ visualization_settings: {+ "pivot_table.column_split": {+ rows: ["TITLE", "SOURCE"],+ columns: [],+ values: ["distinct"],+ },+ },+ };++ const sourceParam = {+ name: "Source",+ slug: "filter-text",+ id: "1b9cd9f1",+ type: "string/=",+ sectionId: "string",+ };++ H.createQuestionAndDashboard({+ dashboardDetails: {+ parameters: [sourceParam],+ },+ questionDetails,+ cardDetails: {+ size_x: 16,+ size_y: 8,+ },+ }).then(({ body: { id, card_id, dashboard_id }, questionId }) => {+ cy.wrap(questionId).as("questionId");++ cy.request("PUT", `/api/dashboard/${dashboard_id}`, {+ dashcards: [+ {+ id,+ card_id,+ row: 0,+ col: 0,+ size_x: 16,+ size_y: 8,+ series: [],+ visualization_settings: {},+ parameter_mappings: [+ {+ parameter_id: sourceParam.id,+ card_id,+ target: [+ "dimension",+ [+ "field",+ PEOPLE.SOURCE,+ {+ "source-field": ORDERS.USER_ID,+ },+ ],+ ],+ },+ ],+ },+ ],+ });++ H.visitDashboard(dashboard_id);+ });++ H.editDashboard();+ H.getDashboardCard(0)+ .realHover({ scrollBehavior: "bottom" })+ .findByLabelText("Click behavior")+ .click();++ H.sidebar().within(() => {+ cy.findByText("Go to a custom destination").click();+ cy.findByText("Dashboard").click();+ });++ H.modal().findByText("Test Dashboard").click();++ cy.findByTestId("click-mappings").findByText("Source").click();++ H.popover().within(() => {+ cy.findByText("Product → Title");+ cy.findByText("User → Source");+ cy.findByText("Distinct values of ID");+ });+ });});describe("sharing (metabase#14447)", () => {@@ -1103,6 +1432,137 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {});});});++ describe("issue 37726", () => {+ const PIVOT_QUESTION = {+ name: "Pivot table with custom column width",+ display: "pivot",+ query: {+ "source-table": ORDERS_ID,+ breakout: [+ [+ "field",+ ORDERS.TOTAL,+ { "base-type": "type/Float", binnig: { strategy: "default" } },+ ],+ ],+ aggregation: [+ [+ "distinct",+ ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],+ ],+ ],+ },+ visualization_settings: {+ "pivot_table.column_split": {+ rows: ["TOTAL"],+ columns: [],+ values: ["distinct"],+ },+ "pivot_table.column_widths": {+ leftHeaderWidths: [80],+ totalLeftHeaderWidths: 80,+ valueHeaderWidths: { 0: 193 },+ },+ },+ };++ beforeEach(() => {+ cy.signInAsNormalUser();+ });++ it("should not result in an error when you add a column after resizing an existing one (#37726)", () => {+ cy.intercept("POST", "/api/dataset/pivot").as("pivot");++ // The important data point in this question is that it has custom+ // leftHeaderWidths as if a user had dragged them to change the defaults.+ H.createQuestion(PIVOT_QUESTION, { visitQuestion: true });++ // Now, add in another column to the pivot table+ cy.button(/Summarize/).click();++ cy.findByRole("listitem", { name: "Category" })+ .realHover()+ .button("Add dimension")+ .click();++ // Wait for the pivot call to return+ cy.wait("@pivot");++ // Refresh the page -- this loads the question using the transient value+ cy.reload();++ // Look for the new column name in the resulting pivot table.+ // Note that before this fix, the page would error out and this elements,+ // along with the rest of the pivot table, would not appear.+ // Instead, you got a nice ⚠️ icon and a "Something's gone wrong" tooltip.+ H.main().within(() => {+ cy.findByText("Product → Category", { timeout: 8000 });+ });+ });+ });++ describe("issue 42697", () => {+ const PIVOT_QUESTION = {+ display: "pivot",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ ["count"],+ ["sum", ["field", ORDERS.TOTAL, { "base-type": "type/Float" }]],+ ],+ breakout: [+ [+ "field",+ PEOPLE.STATE,+ { "base-type": "type/Text", "source-field": ORDERS.USER_ID },+ ],+ [+ "field",+ ORDERS.CREATED_AT,+ { "base-type": "type/DateTime", "temporal-unit": "year" },+ ],+ ],+ },+ visualization_settings: {+ "pivot_table.column_split": {+ rows: ["CREATED_AT"],+ columns: ["STATE"],+ values: ["count", "sum"],+ },+ "pivot_table.column_widths": {+ leftHeaderWidths: [156],+ totalLeftHeaderWidths: 156,+ valueHeaderWidths: {},+ },+ },+ };++ beforeEach(() => {+ cy.signInAsNormalUser();+ cy.intercept("PUT", "/api/card/*").as("updateCard");+ });++ it("should display a pivot table when a new breakout is added to the query (metabase#42697)", () => {+ H.createQuestion(PIVOT_QUESTION, { visitQuestion: true });+ H.openNotebook();+ H.getNotebookStep("summarize")+ .findByTestId("breakout-step")+ .icon("add")+ .click();+ H.popover().within(() => {+ cy.findByText("Product").click();+ cy.findByText("Category").click();+ });+ H.queryBuilderHeader().findByText("Save").click();+ H.modal().button("Save").click();+ cy.wait("@updateCard");+ cy.button("Visualize").click();+ cy.findByTestId("pivot-table")+ .findByText("Product → Category")+ .should("be.visible");+ });+ });});it("should not have to wait for data to show fields in summarisation (metabase#26467)", () => {diff --git a/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.jsindex 07ba9fd9b8b..10d3e5b1381 100644--- a/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.js@@ -2,7 +2,7 @@ const { H } = cy;import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;+const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;describe("scenarios > visualizations > scalar", () => {beforeEach(() => {@@ -73,4 +73,54 @@ describe("scenarios > visualizations > scalar", () => {// eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usagecy.findByText("Time style").should("be.hidden");});++ describe("issue 33208", () => {+ beforeEach(() => {+ H.createNativeQuestion(+ {+ native: {+ query:+ "select distinct category from products where {{category}} order by category",+ "template-tags": {+ category: {+ type: "dimension",+ name: "category",+ id: "82e3e985-5bd8-4503-a628-15201bad321b",+ "display-name": "Category",+ required: true,+ default: ["Doohickey", "Gizmo"],+ dimension: ["field", PRODUCTS.CATEGORY, null],+ "widget-type": "string/=",+ },+ },+ },+ display: "scalar",+ },+ { visitQuestion: true },+ );+ });++ it("should not auto-select chart type when opening a saved native question with parameters that have default values (metabase#33208)", () => {+ // The default value for the category parameter is ["Doohickey","Gizmo"], which means the query results should have two rows, meaning+ // scalar is not a sensible chart type. Normally the chart type would be automatically changed to table, but this shouldn't happen.+ cy.findByTestId("scalar-value").should("be.visible");+ });++ it("should not auto-select chart type when saving a native question with parameters that have default values", () => {+ cy.intercept("POST", "/api/card/*/query").as("cardQuery");++ cy.findByTestId("query-builder-main").findByText("Open Editor").click();+ H.NativeEditor.focus().type(" ");+ H.saveSavedQuestion();+ H.runNativeQuery({ wait: false });+ cy.wait("@cardQuery");++ // The run button shows the refresh icon when the query completes+ cy.findByTestId("native-query-editor-container")+ .icon("refresh")+ .should("be.visible");+ cy.findByTestId("scalar-value").should("be.visible");+ H.tableInteractive().should("not.exist");+ });+ });});diff --git a/e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.jsindex fd942a33e4e..8d8f8a6deee 100644--- a/e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.js@@ -214,6 +214,37 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.button("Add comparison").should("be.enabled");});+ it("should allow selecting more than 1 comparison (metabase#50686)", () => {+ const questionDetails = {+ name: "50686",+ display: "smartscalar",+ native: {+ query:+ "select 100 as total, 110 as forecast, 80 as last_year, now() as now",+ },+ };++ H.createNativeQuestion(questionDetails, { visitQuestion: true });+ // Default comparison (a single one renders inline)+ H.queryBuilderMain().findByText("(No data)");++ // Add another comparison+ H.openVizSettingsSidebar();+ cy.button("Add comparison").click();+ H.popover().findByText("Value from another column…").click();+ H.popover().findByText("FORECAST").click();+ H.popover().button("Done").click();++ H.queryBuilderMain().within(() => {+ // First comparison still exists+ cy.findByText("N/A (No data)");++ // New comparison has been added+ cy.findByText("-9.09% (110)");+ cy.contains("vs. FORECAST");+ });+ });+it("should reset 'another column' comparison when it becomes invalid", () => {cy.intercept("POST", "/api/dataset").as("dataset");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 174c9c0cdb4..ec88bc90285 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@@ -1,6 +1,7 @@import _ from "underscore";const { H } = cy;+import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;@@ -558,6 +559,40 @@ describe("scenarios > visualizations > table column settings", () => {H.assertRowHeight(0, 36);});++ describe("issue 22206", () => {+ beforeEach(() => {+ H.openOrdersTable();++ cy.findByTestId("loading-indicator").should("not.exist");+ });++ it("should not duplicate column in settings when removing and adding it back (metabase#22206)", () => {+ H.openVizSettingsSidebar();++ // remove column+ cy.findByTestId("sidebar-content")+ .findByTestId("draggable-item-Subtotal")+ .icon("eye_outline")+ .click({ force: true });++ // rerun query+ cy.findAllByTestId("run-button").first().click();+ cy.wait("@dataset");+ cy.findByTestId("loading-indicator").should("not.exist");++ // add column back again+ cy.findByTestId("sidebar-content")+ .findByTestId("draggable-item-Subtotal")+ .icon("eye_crossed_out")+ .click({ force: true });++ // fails because there are 2 columns, when there should be one+ cy.findByTestId("sidebar-content").findByText("Subtotal");++ // if you add it back again it crashes the question+ });+ });});describe("multi-stage questions", () => {@@ -884,6 +919,285 @@ describe("scenarios > visualizations > table column settings", () => {_removeColumn(taxColumn);_addColumn(taxColumn);});++ const oldSourceQuestionDetails = {+ native: {+ query: "SELECT 1 AS C1, 2 AS C2, 3 AS C3",+ },+ };++ const newSourceQuestionDetails = {+ native: {+ query: "SELECT 1 AS C1, 3 AS C3",+ },+ };++ const getNestedQuestionDetails = (sourceQuestionId) => ({+ query: {+ "source-table": `card__${sourceQuestionId}`,+ },+ display: "table",+ visualization_settings: {+ "table.columns": [+ { name: "C3", enabled: true },+ { name: "C1", enabled: true },+ { name: "C2", enabled: true },+ ],+ },+ });++ it("should not reset the column order after one of the columns is removed from data source (metabase#7884)", () => {+ H.createNativeQuestion(oldSourceQuestionDetails).then(+ ({ body: sourceQuestion }) =>+ H.createQuestion(getNestedQuestionDetails(sourceQuestion.id)).then(+ ({ body: nestedQuestion }) => {+ cy.request("PUT", `/api/card/${sourceQuestion.id}`, {+ ...sourceQuestion,+ dataset_query: {+ type: "native",+ database: SAMPLE_DB_ID,+ native: newSourceQuestionDetails.native,+ },+ });+ H.visitQuestion(nestedQuestion.id);+ },+ ),+ );++ cy.log("verify column order in the table");+ cy.findAllByTestId("header-cell").eq(0).should("contain.text", "C3");+ cy.findAllByTestId("header-cell").eq(1).should("contain.text", "C1");++ cy.log("verify column order in viz settings");+ H.openVizSettingsSidebar();+ H.getDraggableElements().eq(0).should("contain.text", "C3");+ H.getDraggableElements().eq(1).should("contain.text", "C1");+ });+ });++ describe("issue 28304", () => {+ const questionDetails = {+ name: "28304",+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],+ ],+ },+ database: SAMPLE_DB_ID,+ },+ display: "table",+ visualization_settings: {+ "table.columns": [+ {+ fieldRef: ["field", ORDERS.ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.USER_ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.PRODUCT_ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.SUBTOTAL, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.TAX, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.DISCOUNT, null],+ enabled: true,+ },+ ],+ column_settings: {+ '["name","count"]': { show_mini_bar: true },+ },+ },+ };++ beforeEach(() => {+ cy.signInAsAdmin();++ H.visitQuestionAdhoc(questionDetails);+ });++ it("table should should generate default columns when table.columns entries do not match data.cols (metabase#28304)", () => {+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("Count by Created At: Month").should("be.visible");++ H.openVizSettingsSidebar();+ H.leftSidebar().should("not.contain", "[Unknown]");+ H.leftSidebar().should("contain", "Created At");+ H.leftSidebar().should("contain", "Count");+ cy.findAllByTestId("mini-bar-container").should(+ "have.length.greaterThan",+ 0,+ );+ H.getDraggableElements().should("have.length", 2);+ });+ });++ describe("issue 28311", () => {+ const questionDetails = {+ name: "28311",+ dataset_query: {+ type: "query",+ query: {+ "source-table": ORDERS_ID,+ },+ database: SAMPLE_DB_ID,+ },+ display: "table",+ visualization_settings: {+ "table.columns": [+ {+ fieldRef: ["field", ORDERS.ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.USER_ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.PRODUCT_ID, null],+ enabled: true,+ },+ {+ fieldRef: ["field", ORDERS.SUBTOTAL, null],+ enabled: false,+ },+ {+ fieldRef: ["field", ORDERS.TAX, null],+ enabled: false,+ },+ {+ fieldRef: ["field", ORDERS.DISCOUNT, null],+ enabled: false,+ },+ ],+ },+ };++ beforeEach(() => {+ cy.signInAsAdmin();++ H.visitQuestionAdhoc(questionDetails);+ });++ it("should move a column to a new position on the first drag (metabase#28311)", () => {+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("Product ID").should("be.visible");++ H.openVizSettingsSidebar();+ H.getDraggableElements().contains("Product ID").as("dragElement");+ H.moveDnDKitElementByAlias("@dragElement", {+ vertical: -100,+ useMouseEvents: true,+ });+ H.getDraggableElements().eq(0).should("contain", "Product ID");+ });+ });++ describe("issue 42049", () => {+ beforeEach(() => {+ cy.signInAsAdmin();+ });++ it("should not mess up columns order (metabase#42049)", () => {+ cy.intercept("POST", "/api/card/*/query", (req) => {+ req.on("response", (res) => {+ const createdAt = res.body.data.cols[1];++ createdAt.field_ref[1] = "created_at"; // simulate named field ref++ 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) => {+ req.on("response", (res) => {+ const createdAt = res.body.data.cols[1];++ createdAt.field_ref[1] = "created_at"; // simulate named field ref++ res.send();+ });+ }).as("dataset");++ H.createQuestion(+ {+ query: {+ "source-table": ORDERS_ID,+ fields: [+ ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],+ ["field", ORDERS.CREATED_AT, { "base-type": "type/DateTime" }],+ ["field", ORDERS.QUANTITY, { "base-type": "type/Integer" }],+ ],+ },+ visualization_settings: {+ "table.columns": [+ {+ name: "ID",+ fieldRef: ["field", ORDERS.ID, null],+ enabled: true,+ },+ {+ name: "CREATED_AT",+ fieldRef: [+ "field",+ ORDERS.CREATED_AT,+ {+ "temporal-unit": "default",+ },+ ],+ enabled: true,+ },+ {+ name: "QUANTITY",+ fieldRef: ["field", ORDERS.QUANTITY, null],+ enabled: true,+ },+ ],+ },+ },+ { visitQuestion: true },+ );++ cy.log("verify initial columns order");++ cy.findAllByTestId("header-cell").as("headerCells");+ cy.get("@headerCells").eq(0).should("have.text", "ID");+ cy.get("@headerCells").eq(1).should("have.text", "Created At");+ cy.get("@headerCells").eq(2).should("have.text", "Quantity");++ cy.findByTestId("question-filter-header").click();++ H.popover().within(() => {+ cy.findByText("Created At").click();+ cy.button("Previous month").click();+ });++ cy.wait("@dataset");+ H.queryBuilderFiltersPanel()+ .findByTestId("filter-pill")+ .should("contain", "Created At");++ cy.log("verify columns order after applying the filter");++ cy.findAllByTestId("header-cell").as("headerCells");+ cy.get("@headerCells").eq(0).should("have.text", "ID");+ cy.get("@headerCells").eq(1).should("have.text", "Created At");+ cy.get("@headerCells").eq(2).should("have.text", "Quantity");+ });});it("should handle duplicated values in table.columns viz settings (metabase#62053)", () => {diff --git a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.jsindex 06c5e0a878d..546a5c69bc0 100644--- a/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js+++ b/e2e/test/scenarios/visualizations/tabular/table.cy.spec.js@@ -6,6 +6,8 @@ import {ORDERS_DASHBOARD_ID,} from "e2e/support/cypress_sample_instance_data";+const { PEOPLE, PEOPLE_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;+describe("scenarios > visualizations > table", () => {beforeEach(() => {H.restore();@@ -461,6 +463,20 @@ describe("scenarios > visualizations > table", () => {H.clickActionsPopover({ skipVisibilityCheck: true }).should("not.exist");});+ it("should be able to close a header popover using Escape (metabase#55673)", () => {+ H.openOrdersTable();+ H.tableHeaderClick("Product ID");+ cy.findByTestId("click-actions-view").should("be.visible");++ cy.focused().should(+ "have.attr",+ "data-testid",+ "click-actions-sort-control-sort.ascending",+ );+ cy.realPress(["Escape"]);+ cy.findByTestId("click-actions-view").should("not.exist");+ });+it("popover should not be scrollable horizontally (metabase#31339)", () => {H.openPeopleTable();H.tableHeaderClick("Password");@@ -526,6 +542,195 @@ describe("scenarios > visualizations > table", () => {H.popover().findByText("Symbol ($)").click();H.popover().findByText("Local symbol ($)").should("not.exist");});++ it("should not crash when the table viz gets automatically pivoted (metabase#45481)", () => {+ H.openOrdersTable({ mode: "notebook" });+ H.summarize({ mode: "notebook" });+ H.popover().findByText("Count of rows").click();+ H.getNotebookStep("summarize")+ .findByText("Pick a column to group by")+ .click();+ H.popover().findByText("User ID").click();+ H.getNotebookStep("summarize")+ .findByTestId("breakout-step")+ .icon("add")+ .click();+ H.popover().within(() => {+ cy.findByText("Product").click();+ cy.findByText("Category").click();+ });+ H.visualize();+ H.tableInteractive().should("be.visible");+ });++ describe("issue 56094", () => {+ beforeEach(() => {+ cy.signInAsAdmin();+ });++ it("should allow to switch between automatic pivot table and usual table visualization (metabase#56094)", () => {+ H.visitQuestionAdhoc({+ name: "56094",+ dataset_query: {+ type: "query",+ database: SAMPLE_DB_ID,+ query: {+ "source-table": PRODUCTS_ID,+ aggregation: [["count"]],+ breakout: [+ [+ "field",+ PRODUCTS.CATEGORY,+ {+ "base-type": "type/Text",+ },+ ],+ [+ "field",+ PRODUCTS.RATING,+ {+ binning: {+ strategy: "default",+ },+ },+ ],+ ],++ limit: 20,+ },+ },+ });++ H.tableInteractiveHeader().should("contain", "Doohickey");++ H.queryBuilderFooter().findByLabelText("Switch to data").click();++ H.queryBuilderFooterDisplayToggle().should("exist");+ H.tableInteractiveHeader()+ .should("contain", "Count")+ .and("not.contain", "Doohickey");++ H.queryBuilderFooter().findByLabelText("Switch to visualization").click();++ H.queryBuilderFooterDisplayToggle().should("exist");+ H.tableInteractiveHeader()+ .should("contain", "Doohickey")+ .and("not.contain", "Count");+ });+ });++ describe("issue 18976, 18817", () => {+ const questionDetails = {+ display: "table",+ dataset_query: {+ database: SAMPLE_DB_ID,+ type: "native",+ native: {+ query: "select 'a', 'b'",+ "template-tags": {},+ },+ },+ visualization_settings: {+ "table.pivot": true,+ "table.pivot_column": "'a'",+ "table.cell_column": "1",+ },+ };++ beforeEach(() => {+ cy.signInAsAdmin();+ });++ it("should display a pivot table as regular one when pivot columns are missing (metabase#18976)", () => {+ H.visitQuestionAdhoc(questionDetails);++ H.tableInteractiveHeader().should("contain", "'a'").and("contain", "'b'");+ H.tableInteractive().findByText("a").should("be.visible");+ });++ it("should not keep orphan columns rendered after switching from pivot to regular table (metabase#18817)", () => {+ H.createQuestion(+ {+ query: {+ "source-table": PEOPLE_ID,+ aggregation: [["count"]],+ breakout: [+ ["field", PEOPLE.NAME],+ ["field", PEOPLE.SOURCE],+ ],+ limit: 5,+ },+ database: SAMPLE_DB_ID,+ display: "table",+ },+ { visitQuestion: true },+ );++ cy.findByTestId("qb-header")+ .button(/Summarize/)+ .click();+ H.rightSidebar()+ .findByLabelText("Source")+ .findByRole("button", { name: "Remove dimension" })+ .click();++ cy.findAllByTestId("header-cell")+ .should("have.length", 2)+ .and("contain", "Name")+ .and("contain", "Count");+ });+ });++ describe("issue 56771", () => {+ beforeEach(() => {+ cy.signInAsAdmin();+ });++ it("should apply correct column widths after changing query (metabase#56771)", () => {+ H.openOrdersTable();+ cy.log(+ "Resize a column first to make width stored in the visualization settings",+ );+ H.resizeTableColumn("ID", 100);++ H.openNotebook();+ H.join();+ H.joinTable("Products");+ H.visualize();++ cy.findAllByTestId("header-cell")+ .filter(":contains(Products → Category)")+ .should(($cell) => {+ const width = $cell[0].getBoundingClientRect().width;+ expect(width).to.be.greaterThan(160);+ });+ });+ });++ describe("issue 57685", () => {+ beforeEach(() => {+ H.createNativeQuestion(+ {+ display: "table",+ native: {+ query: 'SELECT id as "" FROM PRODUCTS',+ },+ },+ { visitQuestion: true },+ );+ });++ it("should handle empty column names without error (metabase#57685)", () => {+ H.tableInteractive().should("be.visible");+ cy.findByTestId("visualization-root").icon("warning").should("not.exist");++ cy.findByTestId("qb-header-action-panel")+ .findByText("Explore results")+ .click();++ H.tableInteractive().should("be.visible");+ });+ });});describe("scenarios > visualizations > table > dashboards context", () => {diff --git a/e2e/test/scenarios/visualizations/tabular/visualizations-tabular-reproductions.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/visualizations-tabular-reproductions.cy.spec.jsdeleted file mode 100644index 88c2856f465..00000000000--- a/e2e/test/scenarios/visualizations/tabular/visualizations-tabular-reproductions.cy.spec.js+++ /dev/null@@ -1,1335 +0,0 @@-const { H } = cy;-import { chunk } from "underscore";--import { SAMPLE_DB_ID } from "e2e/support/cypress_data";-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID, PRODUCTS, PRODUCTS_ID } =- SAMPLE_DATABASE;--describe("issue 11249", () => {- const questionDetails = {- name: "13960",- display: "line",- dataset_query: {- type: "query",- database: 1,- query: {- "source-table": ORDERS_ID,- aggregation: [["count"], ["avg", ["field", ORDERS.TOTAL, null]]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],- },- },- visualization_settings: {- "graph.dimensions": ["CREATED_AT"],- "graph.metrics": ["avg"],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not allow adding more series when all columns are used (metabase#11249)", () => {- H.visitQuestionAdhoc(questionDetails);-- H.openVizSettingsSidebar();-- cy.findByTestId("sidebar-left").within(() => {- cy.findByText("Data").click();- cy.findByDisplayValue("Count").should("not.exist");-- cy.findByText("Add another series").click();- cy.findByDisplayValue("Count").should("be.visible");- cy.findByText("Add another series").should("not.exist");- });- });-});--describe("issue 11435", () => {- const questionDetails = {- name: "11435",- display: "line",- native: {- query: `- SELECT "PUBLIC"."ORDERS"."ID" AS "ID", "PUBLIC"."ORDERS"."USER_ID" AS "USER_ID", "PUBLIC"."ORDERS"."PRODUCT_ID" AS "PRODUCT_ID", "PUBLIC"."ORDERS"."SUBTOTAL" AS "SUBTOTAL", "PUBLIC"."ORDERS"."TAX" AS "TAX", "PUBLIC"."ORDERS"."TOTAL" AS "TOTAL", "PUBLIC"."ORDERS"."DISCOUNT" AS "DISCOUNT", "PUBLIC"."ORDERS"."CREATED_AT" AS "CREATED_AT", "PUBLIC"."ORDERS"."QUANTITY" AS "QUANTITY"- FROM "PUBLIC"."ORDERS"- WHERE ("PUBLIC"."ORDERS"."CREATED_AT" >= timestamp with time zone '2028-03-12 00:00:00.000+03:00'- AND "PUBLIC"."ORDERS"."CREATED_AT" < timestamp with time zone '2028-03-13 00:00:00.000+03:00')- LIMIT 1048575`,- },- visualization_settings: {- "graph.dimensions": ["CREATED_AT"],- "graph.metrics": ["TOTAL"],- column_settings: {- '["name","CREATED_AT"]': {- time_enabled: "milliseconds",- },- },- },- };- const hoverLineDot = ({ index } = {}) => {- // eslint-disable-next-line metabase/no-unsafe-element-filtering- H.cartesianChartCircle().eq(index).realHover();- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should use time formatting settings in tooltips for native questions (metabase#11435)", () => {- H.createNativeQuestion(questionDetails, { visitQuestion: true });- hoverLineDot({ index: 1 });- H.assertEChartsTooltip({- header: "March 11, 2028, 5:55:36.759 PM",- rows: [- {- color: "#F9D45C",- name: "TOTAL",- value: "135.23",- },- ],- });- });-});--describe("issue 15353", () => {- const questionDetails = {- name: "15353",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }]],- },- display: "pivot",- };-- beforeEach(() => {- cy.intercept("POST", "/api/dataset/pivot").as("pivotDataset");-- H.restore();- cy.signInAsAdmin();-- H.createQuestion(questionDetails, { visitQuestion: true });- });-- it("should be able to change field name used for values (metabase#15353)", () => {- H.openVizSettingsSidebar();- H.sidebar()- .findByTestId("draggable-item-Count")- .icon("ellipsis")- .click({ force: true });-- cy.findByDisplayValue("Count").type(" renamed").blur();-- cy.wait("@pivotDataset");-- cy.findByTestId("query-visualization-root").should(- "contain",- "Count renamed",- );- });-});--describe("issue 18976, 18817", () => {- const questionDetails = {- display: "table",- dataset_query: {- database: SAMPLE_DB_ID,- type: "native",- native: {- query: "select 'a', 'b'",- "template-tags": {},- },- },- visualization_settings: {- "table.pivot": true,- "table.pivot_column": "'a'",- "table.cell_column": "1",- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should display a pivot table as regular one when pivot columns are missing (metabase#18976)", () => {- H.visitQuestionAdhoc(questionDetails);-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Showing 1 row");- });-- it("should not keep orphan columns rendered after switching from pivot to regular table (metabase#18817)", () => {- H.createQuestion(- {- query: {- "source-table": PEOPLE_ID,- aggregation: [["count"]],- breakout: [- ["field", PEOPLE.NAME],- ["field", PEOPLE.SOURCE],- ],- limit: 5,- },- database: SAMPLE_DB_ID,- display: "table",- },- { visitQuestion: true },- );-- cy.findByTestId("qb-header")- .button(/Summarize/)- .click();- H.rightSidebar()- .findByLabelText("Source")- .findByRole("button", { name: "Remove dimension" })- .click();-- cy.findAllByTestId("header-cell")- .should("have.length", 2)- .and("contain", "Name")- .and("contain", "Count");- });-});--describe("issue 21392", () => {- const TEST_QUERY = {- type: "native",- native: {- query: `- WITH- L0 AS (SELECT c FROM (SELECT 1 UNION ALL SELECT 1) AS D(c)) -- 2^1- ,L1 AS (SELECT 1 AS c FROM L0 AS A CROSS JOIN L0 AS B) -- 2^2- ,L2 AS (SELECT 1 AS c FROM L1 AS A CROSS JOIN L1 AS B) -- 2^4- ,L3 AS (SELECT 1 AS c FROM L2 AS A CROSS JOIN L0 AS B) -- 2^5-- SELECT ROWNUM() id, DATEADD('DAY', ROWNUM(), CURRENT_DATE)::DATE date,- RAND() c00, RAND() c01, RAND() c02, RAND() c03, RAND() c04, RAND() c05, RAND() c06, RAND() c07, RAND() c08, RAND() c09,- RAND() c10, RAND() c11, RAND() c12, RAND() c13, RAND() c14, RAND() c15, RAND() c16, RAND() c17, RAND() c18, RAND() c19,- RAND() c20, RAND() c21, RAND() c22, RAND() c23, RAND() c24, RAND() c25, RAND() c26, RAND() c27, RAND() c28, RAND() c29,- RAND() c30, RAND() c31- FROM L3- `,- },- database: SAMPLE_DB_ID,- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should render a chart with many columns without freezing (metabase#21392)", () => {- H.visitQuestionAdhoc({ dataset_query: TEST_QUERY, display: "line" });- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Visualization").should("be.visible");- });-});--describe("#22206 adding and removing columns doesn't duplicate columns", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- H.openOrdersTable();-- cy.findByTestId("loading-indicator").should("not.exist");- });-- it("should not duplicate column in settings when removing and adding it back", () => {- H.openVizSettingsSidebar();-- // remove column- cy.findByTestId("sidebar-content")- .findByTestId("draggable-item-Subtotal")- .icon("eye_outline")- .click({ force: true });-- // rerun query- cy.findAllByTestId("run-button").first().click();- cy.wait("@dataset");- cy.findByTestId("loading-indicator").should("not.exist");-- // add column back again- cy.findByTestId("sidebar-content")- .findByTestId("draggable-item-Subtotal")- .icon("eye_crossed_out")- .click({ force: true });-- // fails because there are 2 columns, when there should be one- cy.findByTestId("sidebar-content").findByText("Subtotal");-- // if you add it back again it crashes the question- });-});--describe("issue 28304", () => {- const questionDetails = {- name: "28304",- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"]],- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],- },- database: SAMPLE_DB_ID,- },- display: "table",- visualization_settings: {- "table.columns": [- {- fieldRef: ["field", ORDERS.ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.USER_ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.PRODUCT_ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.SUBTOTAL, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.TAX, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.DISCOUNT, null],- enabled: true,- },- ],- column_settings: {- '["name","count"]': { show_mini_bar: true },- },- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.visitQuestionAdhoc(questionDetails);- });-- it("table should should generate default columns when table.columns entries do not match data.cols (metabase#28304)", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Count by Created At: Month").should("be.visible");-- H.openVizSettingsSidebar();- H.leftSidebar().should("not.contain", "[Unknown]");- H.leftSidebar().should("contain", "Created At");- H.leftSidebar().should("contain", "Count");- cy.findAllByTestId("mini-bar-container").should(- "have.length.greaterThan",- 0,- );- H.getDraggableElements().should("have.length", 2);- });-});--describe("issue 25250", () => {- const questionDetails = {- name: "28311",- dataset_query: {- type: "query",- query: {- "source-table": ORDERS_ID,- },- database: SAMPLE_DB_ID,- },- display: "table",- visualization_settings: {- "table.columns": [- {- fieldRef: ["field", ORDERS.ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.USER_ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.PRODUCT_ID, null],- enabled: true,- },- {- fieldRef: ["field", ORDERS.SUBTOTAL, null],- enabled: false,- },- {- fieldRef: ["field", ORDERS.TAX, null],- enabled: false,- },- {- fieldRef: ["field", ORDERS.DISCOUNT, null],- enabled: false,- },- ],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.visitQuestionAdhoc(questionDetails);- });-- it("pivot table should show standalone values when collapsed to the sub-level grouping (metabase#25250)", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Product ID").should("be.visible");-- H.openVizSettingsSidebar();- H.getDraggableElements().contains("Product ID").as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- vertical: -100,- useMouseEvents: true,- });- H.getDraggableElements().eq(0).should("contain", "Product ID");- });-});--describe("issue 30039", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not trigger object detail navigation after the modal was closed (metabase#30039)", () => {- H.startNewNativeQuestion();- H.NativeEditor.type("select * from ORDERS LIMIT 2");- H.runNativeQuery();- cy.findAllByTestId("detail-shortcut").first().click({ force: true });- cy.findByTestId("object-detail").should("be.visible");-- cy.realPress("{esc}");- cy.findByTestId("object-detail").should("not.exist");-- H.NativeEditor.type("{downArrow};");- H.runNativeQuery();- cy.findByTestId("object-detail").should("not.exist");- });-});--describe("issue 37726", () => {- const PIVOT_QUESTION = {- name: "Pivot table with custom column width",- display: "pivot",- query: {- "source-table": ORDERS_ID,- breakout: [- [- "field",- ORDERS.TOTAL,- { "base-type": "type/Float", binnig: { strategy: "default" } },- ],- ],- aggregation: [- ["distinct", ["field", ORDERS.ID, { "base-type": "type/BigInteger" }]],- ],- },- visualization_settings: {- "pivot_table.column_split": {- rows: ["TOTAL"],- columns: [],- values: ["distinct"],- },- "pivot_table.column_widths": {- leftHeaderWidths: [80],- totalLeftHeaderWidths: 80,- valueHeaderWidths: { 0: 193 },- },- },- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not result in an error when you add a column after resizing an existing one (#37726)", () => {- cy.intercept("POST", "/api/dataset/pivot").as("pivot");-- // The important data point in this question is that it has custom- // leftHeaderWidths as if a user had dragged them to change the defaults.- H.createQuestion(PIVOT_QUESTION, { visitQuestion: true });-- // Now, add in another column to the pivot table- cy.button(/Summarize/).click();-- cy.findByRole("listitem", { name: "Category" })- .realHover()- .button("Add dimension")- .click();-- // Wait for the pivot call to return- cy.wait("@pivot");-- // Refresh the page -- this loads the question using the transient value- cy.reload();-- // Look for the new column name in the resulting pivot table.- // Note that before this fix, the page would error out and this elements,- // along with the rest of the pivot table, would not appear.- // Instead, you got a nice ⚠️ icon and a "Something's gone wrong" tooltip.- H.main().within(() => {- cy.findByText("Product → Category", { timeout: 8000 });- });- });-});--describe("issue 42049", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should not mess up columns order (metabase#42049)", () => {- cy.intercept("POST", "/api/card/*/query", (req) => {- req.on("response", (res) => {- const createdAt = res.body.data.cols[1];-- createdAt.field_ref[1] = "created_at"; // simulate named field ref-- res.send();- });- }).as("cardQuery");-- H.createQuestion(- {- query: {- "source-table": ORDERS_ID,- fields: [- ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],- ["field", ORDERS.CREATED_AT, { "base-type": "type/DateTime" }],- ["field", ORDERS.QUANTITY, { "base-type": "type/Integer" }],- ],- },- visualization_settings: {- "table.columns": [- {- name: "ID",- fieldRef: ["field", ORDERS.ID, null],- enabled: true,- },- {- name: "CREATED_AT",- fieldRef: [- "field",- ORDERS.CREATED_AT,- {- "temporal-unit": "default",- },- ],- enabled: true,- },- {- name: "QUANTITY",- fieldRef: ["field", ORDERS.QUANTITY, null],- enabled: true,- },- ],- },- },- { visitQuestion: true },- );-- cy.log("verify initial columns order");-- cy.findAllByTestId("header-cell").as("headerCells");- cy.get("@headerCells").eq(0).should("have.text", "ID");- cy.get("@headerCells").eq(1).should("have.text", "Created At");- cy.get("@headerCells").eq(2).should("have.text", "Quantity");-- cy.findByTestId("question-filter-header").click();-- H.popover().within(() => {- cy.findByText("Created At").click();- cy.button("Previous month").click();- });-- cy.wait("@cardQuery");- cy.get("@cardQuery.all").should("have.length", 2);-- cy.log("verify columns order after applying the filter");-- cy.findAllByTestId("header-cell").as("headerCells");- cy.get("@headerCells").eq(0).should("have.text", "ID");- cy.get("@headerCells").eq(1).should("have.text", "Created At");- cy.get("@headerCells").eq(2).should("have.text", "Quantity");- });-});--describe("issue 42697", () => {- const PIVOT_QUESTION = {- display: "pivot",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["count"],- ["sum", ["field", ORDERS.TOTAL, { "base-type": "type/Float" }]],- ],- breakout: [- [- "field",- PEOPLE.STATE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ],- [- "field",- ORDERS.CREATED_AT,- { "base-type": "type/DateTime", "temporal-unit": "year" },- ],- ],- },- visualization_settings: {- "pivot_table.column_split": {- rows: ["CREATED_AT"],- columns: ["STATE"],- values: ["count", "sum"],- },- "pivot_table.column_widths": {- leftHeaderWidths: [156],- totalLeftHeaderWidths: 156,- valueHeaderWidths: {},- },- },- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- cy.intercept("PUT", "/api/card/*").as("updateCard");- });-- it("should display a pivot table when a new breakout is added to the query (metabase#42697)", () => {- H.createQuestion(PIVOT_QUESTION, { visitQuestion: true });- H.openNotebook();- H.getNotebookStep("summarize")- .findByTestId("breakout-step")- .icon("add")- .click();- H.popover().within(() => {- cy.findByText("Product").click();- cy.findByText("Category").click();- });- H.queryBuilderHeader().findByText("Save").click();- H.modal().button("Save").click();- cy.wait("@updateCard");- cy.button("Visualize").click();- cy.findByTestId("pivot-table")- .findByText("Product → Category")- .should("be.visible");- });-});--describe("issue 7884", () => {- const oldSourceQuestionDetails = {- native: {- query: "SELECT 1 AS C1, 2 AS C2, 3 AS C3",- },- };-- const newSourceQuestionDetails = {- native: {- query: "SELECT 1 AS C1, 3 AS C3",- },- };-- const getNestedQuestionDetails = (sourceQuestionId) => ({- query: {- "source-table": `card__${sourceQuestionId}`,- },- display: "table",- visualization_settings: {- "table.columns": [- { name: "C3", enabled: true },- { name: "C1", enabled: true },- { name: "C2", enabled: true },- ],- },- });-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not reset the column order after one of the columns is removed from data source (metabase#7884)", () => {- H.createNativeQuestion(oldSourceQuestionDetails).then(- ({ body: sourceQuestion }) =>- H.createQuestion(getNestedQuestionDetails(sourceQuestion.id)).then(- ({ body: nestedQuestion }) => {- cy.request("PUT", `/api/card/${sourceQuestion.id}`, {- ...sourceQuestion,- dataset_query: {- type: "native",- database: SAMPLE_DB_ID,- native: newSourceQuestionDetails.native,- },- });- H.visitQuestion(nestedQuestion.id);- },- ),- );-- cy.log("verify column order in the table");- cy.findAllByTestId("header-cell").eq(0).should("contain.text", "C3");- cy.findAllByTestId("header-cell").eq(1).should("contain.text", "C1");-- cy.log("verify column order in viz settings");- H.openVizSettingsSidebar();- H.getDraggableElements().eq(0).should("contain.text", "C3");- H.getDraggableElements().eq(1).should("contain.text", "C1");- });-});--describe("issue 45481", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should not crash when the table viz gets automatically pivoted (metabase#45481)", () => {- H.openOrdersTable({ mode: "notebook" });- H.summarize({ mode: "notebook" });- H.popover().findByText("Count of rows").click();- H.getNotebookStep("summarize")- .findByText("Pick a column to group by")- .click();- H.popover().findByText("User ID").click();- H.getNotebookStep("summarize")- .findByTestId("breakout-step")- .icon("add")- .click();- H.popover().within(() => {- cy.findByText("Product").click();- cy.findByText("Category").click();- });- H.visualize();- H.tableInteractive().should("be.visible");- });-});--describe("issue 12368", () => {- const questionDetails = {- type: "question",- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [- ["field", PRODUCTS.VENDOR, { "base-type": "type/Text" }],- ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],- ],- },- visualization_settings: {- "table.pivot": true,- "table.pivot_column": "CATEGORY",- "table.cell_column": "count",- column_settings: {- [`["ref",["field",${PRODUCTS.VENDOR},null]]`]: {- column_title: "Vendor2",- },- },- },- };-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- });-- it("should clear pivot settings when doing underlying records drill from a pivot table (metabase#12368)", () => {- cy.log("drill thru from a pivot table");- H.createQuestion(questionDetails, { visitQuestion: true });- cy.findAllByTestId("cell-data").contains("1").first().click();- H.popover().findByText("See this Product").click();-- cy.log("pivot flag should be cleared but other viz settings are preserved");- H.tableInteractive().within(() => {- cy.findByText("Ean").should("be.visible");- cy.findByText("Vendor2").should("be.visible");- });- H.openVizSettingsSidebar();- cy.findByTestId("chartsettings-sidebar").within(() => {- cy.button("Add or remove columns").should("be.visible");- cy.findByText("Pivot column").should("not.exist");- cy.findByText("Cell column").should("not.exist");- });- });-});--describe("issue 32718", () => {- const questionDetails = {- display: "table",- query: {- "source-table": PRODUCTS_ID,- fields: [- ["field", PRODUCTS.ID, { "base-type": "type/BigInteger" }],- ["field", PRODUCTS.EAN, { "base-type": "type/Text" }],- ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],- ["field", PRODUCTS.CREATED_AT, { "base-type": "type/DateTime" }],- ],- limit: 1,- },- visualization_settings: {- "table.columns": [- { name: "ID", enabled: true },- { name: "EAN", enabled: false },- { name: "CATEGORY", enabled: true },- { name: "CREATED_AT", enabled: true },- ],- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- cy.request("PUT", `/api/field/${PRODUCTS.CATEGORY}`, {- visibility_type: "details-only",- });- });-- it("should honor visibility_type of the field when the question has viz settings (metabase#32718)", () => {- H.createQuestion(questionDetails, { visitQuestion: true });- H.tableInteractive().within(() => {- cy.findByText("ID").should("be.visible");- cy.findByText("Ean").should("not.exist");- cy.findByText("Category").should("not.exist");- cy.findByText("Created At").should("be.visible");- });- H.openVizTypeSidebar();- cy.findByTestId("Detail-button").click();- cy.findByTestId("object-detail").within(() => {- cy.findByText("ID").should("be.visible");- cy.findByText("Ean").should("not.exist");- cy.findByText("Category").should("be.visible");- cy.findByText("Created At").should("be.visible");- });- });-});--describe("issue 50346", () => {- const questionDetails = {- query: {- "source-table": ORDERS_ID,- aggregation: [- ["count"],- ["sum", ["field", ORDERS.TOTAL, { "base-type": "type/Float" }]],- ],- breakout: [- [- "field",- PRODUCTS.CATEGORY,- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },- ],- [- "field",- PRODUCTS.VENDOR,- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },- ],- [- "field",- PEOPLE.SOURCE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ],- ],- },- display: "pivot",- visualization_settings: {- "pivot_table.column_split": {- // mix field refs with and without `base-type` to make sure we support both cases- rows: [- ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],- [- "field",- PRODUCTS.VENDOR,- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },- ],- [- "field",- PEOPLE.SOURCE,- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },- ],- ],- columns: [],- values: [- ["aggregation", 0],- ["aggregation", 1],- ],- },- "pivot_table.column_widths": {- leftHeaderWidths: [150, 214, 120],- totalLeftHeaderWidths: 484,- valueHeaderWidths: {},- },- },- };-- const groupValue = "Annetta Wyman and Sons";- const totalValue = "1,217.76";-- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- cy.intercept("PUT", "/api/card/*").as("updateCard");- });-- it("should be able to collapse rows for questions with legacy pivot settings (metabase#50346)", () => {- H.createQuestion(questionDetails, { visitQuestion: true, wrapId: true });-- cy.log("collapse one of the sections");- cy.findByTestId("pivot-table").within(() => {- cy.findByText(totalValue).should("be.visible");- cy.findByTestId(`${groupValue}-toggle-button`).click();- cy.findByText(totalValue).should("not.exist");- });-- cy.log("save and make sure the setting is preserved on reload");- H.queryBuilderHeader().button("Save").click();- H.modal().button("Save").click();- cy.wait("@updateCard");- H.visitQuestion("@questionId");- cy.findByTestId("pivot-table").within(() => {- cy.findByText(totalValue).should("not.exist");- });-- cy.log("expand the section");- cy.findByTestId("pivot-table").within(() => {- cy.findByTestId(`${groupValue}-toggle-button`).click();- cy.findByText(totalValue).should("be.visible");- });- });-});--describe("issue 50686", () => {- const questionDetails = {- name: "50686",- display: "smartscalar",- native: {- query:- "select 100 as total, 110 as forecast, 80 as last_year, now() as now",- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should allow selecting more than 1 comparison (metabase#50686)", () => {- H.createNativeQuestion(questionDetails, { visitQuestion: true });- // Default comparison (a single one renders inline)- H.queryBuilderMain().findByText("(No data)");-- // Add another comparison- H.openVizSettingsSidebar();- cy.button("Add comparison").click();- H.popover().findByText("Value from another column…").click();- H.popover().findByText("FORECAST").click();- H.popover().button("Done").click();-- H.queryBuilderMain().within(() => {- // First comparison still exists- cy.findByText("N/A (No data)");-- // New comparison has been added- cy.findByText("-9.09% (110)");- cy.contains("vs. FORECAST");- });- });-});--describe("issue 52339", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should allow mapping pivot table dashcard fields to click behavior targets (metabase#52339)", () => {- const questionDetails = {- name: "Orders, Distinct values of ID, Grouped by Product → Title and Created At (month) and User → ID",-- query: {- "source-table": ORDERS_ID,- aggregation: [["distinct", ["field", ORDERS.ID, null]]],- breakout: [- ["field", PRODUCTS.TITLE, { "source-field": ORDERS.PRODUCT_ID }],- ["field", PEOPLE.SOURCE, { "source-field": ORDERS.USER_ID }],- ],- },- display: "pivot",- visualization_settings: {- "pivot_table.column_split": {- rows: ["TITLE", "SOURCE"],- columns: [],- values: ["distinct"],- },- },- };-- const sourceParam = {- name: "Source",- slug: "filter-text",- id: "1b9cd9f1",- type: "string/=",- sectionId: "string",- };-- H.createQuestionAndDashboard({- dashboardDetails: {- parameters: [sourceParam],- },- questionDetails,- cardDetails: {- size_x: 16,- size_y: 8,- },- }).then(({ body: { id, card_id, dashboard_id }, questionId }) => {- cy.wrap(questionId).as("questionId");-- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id,- card_id,- row: 0,- col: 0,- size_x: 16,- size_y: 8,- series: [],- visualization_settings: {},- parameter_mappings: [- {- parameter_id: sourceParam.id,- card_id,- target: [- "dimension",- [- "field",- PEOPLE.SOURCE,- {- "source-field": ORDERS.USER_ID,- },- ],- ],- },- ],- },- ],- });-- H.visitDashboard(dashboard_id);- });-- H.editDashboard();- H.getDashboardCard(0)- .realHover({ scrollBehavior: "bottom" })- .findByLabelText("Click behavior")- .click();-- H.sidebar().within(() => {- cy.findByText("Go to a custom destination").click();- cy.findByText("Dashboard").click();- });-- H.modal().findByText("Test Dashboard").click();-- cy.findByTestId("click-mappings").findByText("Source").click();-- H.popover().within(() => {- cy.findByText("Product → Title");- cy.findByText("User → Source");- cy.findByText("Distinct values of ID");- });- });-});--describe("issue 56771", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should apply correct column widths after changing query (metabase#56771)", () => {- H.openOrdersTable();- cy.log(- "Resize a column first to make width stored in the visualization settings",- );- H.resizeTableColumn("ID", 100);-- H.openNotebook();- H.join();- H.joinTable("Products");- H.visualize();-- cy.wait(100); // wait for the column to be resized-- cy.findAllByTestId("header-cell")- .filter(":contains(Products → Category)")- .as("headerCell")- .then(($cell) => {- const width = $cell[0].getBoundingClientRect().width;- expect(width).to.be.greaterThan(160);- });- });-});--describe("issue 52333", () => {- const baseQuery = `-SELECT *-FROM (- SELECT- category,- source,- state,- SUM(orders.discount) AS discount,- SUM(orders.total) AS total,- SUM(orders.quantity) AS quantity- FROM- orders- LEFT JOIN products ON orders.product_id = products.id- LEFT JOIN people ON orders.user_id = people.id- GROUP BY category, source, state-) AS filtered_orders-WHERE NOT (- category = 'Gizmo'- AND (- source IN ('Facebook', 'Google', 'Organic', 'Twitter')- OR state NOT IN ('AK')- )-);`;-- const baseQuestionDetails = {- name: "52333",- display: "table",- native: {- query: baseQuery,- },- };-- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("pivot table should show subtotals for a group of a single value (metabase#52333)", () => {- H.createNativeQuestion(baseQuestionDetails, {- visitQuestion: true,- wrapId: true,- });-- cy.get("@questionId").then((id) => {- const questionDetails = {- query: {- "source-table": `card__${id}`,- aggregation: [["count"]],- breakout: [- [- "field",- "CATEGORY",- {- "base-type": "type/Text",- },- ],- [- "field",- "SOURCE",- {- "base-type": "type/Text",- },- ],- [- "field",- "STATE",- {- "base-type": "type/Text",- },- ],- ],- },- display: "pivot",- visualization_settings: {- "pivot_table.column_split": {- rows: ["CATEGORY", "SOURCE", "STATE"],- columns: [],- values: ["count", "avg"],- },- "pivot_table.column_widths": {- leftHeaderWidths: [104, 92, 80],- totalLeftHeaderWidths: 276,- valueHeaderWidths: {},- },- "pivot_table.collapsed_rows": {- value: ['["Doohickey"]', '["Gadget"]', '["Widget"]'],- rows: ["CATEGORY", "SOURCE", "STATE"],- },- },- };-- H.createQuestion(questionDetails, { visitQuestion: true });- });-- H.queryBuilderMain().within(() => {- cy.findByText("Affiliate");- cy.findByText("AK");-- // Ensure it does not show subtotals for the single value by default- cy.findByText("Totals for Affiliate").should("not.exist");-- H.openVizSettingsSidebar();- });-- H.sidebar().findByText("Condense duplicate totals").click();-- // Ensure it shows subtotals for the single value- H.queryBuilderMain()- .findByText("Totals for Affiliate")- .should("be.visible");- });-});--describe("issue 55673", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- H.openOrdersTable();- });-- it("should be able to close a header popover using Escape (metabase#55673)", () => {- H.tableHeaderClick("Product ID");- cy.findByTestId("click-actions-view").should("be.visible");-- cy.focused().should(- "have.attr",- "data-testid",- "click-actions-sort-control-sort.ascending",- );- cy.realPress(["Escape"]);- cy.findByTestId("click-actions-view").should("not.exist");- });-});--describe("issue 63745", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should display correct data when toggling columns (metabase#63745)", () => {- H.visitQuestionAdhoc({- name: "63745",- display: "object",- dataset_query: {- type: "query",- database: SAMPLE_DB_ID,- query: {- "source-table": ORDERS_ID,- limit: 5,- },- },- });-- H.openVizSettingsSidebar();- cy.findByTestId("chartsettings-sidebar")- .button("Add or remove columns")- .click();-- cy.findAllByTestId("object-details-table-cell").should(($cells) => {- const cellsFlat = $cells.toArray().map((el) => el.textContent);- const map = new Map(chunk(cellsFlat, 2));- expect(map.get("User ID")).to.eq("1");- });-- cy.findByTestId("orders-table-columns").findByLabelText("ID").click();-- cy.findAllByTestId("object-details-table-cell").should(($cells) => {- const cellsFlat = $cells.toArray().map((el) => el.textContent);- const map = new Map(chunk(cellsFlat, 2));- expect(map.get("User ID")).to.eq("1");- });- });-});--describe("issue 56094", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should allow to switch between automatic pivot table and usual table visualization (metabase#56094)", () => {- H.visitQuestionAdhoc({- name: "56094",- dataset_query: {- type: "query",- database: SAMPLE_DB_ID,- query: {- "source-table": PRODUCTS_ID,- aggregation: [["count"]],- breakout: [- [- "field",- PRODUCTS.CATEGORY,- {- "base-type": "type/Text",- },- ],- [- "field",- PRODUCTS.RATING,- {- binning: {- strategy: "default",- },- },- ],- ],-- limit: 20,- },- },- });-- H.queryBuilderFooter().findByLabelText("Switch to data").click();-- H.queryBuilderFooterDisplayToggle().should("exist");-- H.queryBuilderFooter().findByLabelText("Switch to visualization").click();-- H.queryBuilderFooterDisplayToggle().should("exist");- });-});--describe("issue 57685", () => {- beforeEach(() => {- H.restore();- cy.signInAsNormalUser();- H.createNativeQuestion(- {- display: "table",- native: {- query: 'SELECT id as "" FROM PRODUCTS',- },- },- { visitQuestion: true },- );- });-- it("should handle empty column names without error (metabase#57685)", () => {- cy.findByTestId("visualization-root").icon("warning").should("not.exist");-- cy.findByTestId("qb-header-action-panel")- .findByText("Explore results")- .click();-- H.tableInteractive().should("be.visible");- });-});diff --git a/e2e/test/scenarios/visualizer/basics.cy.spec.ts b/e2e/test/scenarios/visualizer/basics.cy.spec.tsindex 4f0d868de44..018f1f9c67d 100644--- a/e2e/test/scenarios/visualizer/basics.cy.spec.ts+++ b/e2e/test/scenarios/visualizer/basics.cy.spec.ts@@ -818,6 +818,64 @@ describe("scenarios > visualizer > basics", () => {});});+ it("should not reload the dashboard when the base card of a multi-series dashcard is broken (metabase#21665)", () => {+ const Q1 = {+ name: "21665 Q1",+ native: { query: "select 1" },+ display: "scalar" as const,+ };++ const Q2 = {+ name: "21665 Q2",+ native: { query: "select 2" },+ display: "scalar" as const,+ };++ H.createNativeQuestion(Q2);+ H.createNativeQuestionAndDashboard({+ questionDetails: Q1,+ dashboardDetails: { name: "21665D" },+ }).then(({ body: { card_id, dashboard_id } }) => {+ cy.wrap(card_id).as("baseQuestionId");+ cy.wrap(dashboard_id).as("dashboardId");+ H.visitDashboard(dashboard_id);+ });++ H.editDashboard();+ H.getDashboardCard(0)+ .realHover({ scrollBehavior: "bottom" })+ .findByLabelText("Visualize another way")+ .click();+ H.modal().within(() => {+ H.switchToAddMoreData();+ H.selectDataset(Q2.name);+ cy.button("Save").click();+ });+ H.saveDashboard();++ cy.get("@baseQuestionId").then((baseQuestionId) => {+ cy.request("PUT", `/api/card/${baseQuestionId}`, {+ dataset_query: {+ type: "native",+ native: { query: "select order by --" },+ database: SAMPLE_DB_ID,+ },+ });+ });++ // `cy.on` runs when the test is defined, so register it in the command queue to skip the earlier visit+ const windowLoad = cy.spy().as("windowLoad");+ cy.then(() => cy.on("window:before:load", windowLoad));++ H.visitDashboard("@dashboardId");+ H.getDashboardCard(0)+ .findByText(+ "Some columns are missing, this card might not render correctly.",+ )+ .should("be.visible");+ cy.get("@windowLoad").should("have.been.calledOnce");+ });+describe("public sharing and embedding", () => {function ensureVisualizerCardsAreRendered() {// Checks a cartesian chart has an axis name