Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

e2e2unit: Binning reproductions follow up (#85302)

Nemanja Glumac23f8d7ddef3e
diff --git a/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js b/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
index df8b48f8c6f..1003001678d 100644
--- a/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
@@ -4,6 +4,15 @@ import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
+const CREATED_AT_DAY_OF_WEEK_BREAKOUT = [
+ "field",
+ ORDERS.CREATED_AT,
+ {
+ "base-type": "type/DateTime",
+ "temporal-unit": "day-of-week",
+ },
+];
+
describe("binning related reproductions", () => {
beforeEach(() => {
H.restore();
@@ -65,4 +74,39 @@ describe("binning related reproductions", () => {
H.cartesianChartCircle().should("have.length.greaterThan", 1);
});
+
+ it("can drill through question with temporal extraction breakout without semantic type defined for the column (metabase#23851)", () => {
+ cy.log("Reproduces metabase#23851");
+ cy.intercept("POST", "/api/dataset").as("dataset");
+ cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {
+ semantic_type: null,
+ });
+ H.createQuestion(
+ {
+ query: {
+ "source-table": ORDERS_ID,
+ aggregation: [["count"]],
+ breakout: [CREATED_AT_DAY_OF_WEEK_BREAKOUT],
+ },
+ display: "bar",
+ },
+ { visitQuestion: true },
+ );
+
+ H.chartPathWithFillColor("#509EE3").should("have.length", 7);
+ H.chartPathWithFillColor("#509EE3").eq(5).click();
+ H.popover().findByText("See these Orders").click();
+
+ cy.wait("@dataset");
+
+ cy.findByTestId("filter-pill").should(
+ "have.text",
+ "Created At: Day of week is equal to 6",
+ );
+ cy.findAllByTestId("cell-data").should("contain", "37.65"); // might change based on a year
+ H.openNotebook();
+ H.getNotebookStep("filter")
+ .findByText("Created At: Day of week is equal to 6")
+ .should("exist");
+ });
});
diff --git a/e2e/test/scenarios/binning/reproductions/23851-drill-temporal-extraction.cy.spec.js b/e2e/test/scenarios/binning/reproductions/23851-drill-temporal-extraction.cy.spec.js
deleted file mode 100644
index 352228e6318..00000000000
--- a/e2e/test/scenarios/binning/reproductions/23851-drill-temporal-extraction.cy.spec.js
+++ /dev/null
@@ -1,54 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
-
-const CREATED_AT_BREAKOUT = [
- "field",
- ORDERS.CREATED_AT,
- {
- "base-type": "type/DateTime",
- "temporal-unit": "day-of-week",
- },
-];
-
-describe("issue 23851", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("can drill through question with temporal extraction breakout without semantic type defined for the column (metabase#23851)", () => {
- cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {
- semantic_type: null,
- });
- H.createQuestion(
- {
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [CREATED_AT_BREAKOUT],
- },
- display: "bar",
- },
- { visitQuestion: true },
- );
-
- H.chartPathWithFillColor("#509EE3").should("have.length", 7);
- H.chartPathWithFillColor("#509EE3").eq(5).click();
- H.popover().findByText("See these Orders").click();
-
- cy.wait("@dataset");
-
- cy.findByTestId("filter-pill").should(
- "have.text",
- "Created At: Day of week is equal to 6",
- );
- cy.findAllByTestId("cell-data").should("contain", "37.65"); // might change based on a year
- H.openNotebook();
- H.getNotebookStep("filter")
- .findByText("Created At: Day of week is equal to 6")
- .should("exist");
- });
-});
diff --git a/e2e/test/scenarios/binning/reproductions/34688-34690-time-series-footer.cy.spec.js b/e2e/test/scenarios/binning/reproductions/34688-34690-time-series-footer.cy.spec.js
deleted file mode 100644
index 3e3e93afc8f..00000000000
--- a/e2e/test/scenarios/binning/reproductions/34688-34690-time-series-footer.cy.spec.js
+++ /dev/null
@@ -1,60 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;
-
-const CREATED_AT_BREAKOUT = [
- "field",
- PRODUCTS.CREATED_AT,
- {
- "base-type": "type/DateTime",
- "temporal-unit": "month",
- },
-];
-
-const CUSTOM_COLUMN_BREAKOUT = [
- "expression",
- "Custom column",
- { "base-type": "type/Text" },
-];
-
-const ID_FIELD_REF = ["field", PRODUCTS.ID, { "base-type": "type/BigInteger" }];
-
-const BASE_QUERY = {
- "source-table": PRODUCTS_ID,
- expressions: {
- "Custom column": [
- "case",
- [[["<", ID_FIELD_REF, 10], "Foo"]],
- { default: "Bar" },
- ],
- },
- aggregation: [["count"]],
-};
-
-describe("issues 34688 and 34690", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("shows time series footer with a category breakout before or after the temporal one (metabase#34688, metabase#34690)", () => {
- [
- [CUSTOM_COLUMN_BREAKOUT, CREATED_AT_BREAKOUT],
- [CREATED_AT_BREAKOUT, CUSTOM_COLUMN_BREAKOUT],
- ].forEach((breakout) => {
- H.createQuestion(
- {
- database: SAMPLE_DB_ID,
- type: "query",
- query: { ...BASE_QUERY, breakout },
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("timeseries-filter-button").should("exist");
- cy.findByTestId("timeseries-bucket-button").should("exist");
- });
- });
-});
diff --git a/frontend/src/metabase/querying/filters/components/TimeseriesChrome/TimeseriesChrome.unit.spec.tsx b/frontend/src/metabase/querying/filters/components/TimeseriesChrome/TimeseriesChrome.unit.spec.tsx
index fe9c74509fe..facd37a551c 100644
--- a/frontend/src/metabase/querying/filters/components/TimeseriesChrome/TimeseriesChrome.unit.spec.tsx
+++ b/frontend/src/metabase/querying/filters/components/TimeseriesChrome/TimeseriesChrome.unit.spec.tsx
@@ -8,8 +8,13 @@ import {
SAMPLE_PROVIDER,
} from "metabase-lib/test-helpers";
import Question from "metabase-lib/v1/Question";
+import type { TestBreakoutSpec } from "metabase-types/api";
import { createMockCard } from "metabase-types/api/mocks";
-import { ORDERS, ORDERS_ID } from "metabase-types/api/mocks/presets";
+import {
+ ORDERS,
+ ORDERS_ID,
+ PRODUCTS_ID,
+} from "metabase-types/api/mocks/presets";
import { TimeseriesChrome } from "./TimeseriesChrome";
@@ -69,6 +74,57 @@ describe("TimeseriesChrome", () => {
expect(screen.queryByText("View")).not.toBeInTheDocument();
});
+ it.each<{ title: string; breakouts: TestBreakoutSpec[] }>([
+ {
+ title: "before",
+ breakouts: [
+ { type: "column", name: "Custom column" },
+ { type: "column", name: "CREATED_AT", unit: "month" },
+ ],
+ },
+ {
+ title: "after",
+ breakouts: [
+ { type: "column", name: "CREATED_AT", unit: "month" },
+ { type: "column", name: "Custom column" },
+ ],
+ },
+ ])(
+ "should render the chrome with a custom column breakout $title the temporal one (metabase#34688, metabase#34690)",
+ ({ breakouts }) => {
+ const query = Lib.createTestQuery(SAMPLE_PROVIDER, {
+ stages: [
+ {
+ source: { type: "table", id: PRODUCTS_ID },
+ expressions: [
+ {
+ name: "Custom column",
+ value: {
+ type: "operator",
+ operator: "concat",
+ args: [
+ { type: "column", name: "TITLE" },
+ { type: "literal", value: "!" },
+ ],
+ },
+ },
+ ],
+ aggregations: [{ type: "operator", operator: "count", args: [] }],
+ breakouts,
+ },
+ ],
+ });
+ setup({ query });
+
+ expect(
+ screen.getByTestId("timeseries-filter-button"),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId("timeseries-bucket-button")).toHaveTextContent(
+ "Month",
+ );
+ },
+ );
+
it("should allow to change the temporal unit for a breakout", async () => {
const query = Lib.createTestQuery(SAMPLE_PROVIDER, {
stages: [