The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Consolidate other charts and scalar e2e tests (#83965)
Nemanja Glumac474271d120d6
diff --git a/e2e/test/scenarios/visualizations/charts/boxplot.cy.spec.js b/e2e/test/scenarios/visualizations/charts/boxplot.cy.spec.jsindex a2576d992a5..27c10bbd8e8 100644--- a/e2e/test/scenarios/visualizations/charts/boxplot.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/boxplot.cy.spec.js@@ -35,7 +35,7 @@ describe("scenarios > visualizations > boxplot", () => {cy.signInAsNormalUser();});- it("should render boxplot and update chart on display settings changes", () => {+ it("should render boxplot with tooltips and update chart on display and axis settings changes", () => {H.visitQuestionAdhoc(singleSeriesQuestion);// 5 Boxes: 2025-2029@@ -45,12 +45,38 @@ describe("scenarios > visualizations > boxplot", () => {H.BoxPlot.getPoints().should("have.length", 1); // Only one outlierH.BoxPlot.getMeanMarkers().should("have.length", 5);+ // Hover over a box element from the left side to avoid mean marker overlap+ H.BoxPlot.getBoxes().first().trigger("mousemove", "left");+ H.assertEChartsTooltip({+ header: "2025",+ rows: [+ { name: "Upper whisker", value: "84" },+ { name: "Q3 (75th percentile)", value: "59" },+ { name: "Median", value: "35" },+ { name: "Mean", value: "39.16" },+ { name: "Q1 (25th percentile)", value: "15.5" },+ { name: "Lower whisker", value: "1" },+ ],+ });++ // Hover over the outlier point+ H.BoxPlot.getPoints().first().trigger("mousemove");+ H.assertEChartsTooltip({+ header: "2029 (outlier)",+ rows: [+ { name: "Count", value: "189" },+ { name: "Total: 50 bins", value: "70 – 75" },+ ],+ blurAfter: true,+ });+// Open settings and change whisker type to Min/MaxH.openVizSettingsSidebar();H.leftSidebar().within(() => {cy.findByText("Display").click();cy.findByText("Whiskers extend to").should("exist");cy.findByText("1.5 × interquartile range").should("exist");+ cy.findByText("Outliers only").should("be.visible");cy.findByText("Min/Max").click();});@@ -75,70 +101,7 @@ describe("scenarios > visualizations > boxplot", () => {// Toggle mean back onH.leftSidebar().findByText("Show mean").click();H.BoxPlot.getMeanMarkers().should("have.length", 5);- });-- it("should show and configure data labels", () => {- H.visitQuestionAdhoc(singleSeriesQuestion);-- H.openVizSettingsSidebar();- H.leftSidebar().within(() => {- cy.findByText("Display").click();- cy.findByText("Show values on data points").click();- });-- // After enabling, "Values to display" option appears with segmented buttons- H.leftSidebar().within(() => {- cy.findByText("Values to display").should("exist");- cy.findByRole("button", { name: "Median only" }).should("exist");- cy.findByRole("button", { name: "All" }).click();- });-- // Verify label value appears- H.echartsContainer().findByText("412").should("exist");-- // Disable "Hide overlapping labels" to show more labels- H.leftSidebar().findByText("Hide overlapping labels").click();- H.echartsContainer().findByText("91.75").should("exist");-- // Test "Auto formatting" segmented button- H.leftSidebar().within(() => {- cy.findByText("Auto formatting").should("exist");- cy.findByRole("button", { name: "Full" }).click();- });- });-- it("should display tooltips on hover", () => {- H.visitQuestionAdhoc(singleSeriesQuestion);- // Hover over a box element from the left side to avoid mean marker overlap- H.BoxPlot.getBoxes().first().trigger("mousemove", "left");- H.assertEChartsTooltip({- header: "2025",- rows: [- { name: "Upper whisker", value: "84" },- { name: "Q3 (75th percentile)", value: "59" },- { name: "Median", value: "35" },- { name: "Mean", value: "39.16" },- { name: "Q1 (25th percentile)", value: "15.5" },- { name: "Lower whisker", value: "1" },- ],- });-- // Hover over the outlier point- H.BoxPlot.getPoints().first().trigger("mousemove");- H.assertEChartsTooltip({- header: "2029 (outlier)",- rows: [- { name: "Count", value: "189" },- { name: "Total: 50 bins", value: "70 – 75" },- ],- });- });-- it("should support axis customization", () => {- H.visitQuestionAdhoc(singleSeriesQuestion);-- H.openVizSettingsSidebar();H.leftSidebar().findByText("Axes").click();// Add y-axis label@@ -164,11 +127,44 @@ describe("scenarios > visualizations > boxplot", () => {});});- it("should display goal line when configured", () => {+ it("should show and configure data labels and the goal line", () => {H.visitQuestionAdhoc(singleSeriesQuestion);H.openVizSettingsSidebar();- H.leftSidebar().findByText("Display").click();+ H.leftSidebar().within(() => {+ cy.findByText("Display").click();+ cy.findByText("Show values on data points").click();+ });++ // After enabling, "Values to display" option appears with segmented buttons+ H.leftSidebar().within(() => {+ cy.findByText("Values to display").should("exist");+ cy.findByRole("button", { name: "Median only" }).should("exist");+ });++ // With "Median only", the median labels show (2025 median is 35), but not the other values+ H.echartsContainer().findAllByText("35").should("exist");+ H.echartsContainer().findByText("412").should("not.exist");++ H.leftSidebar().findByRole("button", { name: "All" }).click();++ // Verify label value appears+ H.echartsContainer().findByText("412").should("exist");++ H.leftSidebar().findByText("Hide overlapping labels").click();+ H.echartsContainer().findByText("91.75").should("exist");++ // Test "Auto formatting" segmented button+ H.leftSidebar().within(() => {+ cy.findByText("Auto formatting").should("exist");+ cy.findByRole("button", { name: "Full" }).click();+ cy.findByRole("button", { name: "Full" }).should(+ "have.attr",+ "data-variant",+ "filled",+ );+ });+H.leftSidebar().findByText("Goal line").click();H.leftSidebar().within(() => {diff --git a/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js b/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.jsindex fd6b9dce200..9060e41fb75 100644--- a/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/funnel.cy.spec.js@@ -25,7 +25,7 @@ describe("scenarios > visualizations > funnel chart", () => {H.sidebar().findByText("Data").click();});- it("should allow you to reorder and show/hide rows", () => {+ it("should allow you to reorder and show/hide rows, and handle row items being filtered out and returned", () => {cy.log("ensure that rows are shown");H.getDraggableElements().should("have.length", 5);@@ -65,15 +65,8 @@ describe("scenarios > visualizations > funnel chart", () => {cy.icon("eye_crossed_out").click({ force: true });});cy.findAllByTestId("funnel-chart-header").should("have.length", 5);- });-- it("should handle row items being filterd out and returned gracefully", () => {- H.getDraggableElements().first().as("dragElement");- H.moveDnDKitElementByAlias("@dragElement", {- vertical: 100,- useMouseEvents: true,- });+ cy.log("filter rows out and return them");H.getDraggableElements().eq(1).within(() => {@@ -89,6 +82,7 @@ describe("scenarios > visualizations > funnel chart", () => {});H.getDraggableElements().should("have.length", 4);+ cy.findAllByTestId("funnel-chart-header").should("have.length", 3);//Ensures that "Google" is still hidden, so it's state hasn't changed.H.getDraggableElements()diff --git a/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.js b/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.jsindex aba06895d93..31e54ccfe73 100644--- a/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/gauge.cy.spec.js@@ -14,31 +14,31 @@ describe("scenarios > visualizations > gauge chart", () => {name: "15980",query: { "source-table": ORDERS_ID, aggregation: [["count"]] },display: "gauge",+ visualization_settings: {+ "gauge.segments": [+ { min: 0, max: 10000, color: "#ED6E6E", label: "" },+ { min: 10000, max: 30000, color: "#84BB4C", label: "Goal" },+ ],+ },};- H.createQuestionAndDashboard({ questionDetails }).then(- ({ body: { id, card_id, dashboard_id } }) => {- // Make dashboard card really small (necessary for this repro as it doesn't show any labels)- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {- dashcards: [- {- id,- card_id,- row: 0,- col: 0,- size_x: 5,- size_y: 4,- parameter_mappings: [],- },- ],- });+ // A small dashboard card hides the gauge labels and shows them in a tooltip on hover+ H.createQuestionAndDashboard({+ questionDetails,+ cardDetails: { size_x: 5, size_y: 4 },+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);+ });- H.visitDashboard(dashboard_id);- },- );+ // Hover a segment without a label, then a segment with a label+ H.getDashboardCard().findByTestId("gauge-arc-0").trigger("mousemove");++ // The value text covers the center of this arc+ H.getDashboardCard()+ .findByTestId("gauge-arc-1")+ .trigger("mousemove", { force: true });+ H.tooltip().should("contain", "Goal").and("contain", "10,000 - 30,000");- cy.findByTestId("gauge-arc-1").trigger("mousemove");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Something went wrong").should("not.exist");+ H.getDashboardCard().findByTestId("gauge-arc-1").should("be.visible");});});diff --git a/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js b/e2e/test/scenarios/visualizations/charts/maps.cy.spec.jsindex 8ebb196253d..420d4299092 100644--- a/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/maps.cy.spec.js@@ -78,11 +78,8 @@ describe("scenarios > visualizations > maps", () => {{ visitQuestion: true },);- cy.button("Visualization").click();-- cy.findByTestId("chart-type-settings").within(() => {- cy.findByText("Map").should("be.visible");- });+ // A saved question resets to the default display on load when its display is not sensible+ H.queryBuilderMain().find(".leaflet-marker-icon").should("have.length", 10);});it("should wrap markers around the international date line correctly (metabase#5369)", () => {@@ -205,10 +202,10 @@ describe("scenarios > visualizations > maps", () => {cy.get("@texas").trigger("mousemove");// check tooltip content- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("State:"); // column name key- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Texas"); // feature name as value+ H.tooltip().within(() => {+ cy.findByText("State:").should("be.visible"); // column name key+ cy.findByText("Texas").should("be.visible"); // feature name as value+ });// open drill-through menu and drill within itcy.get("@texas").click();@@ -223,48 +220,6 @@ describe("scenarios > visualizations > maps", () => {cy.findByText("171 Olive Oyle Lane"); // Address in the first row});- it("should display pins when a breakout column sets a base-type (metabase#59984)", () => {- cy.intercept("/api/tiles/**").as("tiles");-- H.visitQuestionAdhoc({- display: "map",- dataset_query: {- database: SAMPLE_DB_ID,- type: "query",- query: {- "source-table": PEOPLE_ID,- aggregation: ["count"],- breakout: [- [- "field",- PEOPLE.LONGITUDE,- {- "base-type": "type/Float",- },- ],- [- "field",- PEOPLE.LATITUDE,- {- "base-type": "type/Float",- },- ],- ],- },- },- visualization_settings: {- "map.type": "pin",- "map.latitude_column": "LATITUDE",- "map.longitude_column": "LONGITUDE",- },- });-- // this should not create a 400 error- cy.wait("@tiles").then((xhr) => {- expect(xhr.response.statusCode).to.equal(200);- });- });-it("should display a tooltip for a grid map without a metric column (metabase#17940)", () => {H.visitQuestionAdhoc({display: "map",@@ -305,12 +260,11 @@ describe("scenarios > visualizations > maps", () => {cy.get(".leaflet-interactive").trigger("mousemove");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Latitude: 10°:");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Longitude: 10°:");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("1");+ H.tooltip().within(() => {+ cy.findByText("Latitude: 10°:").should("be.visible");+ cy.findByText("Longitude: 10°:").should("be.visible");+ cy.findByText("1").should("be.visible");+ });});it("should render grid map visualization for native questions (metabase#8362)", () => {@@ -335,18 +289,11 @@ describe("scenarios > visualizations > maps", () => {},});- // Ensure chart is rendered- cy.get(".leaflet-interactive");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Visualization").click();-- cy.findByTestId("chart-type-settings").within(() => {- cy.findByTestId("Map-button").should("be.visible");- });+ // An ad-hoc question resets to the default display when its display is not sensible+ H.queryBuilderMain().find(".leaflet-interactive").should("exist");});- it("should display pins type viz setting (metabase#40999)", () => {+ it("should display pins when a breakout column sets a base-type and support the pin type viz setting (metabase#40999) (metabase#59984)", () => {cy.intercept("/api/tiles/**").as("tiles");H.visitQuestionAdhoc({@@ -382,7 +329,8 @@ describe("scenarios > visualizations > maps", () => {},});- cy.wait("@tiles");+ // this should not create a 400 error (metabase#59984)+ cy.wait("@tiles").its("response.statusCode").should("eq", 200);cy.findByTestId("viz-settings-button").click();@@ -394,7 +342,7 @@ describe("scenarios > visualizations > maps", () => {});cy.findByTestId("visualization-root")- .get(".leaflet-marker-icon")+ .find(".leaflet-marker-icon").should("have.length.greaterThan", 10);});@@ -565,78 +513,71 @@ describe("scenarios > visualizations > maps", () => {);});- 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");+ it("should handle data sets that contain only null values for longitude/latitude (metabase#18061)", () => {+ cy.log("scenario 1: question with a filter (metabase#18061-1)");+ H.visitAlias("@questionUrl");- cy.wait("@getCard");- cy.wait("@cardQuery");+ cy.wait("@getCard");+ cy.wait("@cardQuery");- cy.intercept("POST", "/api/dataset").as("dataset");- cy.window().then((w) => (w.beforeReload = true));+ 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.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");+ 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.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);- });- });+ 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.log("scenario 2: dashboard with a filter (metabase#18061-2)");+ H.visitAlias("@dashboardUrl");- cy.wait("@dashCardQuery");- cy.window().then((w) => (w.beforeReload = true));+ cy.wait("@dashCardQuery");+ cy.window().then((w) => (w.beforeReload = true));- addFilter("Twitter");+ addFilter("Twitter");- cy.wait("@dashCardQuery");- cy.location("search").should("eq", "?category=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);- });- });+ // 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");+ cy.log(+ "scenario 3: publicly shared dashboard with a filter (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]");+ // 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");- });+ addFilter("Twitter");+ cy.location("search").should("eq", "?category=Twitter");+ cy.findAllByTestId("no-results-image");+ cy.get("[data-element-id=pin-map]").should("not.exist");});});diff --git a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.jsindex d7cf58d746e..b4e0886f3f7 100644--- a/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/pie_chart.cy.spec.js@@ -76,7 +76,7 @@ describe("scenarios > visualizations > pie chart", () => {cy.signInAsNormalUser();});- it("should render a pie chart (metabase#12506) (#35244)", () => {+ it("should render a pie chart and mute legend items on hover (metabase#12506) (metabase#29224) (#35244)", () => {H.visitQuestionAdhoc({dataset_query: testQuery,display: "pie",@@ -100,24 +100,7 @@ describe("scenarios > visualizations > pie chart", () => {});});- cy.log("#35244");- cy.findByLabelText("Switch to data").click();- H.tableHeaderClick("Count");- H.popover().within(() => {- cy.findByRole("img", { name: /filter/ }).should("exist");- cy.findByRole("img", { name: /gear/ }).should("not.exist");- cy.findByRole("img", { name: /eye_crossed_out/ }).should("not.exist");- });- });-- it("should mute items in legend when hovering (metabase#29224)", () => {- H.visitQuestionAdhoc({- dataset_query: testQuery,- display: "pie",- });-- // flakiness prevention- cy.findByTestId("chart-container").findByText("Total").should("be.visible");+ cy.log("metabase#29224");cy.findByTestId("view-footer").findByText("Showing 4 rows").should("be.visible");@@ -132,9 +115,18 @@ describe("scenarios > visualizations > pie chart", () => {["Gizmo", "false"],["Widget", "false"],].map((args) => checkLegendItemAriaCurrent(args[0], args[1]));++ cy.log("#35244");+ cy.findByLabelText("Switch to data").click();+ H.tableHeaderClick("Count");+ H.popover().within(() => {+ cy.findByRole("img", { name: /filter/ }).should("exist");+ cy.findByRole("img", { name: /gear/ }).should("not.exist");+ cy.findByRole("img", { name: /eye_crossed_out/ }).should("not.exist");+ });});- it("should not truncate legend titles when enabling percentages (metabase#48207)", () => {+ it("should not truncate legend titles when enabling percentages and should instantly toggle the total (metabase#48207)", () => {H.visitQuestionAdhoc({dataset_query: testQuery,display: "pie",@@ -150,24 +142,21 @@ describe("scenarios > visualizations > pie chart", () => {cy.findByText("In legend").click();});- cy.findByTestId("chart-legend").within(() => {- cy.findByText("Widget").then(([element]) => {+ cy.findByTestId("chart-legend")+ .findByTestId("legend-item-Widget")+ .should("contain", "%");+ cy.findByTestId("chart-legend")+ .findByText("Widget")+ .should(([element]) => {// When text is truncated, offsetWidth will be less than scrollWidthexpect(element.offsetWidth).to.eq(element.scrollWidth);});- });- });- it("should instantly toggle the total after changing the setting", () => {- H.visitQuestionAdhoc({- dataset_query: testQuery,- display: "pie",- });-- H.openVizSettingsSidebar();+ cy.findByTestId("query-visualization-root")+ .findByText("Total")+ .should("be.visible");H.leftSidebar().within(() => {- cy.findByText("Display").click();cy.findByText("Show total").click();});@@ -184,7 +173,7 @@ describe("scenarios > visualizations > pie chart", () => {});});- it("should add new slices to the chart if they appear in the query result", () => {+ it("should add new slices to the chart and preserve a slice's settings if its row is removed then reappears in the query result", () => {H.visitQuestionAdhoc({dataset_query: getLimitedQuery(testQuery, 2),display: "pie",@@ -195,15 +184,6 @@ describe("scenarios > visualizations > pie chart", () => {changeRowLimit(2, 4);ensurePieChartRendered(["Widget", "Gadget", "Gizmo", "Doohickey"]);- });-- it("should preserve a slice's settings if its row is removed then reappears in the query result", () => {- H.visitQuestionAdhoc({- dataset_query: getLimitedQuery(testQuery, 4),- display: "pie",- });-- ensurePieChartRendered(["Widget", "Gadget", "Gizmo", "Doohickey"]);H.openVizSettingsSidebar();@@ -261,26 +241,6 @@ describe("scenarios > visualizations > pie chart", () => {});});- it("should automatically map dimension columns in query to rings", () => {- H.visitQuestionAdhoc({- dataset_query: twoRingQuery,- display: "pie",- });-- ensurePieChartRendered(- [- "Sunday",- "Monday",- "Tuesday",- "Wednesday",- "Thursday",- "Friday",- "Saturday",- ],- ["Doohickey", "Gadget", "Gizmo", "Widget"],- );- });-it("should allow the user to edit rings", () => {H.visitQuestionAdhoc({dataset_query: threeRingQuery,@@ -347,9 +307,6 @@ describe("scenarios > visualizations > pie chart", () => {H.visitQuestionAdhoc({dataset_query: twoRingQuery,display: "pie",- visualization_settings: {- "pie.slice_threshold": 0,- },});ensurePieChartRendered(diff --git a/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js b/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.jsindex ed33b5d6b2b..8581727e682 100644--- a/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/progress-bar.cy.spec.js@@ -56,72 +56,6 @@ describe("scenarios > visualizations > progress chart", () => {});});- it("should allow value field selection with multiple numeric columns", () => {- const questionDetails = {- name: "Multi-column Progress Test",- query: {- "source-table": ORDERS_ID,- aggregation: [["count"], ["sum", ["field", ORDERS.TOTAL, null]]],- },- display: "progress",- };-- H.createQuestion(questionDetails, { visitQuestion: true });-- // Open visualization settings- H.openVizSettingsSidebar();- H.vizSettingsSidebar().within(() => {- cy.findByText("Display").click();-- // Should show Value field selector since we have multiple numeric columns- cy.findByText("Value").should("be.visible");-- // Default should be first column (Count)- cy.findByDisplayValue("Count").should("be.visible");-- // Change to Sum of Total- cy.findByDisplayValue("Count").click();- });-- H.popover().within(() => {- cy.findByText("Sum of Total").click();- });-- // Verify the field changed- H.vizSettingsSidebar().within(() => {- cy.findByDisplayValue("Sum of Total").should("be.visible");- });- });-- it("should not show value field selector with single numeric column", () => {- const questionDetails = {- name: "Single Column Progress Test",- query: { "source-table": ORDERS_ID, aggregation: [["count"]] },- display: "progress",- };-- H.createQuestion(questionDetails, { visitQuestion: true });-- H.openVizSettingsSidebar();- H.vizSettingsSidebar().within(() => {- cy.findByText("Display").click();-- // Should NOT show Value field selector since we only have one numeric column- cy.findByText("Value").should("not.exist");-- // Goal setting should still be visible with no dropdown since no other columns- cy.findByText("Goal").should("be.visible");-- // No dropdown icon should be visible since there are no other columns for goal- cy.findByPlaceholderText("Enter goal value")- .parent()- .parent()- .within(() => {- cy.icon("chevrondown").should("not.exist");- });- });- });-it("should exclude value column from goal column options and include Custom value option", () => {const questionDetails = {name: "Exclusion Test Progress",@@ -167,11 +101,11 @@ describe("scenarios > visualizations > progress chart", () => {// Goal should show Count selected in the inputH.vizSettingsSidebar().within(() => {- cy.findByText("Count").should("exist");+ cy.findByDisplayValue("Count").should("be.visible");});});- it("should be backwards compatibile", () => {+ it("should be backwards compatible and not show value field selector with single numeric column", () => {// A question with numeric `progress.goal` and no `progress.value` should render a progress bar with the goal valueconst questionDetails = {name: "Backwards Compat Test",@@ -191,9 +125,28 @@ describe("scenarios > visualizations > progress chart", () => {cy.findByText("18,760").should("be.visible");cy.contains("Goal 1,000").should("be.visible");});++ H.openVizSettingsSidebar();+ H.vizSettingsSidebar().within(() => {+ cy.findByText("Display").click();++ // Goal setting should still be visible with no dropdown since no other columns+ cy.findByText("Goal").should("be.visible");++ // Should NOT show Value field selector since we only have one numeric column+ cy.findByText("Value").should("not.exist");++ // No dropdown icon should be visible since there are no other columns for goal+ cy.findByPlaceholderText("Enter goal value")+ .parent()+ .parent()+ .within(() => {+ cy.icon("chevrondown").should("not.exist");+ });+ });});- it("should allow switching between custom value and column reference via dropdown", () => {+ it("should allow value field selection with multiple numeric columns and switching the goal between custom value and column reference via dropdown", () => {const questionDetails = {name: "Custom Value Toggle Test",query: {@@ -209,6 +162,12 @@ describe("scenarios > visualizations > progress chart", () => {H.vizSettingsSidebar().within(() => {cy.findByText("Display").click();+ // Should show Value field selector since we have multiple numeric columns+ cy.findByText("Value").should("be.visible");++ // Default should be first column (Count)+ cy.findByDisplayValue("Count").should("be.visible");+// Initially should show number input with placeholdercy.findByPlaceholderText("Enter goal value").should("be.visible");@@ -221,7 +180,7 @@ describe("scenarios > visualizations > progress chart", () => {// Should now show the column name in a read-only text inputH.vizSettingsSidebar().within(() => {- cy.findByText("Sum of Total").should("exist");+ cy.findByDisplayValue("Sum of Total").should("be.visible");// Click dropdown again to switch back to custom valuecy.findByText("Goal").parent().parent().icon("chevrondown").click();@@ -236,6 +195,18 @@ describe("scenarios > visualizations > progress chart", () => {cy.findByPlaceholderText("Enter goal value").should("exist").should("have.focus");++ // Change value to Sum of Total+ cy.findByDisplayValue("Count").click();+ });++ H.popover().within(() => {+ cy.findByText("Sum of Total").click();+ });++ // Verify the field changed+ H.vizSettingsSidebar().within(() => {+ cy.findByDisplayValue("Sum of Total").should("be.visible");});});diff --git a/e2e/test/scenarios/visualizations/charts/sankey.cy.spec.js b/e2e/test/scenarios/visualizations/charts/sankey.cy.spec.jsindex bf0cf4a33cf..1d270cf918e 100644--- a/e2e/test/scenarios/visualizations/charts/sankey.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/sankey.cy.spec.js@@ -139,59 +139,64 @@ describe("scenarios > visualizations > sankey", () => {H.checkSavedToCollectionQuestionToast();});- [false, true].forEach((devMode) => {- it(`should render sankey charts in dashboard context - development-mode: ${devMode}`, () => {- cy.intercept("/api/session/properties", (req) => {- req.continue((res) => {- res.body["token-features"].development_mode = devMode;- });+ it("should render sankey charts in dashboard context - development-mode: true", () => {+ cy.intercept("/api/session/properties", (req) => {+ req.continue((res) => {+ res.body["token-features"].development_mode = true;});- H.createDashboard({- name: "Sankey Dashboard",- }).then(({ body: dashboard }) => {- H.createNativeQuestion({- name: "Sankey Question",- native: {- query: SANKEY_QUERY,- },- display: "sankey",- visualization_settings: {- "graph.show_values": true,- "graph.label_value_formatting": "compact",+ });+ H.createDashboard({+ name: "Sankey Dashboard",+ }).then(({ body: dashboard }) => {+ H.createNativeQuestion({+ name: "Sankey Question",+ native: {+ query: SANKEY_QUERY,+ },+ display: "sankey",+ visualization_settings: {+ "graph.show_values": true,+ "graph.label_value_formatting": "compact",+ },+ }).then(({ body: card }) => {+ H.addOrUpdateDashboardCard({+ card_id: card.id,+ dashboard_id: dashboard.id,+ card: {+ size_x: 12,+ size_y: 8,},- }).then(({ body: card }) => {- H.addOrUpdateDashboardCard({- card_id: card.id,- dashboard_id: dashboard.id,- card: {- size_x: 12,- size_y: 8,- },- });-- H.visitDashboard(dashboard.id);});++ H.visitDashboard(dashboard.id);});+ });- H.echartsContainer().findByText("Social Media");+ H.getDashboardCard().findByTestId("development-watermark").should("exist");+ H.echartsContainer().findByText("Social Media");- // Ensure drill-through works- H.chartPathWithFillColor("#ED8535").first().click();- H.popover().within(() => {- cy.findByText("=").should("be.visible");- cy.findByText("≠").should("be.visible");+ // Ensure drill-through works+ H.chartPathWithFillColor("#ED8535").first().click();+ H.popover().within(() => {+ cy.findByText("=").should("be.visible");+ cy.findByText("≠").should("be.visible");- cy.findByText("Is Paid Subscription").click();- });+ cy.findByText("Is Paid Subscription").click();+ });- cy.findAllByTestId("filter-pill").should("have.length", 1);- cy.findByTestId("filter-pill").within(() => {- cy.findByText("TARGET is Paid Subscription").should("be.visible");- });+ cy.findAllByTestId("filter-pill").should("have.length", 1);+ cy.findByTestId("filter-pill").within(() => {+ cy.findByText("TARGET is Paid Subscription").should("be.visible");});});- it("should send the clicked node's own value to a mapped dashboard filter for both source and target column mappings (metabase#78113)", () => {+ it("should send the clicked node's own value to a mapped dashboard filter for both source and target column mappings, and drill through from a node (metabase#78113)", () => {+ cy.intercept("/api/session/properties", (req) => {+ req.continue((res) => {+ res.body["token-features"].development_mode = false;+ });+ });+const CROSSFILTER_QUERY = `SELECT 'Start A' AS source, 'Middle X' AS target, 1 AS amountUNION ALL@@ -243,33 +248,52 @@ SELECT 'Middle Y', 'End', 3;"sankey.value": "AMOUNT",},}).then(({ body: card }) => {- H.createDashboard({- name: "Sankey crossfilter dashboard",- parameters: [TEXT_FILTER],- }).then(({ body: dashboard }) => {- H.updateDashboardCards({- dashboard_id: dashboard.id,- cards: [- {- card_id: card.id,- row: 0,- col: 0,- size_x: 12,- size_y: 8,- visualization_settings: crossfilterOn("TARGET"),- },- {- card_id: card.id,- row: 0,- col: 12,- size_x: 12,- size_y: 8,- visualization_settings: crossfilterOn("SOURCE"),- },- ],- });+ H.createNativeQuestion({+ name: "Sankey Question",+ native: {+ query: SANKEY_QUERY,+ },+ display: "sankey",+ visualization_settings: {+ "graph.show_values": true,+ "graph.label_value_formatting": "compact",+ },+ }).then(({ body: drillCard }) => {+ H.createDashboard({+ name: "Sankey crossfilter dashboard",+ parameters: [TEXT_FILTER],+ }).then(({ body: dashboard }) => {+ H.updateDashboardCards({+ dashboard_id: dashboard.id,+ cards: [+ {+ card_id: card.id,+ row: 0,+ col: 0,+ size_x: 12,+ size_y: 8,+ visualization_settings: crossfilterOn("TARGET"),+ },+ {+ card_id: card.id,+ row: 0,+ col: 12,+ size_x: 12,+ size_y: 8,+ visualization_settings: crossfilterOn("SOURCE"),+ },+ {+ card_id: drillCard.id,+ row: 8,+ col: 0,+ size_x: 12,+ size_y: 8,+ },+ ],+ });- H.visitDashboard(dashboard.id);+ H.visitDashboard(dashboard.id);+ });});});@@ -292,5 +316,23 @@ SELECT 'Middle Y', 'End', 3;cy.log("SOURCE mapping: a start node keeps working");clickNode(1, "Start A");cy.location("search").should("eq", "?text_filter=Start+A");++ cy.log("drill through from a node");+ H.getDashboardCard(2).within(() => {+ cy.findByText("Sankey Question").should("be.visible");+ H.echartsContainer().findByText("Social Media");+ H.chartPathWithFillColor("#ED8535").first().click();+ });+ H.popover().within(() => {+ cy.findByText("=").should("be.visible");+ cy.findByText("≠").should("be.visible");++ cy.findByText("Is Paid Subscription").click();+ });++ cy.findAllByTestId("filter-pill").should("have.length", 1);+ cy.findByTestId("filter-pill").within(() => {+ cy.findByText("TARGET is Paid Subscription").should("be.visible");+ });});});diff --git a/e2e/test/scenarios/visualizations/charts/scalar.cy.spec.ts b/e2e/test/scenarios/visualizations/charts/scalar.cy.spec.tsindex a9283168f74..55c9ce23e0c 100644--- a/e2e/test/scenarios/visualizations/charts/scalar.cy.spec.ts+++ b/e2e/test/scenarios/visualizations/charts/scalar.cy.spec.ts@@ -1,9 +1,10 @@const { H } = cy;import Color from "color";+import { SAMPLE_DB_ID } from "e2e/support/cypress_data";import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";-const { ORDERS_ID } = SAMPLE_DATABASE;+const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;describe("scenarios > visualizations > scalar", () => {beforeEach(() => {@@ -55,4 +56,111 @@ describe("scenarios > visualizations > scalar", () => {cy.findByTestId("scalar-value").realHover();H.tooltip().should("contain.text", "≤ 1000").and("contain.text", "≥ 1000");});++ it("should render human readable numbers on every screen size (metabase#12629)", () => {+ // The mobile size sits between two compacted sizes, so each value check runs on a page that showed a different value before.+ const SCREEN_SIZES: [string, [number, number]][] = [+ ["tablet", [900, 600]],+ ["mobile", [600, 400]],+ ["desktop", [1200, 800]],+ ["hd", [1920, 1280]],+ ];++ H.createQuestionAndDashboard({+ questionDetails: {+ name: "12629",+ query: {+ "source-table": ORDERS_ID,+ aggregation: [+ // @ts-expect-error the `Aggregation` type has no arithmetic expressions+ ["*", 1000000, ["sum", ["field", ORDERS.TOTAL, null]]],+ ],+ },+ display: "scalar",+ },+ cardDetails: {+ size_x: 5,+ size_y: 4,+ },+ }).then(({ body: { dashboard_id } }) => {+ SCREEN_SIZES.forEach(([size, [width, height]]) => {+ cy.log(`${size} screen size`);+ cy.viewport(width, height);+ H.visitDashboard(dashboard_id);+ // cards on mobile take up the full viewport width so there is enough room to display the uncompacted value+ // If https://github.com/metabase/metabase/issues/6201 is completed this may change but in this instance showing+ // the uncompacted value for mobile is the expected behaviour.+ H.getDashboardCard()+ .findByText(size === "mobile" ? "1,510,621,683,050.63" : "1.5T")+ .should("be.visible");+ });+ });+ });++ it("should render date without time (metabase#7494)", () => {+ H.visitQuestionAdhoc({+ dataset_query: {+ type: "native",+ native: {+ query: "SELECT cast('2024-05-01T00:00:00Z'::timestamp as date)",+ "template-tags": {},+ },+ database: SAMPLE_DB_ID,+ },+ display: "scalar",+ });++ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("April 30, 2024");+ H.openVizSettingsSidebar();++ H.sidebar().findByText("Date style").should("be.visible");+ H.sidebar().findByText("Show the time").should("be.hidden");+ H.sidebar().findByText("Time style").should("be.hidden");+ });++ it("should not auto-select chart type when opening and saving a native question with parameters that have default values (metabase#33208)", () => {+ 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,+ // @ts-expect-error the `TemplateTag` type allows only a single string default+ default: ["Doohickey", "Gizmo"],+ dimension: ["field", PRODUCTS.CATEGORY, null],+ "widget-type": "string/=",+ },+ },+ },+ display: "scalar",+ },+ { visitQuestion: true },+ );++ // 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");++ 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/charts/smartscalar-trend.cy.spec.jssimilarity index 99%rename from e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.jsrename to e2e/test/scenarios/visualizations/charts/smartscalar-trend.cy.spec.jsindex 8d8f8a6deee..878fd1a6710 100644--- a/e2e/test/scenarios/visualizations/tabular/smartscalar-trend.cy.spec.js+++ b/e2e/test/scenarios/visualizations/charts/smartscalar-trend.cy.spec.js@@ -359,6 +359,7 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {cy.findByText("Sum of Total").should("not.exist");cy.findByText("Previous month").should("exist").click();});+ H.menu().findByText("Previous value").should("be.visible");H.menu().findByText("Value from another column…").should("not.exist");});@@ -565,8 +566,8 @@ describe("scenarios > visualizations > trend chart (SmartScalar)", () => {// check that we can switch visualizations and no longer have the error showH.openVizTypeSidebar();cy.findByTestId("Line-button").click();- cy.icon("warning").should("not.exist");H.cartesianChartCircle().should("have.length", 3);+ cy.icon("warning").should("not.exist");});it("should keep full date granularity for native questions and let users pick a coarser granularity (metabase#69525)", () => {diff --git a/e2e/test/scenarios/visualizations/charts/treemap.cy.spec.ts b/e2e/test/scenarios/visualizations/charts/treemap.cy.spec.tsindex bd4d79317ad..4b0b96ded61 100644--- a/e2e/test/scenarios/visualizations/charts/treemap.cy.spec.ts+++ b/e2e/test/scenarios/visualizations/charts/treemap.cy.spec.ts@@ -24,7 +24,7 @@ describe("scenarios > visualizations > treemap", () => {cy.signInAsNormalUser();});- it("should render and configure a treemap in the query builder", () => {+ it("should render, configure and drill into a treemap in the query builder", () => {H.visitQuestionAdhoc({display: "table",dataset_query: {@@ -61,24 +61,9 @@ describe("scenarios > visualizations > treemap", () => {cy.get("@settings-sidebar").findByText("Show leaf labels").click();H.echartsContainer().should("contain", "Chickpeas");- cy.log("Saving the question works");- cy.findByTestId("qb-save-button").click();- cy.findByPlaceholderText("What is the name of your question?").type(- "My Treemap",- );- cy.findByTestId("save-question-modal").findByText("Save").click();- H.checkSavedToCollectionQuestionToast();- });-- it("should drill into a group and navigate back via the breadcrumb", () => {- H.visitQuestionAdhoc({- display: "treemap",- dataset_query: {- type: "native",- native: { query: TREEMAP_QUERY },- database: SAMPLE_DB_ID,- },- });+ cy.log("Close the settings sidebar");+ H.leftSidebar().button("Done").click();+ cy.findByTestId("chartsettings-sidebar").should("not.exist");cy.log("Overview breadcrumb shows the grand total");treemapBreadcrumb().should("contain", "Total");@@ -104,6 +89,14 @@ describe("scenarios > visualizations > treemap", () => {treemapBreadcrumb().should("contain", "Total");H.echartsContainer().should("contain", "Grains").and("contain", "Nuts");++ cy.log("Saving the question works");+ cy.findByTestId("qb-save-button").click();+ cy.findByPlaceholderText("What is the name of your question?").type(+ "My Treemap",+ );+ cy.findByTestId("save-question-modal").findByText("Save").click();+ H.checkSavedToCollectionQuestionToast();});it("should drill through from a tile", () => {diff --git a/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.js b/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.jsdeleted file mode 100644index 10d3e5b1381..00000000000--- a/e2e/test/scenarios/visualizations/tabular/scalar.cy.spec.js+++ /dev/null@@ -1,126 +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, PRODUCTS } = SAMPLE_DATABASE;--describe("scenarios > visualizations > scalar", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- const SCREEN_SIZES = {- mobile: [600, 400],- tablet: [900, 600],- desktop: [1200, 800],- hd: [1920, 1280],- };-- Object.entries(SCREEN_SIZES).forEach(([size, viewport]) => {- it(`should render human readable numbers on ${size} screen size (metabase`, () => {- const [width, height] = viewport;-- cy.viewport(width, height);- H.createQuestionAndDashboard({- questionDetails: {- name: "12629",- query: {- "source-table": ORDERS_ID,- aggregation: [- ["*", 1000000, ["sum", ["field", ORDERS.TOTAL, null]]],- ],- },- display: "scalar",- },- cardDetails: {- size_x: 5,- size_y: 4,- },- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- // cards on mobile take up the full viewport width so there is enough room to display the uncompacted value- // If https://github.com/metabase/metabase/issues/6201 is completed this may change but in this instance showing- // the uncompacted value for mobile is the expected behaviour.- if (size === "mobile") {- cy.findByText("1,510,621,683,050.63");- } else {- cy.findByText("1.5T");- }- });- });- });-- it("should render date without time (metabase#7494)", () => {- H.visitQuestionAdhoc({- dataset_query: {- type: "native",- native: {- query: "SELECT cast('2024-05-01T00:00:00Z'::timestamp as date)",- "template-tags": {},- },- database: SAMPLE_DB_ID,- },- display: "scalar",- });-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("April 30, 2024");- H.openVizSettingsSidebar();-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Show the time").should("be.hidden");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.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");- });- });-});