Skip to content

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

Remove querying e2e tests made redundant by backend test parity

Fraser4701e5f8dc54
diff --git a/e2e/test/scenarios/binning/binning-options.cy.spec.js b/e2e/test/scenarios/binning/binning-options.cy.spec.js
index a18a9c37971..1baec0900a0 100644
--- a/e2e/test/scenarios/binning/binning-options.cy.spec.js
+++ b/e2e/test/scenarios/binning/binning-options.cy.spec.js
@@ -1,51 +1,7 @@
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, PEOPLE_ID, PEOPLE, PRODUCTS_ID, PRODUCTS } =
- SAMPLE_DATABASE;
-
-const ordersJoinPeopleQuery = {
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People" }],
- ],
- alias: "People",
- },
- ],
- fields: [["field", ORDERS.ID, null]],
- },
- database: SAMPLE_DB_ID,
-};
-
-const ordersJoinProductsQuery = {
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- fields: [["field", ORDERS.ID, null]],
- },
- database: SAMPLE_DB_ID,
-};
+const { ORDERS_ID, PEOPLE_ID } = SAMPLE_DATABASE;
const NUMBER_BUCKETS = [
"Auto bin",
@@ -208,74 +164,6 @@ describe("scenarios > binning > binning options", () => {
});
});
});
-
- context("implicit joins (metabase#16674)", { tags: "@skip" }, () => {
- it("should work for time series", () => {
- chooseInitialBinningOption({
- table: ORDERS_ID,
- column: "Birth Date",
- });
-
- openBinningListForDimension("Birth Date", "by month");
- getAllOptions({ options: TIME_BUCKETS, isSelected: "Month" });
- });
-
- it("should work for number", () => {
- chooseInitialBinningOption({
- table: ORDERS_ID,
- column: "Price",
- });
-
- openBinningListForDimension("Price", "Auto binned");
- getAllOptions({ options: NUMBER_BUCKETS, isSelected: "Auto bin" });
- });
-
- it("should work for longitude", () => {
- chooseInitialBinningOption({
- table: ORDERS_ID,
- column: "Longitude",
- });
-
- openBinningListForDimension("Longitude", "Auto binned");
- getAllOptions({ options: LONGITUDE_BUCKETS, isSelected: "Auto bin" });
- });
- });
-
- context("explicit joins (metabase#16675)", { tags: "@skip" }, () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should work for time series", () => {
- chooseInitialBinningOptionForExplicitJoin({
- baseTableQuery: ordersJoinPeopleQuery,
- column: "Birth Date",
- });
-
- openBinningListForDimension("Birth Date", "by month");
- getAllOptions({ options: TIME_BUCKETS, isSelected: "Month" });
- });
-
- it("should work for number", () => {
- chooseInitialBinningOptionForExplicitJoin({
- baseTableQuery: ordersJoinProductsQuery,
- column: "Price",
- });
-
- openBinningListForDimension("Price", "Auto binned");
- getAllOptions({ options: NUMBER_BUCKETS, isSelected: "Auto bin" });
- });
-
- it("should work for longitude", () => {
- chooseInitialBinningOptionForExplicitJoin({
- baseTableQuery: ordersJoinPeopleQuery,
- column: "Longitude",
- });
-
- openBinningListForDimension("Longitude", "Auto binned");
- getAllOptions({ options: LONGITUDE_BUCKETS, isSelected: "Auto bin" });
- });
- });
});
function chooseInitialBinningOption({ table, column, mode = null } = {}) {
@@ -291,20 +179,6 @@ function chooseInitialBinningOption({ table, column, mode = null } = {}) {
}
}
-function chooseInitialBinningOptionForExplicitJoin({
- baseTableQuery,
- column,
-} = {}) {
- H.visitQuestionAdhoc({ dataset_query: baseTableQuery });
-
- H.summarize();
-
- cy.findByTestId("sidebar-right").within(() => {
- cy.findByText("Count"); // Test fails without this because of some weird race condition
- cy.findByText(column).click();
- });
-}
-
function openBinningListForDimension(column, binning) {
H.getBinningButtonForDimension({ name: column, isSelected: true })
.should("contain", binning)
diff --git a/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js b/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
index 1fd4ed28bcf..11d5dedb379 100644
--- a/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/binning/binning-reproductions.cy.spec.js
@@ -250,133 +250,4 @@ describe("binning related reproductions", () => {
cy.findByText("June 2025");
});
});
-
- describe("binning should work on nested question based on question that has aggregation (metabase#16379)", () => {
- beforeEach(() => {
- H.createQuestion(
- {
- name: "16379",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["avg", ["field", ORDERS.SUBTOTAL, null]]],
- breakout: [["field", ORDERS.USER_ID, null]],
- },
- },
- { visitQuestion: true },
- );
- });
-
- it("should work for simple mode", () => {
- openSummarizeOptions("Simple mode");
-
- H.changeBinningForDimension({
- name: "Average of Subtotal",
- fromBinning: "Auto bin",
- toBinning: "10 bins",
- });
-
- H.chartPathWithFillColor("#509EE3");
- });
-
- it("should work for notebook mode", () => {
- openSummarizeOptions("Notebook mode");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a function or metric").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count of rows").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
-
- H.changeBinningForDimension({
- name: "Average of Subtotal",
- fromBinning: "Auto bin",
- toBinning: "10 bins",
- });
-
- H.visualize();
-
- H.chartPathWithFillColor("#509EE3");
- });
- });
-
- describe("result metadata issues", { tags: "@skip" }, () => {
- /**
- * Issues that arise only when we save SQL question without running it first.
- * It doesn't load the necessary metadata, which results in the wrong binning results.
- *
- * Fixing the underlying issue with `result_metadata` will most likely fix all three issues reproduced here.
- * Unskip the whole `describe` block once the fix is ready.
- */
-
- beforeEach(() => {
- // This query is the equivalent of saving the question without running it first.
- H.createNativeQuestion({
- name: "SQL Binning",
- native: {
- query:
- "SELECT ORDERS.CREATED_AT, ORDERS.TOTAL, PEOPLE.LONGITUDE FROM ORDERS JOIN PEOPLE ON orders.user_id = people.id",
- },
- });
-
- H.startNewQuestion();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Saved Questions").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("SQL Binning").click();
-
- H.visualize();
- H.summarize();
- });
-
- it("should render number auto binning correctly (metabase#16670)", () => {
- cy.findByTestId("sidebar-right").within(() => {
- cy.findByText("TOTAL").click();
- });
-
- cy.wait("@dataset");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by TOTAL: Auto binned");
- cy.get(".bar").should("have.length.of.at.most", 10);
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("-60");
- });
-
- it("should render time series auto binning default bucket correctly (metabase#16671)", () => {
- H.getBinningButtonForDimension({ name: "CREATED_AT" }).should(
- "have.text",
- "by month",
- );
- });
-
- it("should work for longitude (metabase#16672)", () => {
- cy.findByTestId("sidebar-right").within(() => {
- cy.findByText("LONGITUDE").click();
- });
-
- cy.wait("@dataset").then((xhr) => {
- expect(xhr.response.body.error).not.to.exist;
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by LONGITUDE: Auto binned");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("170° W");
- });
- });
});
-
-function openSummarizeOptions(questionType) {
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("16379").click();
- });
-
- if (questionType === "Simple mode") {
- H.visualize();
- H.summarize();
- }
-}
diff --git a/e2e/test/scenarios/binning/qb-explicit-joins.cy.spec.js b/e2e/test/scenarios/binning/qb-explicit-joins.cy.spec.js
deleted file mode 100644
index 7ef658ef3dc..00000000000
--- a/e2e/test/scenarios/binning/qb-explicit-joins.cy.spec.js
+++ /dev/null
@@ -1,318 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { ORDERS_ID, ORDERS, PEOPLE_ID, PEOPLE, PRODUCTS_ID, PRODUCTS } =
- SAMPLE_DATABASE;
-
-/**
- * The list of issues this spec covers:
- * - metabase#15446
- * -
- */
-describe("scenarios > binning > from a saved QB question with explicit joins", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.createQuestion({
- name: "QB Binning",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: [
- ["field", PEOPLE.LONGITUDE, { "join-alias": "People" }],
- [
- "field",
- PEOPLE.BIRTH_DATE,
- { "temporal-unit": "default", "join-alias": "People" },
- ],
- ],
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People" }],
- ],
- alias: "People",
- },
- {
- fields: [["field", PRODUCTS.PRICE, { "join-alias": "Products" }]],
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- fields: [["field", ORDERS.ID, null]],
- },
- });
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- context("via simple mode", () => {
- beforeEach(() => {
- H.startNewQuestion();
-
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("QB Binning").click();
- });
-
- H.visualize();
- H.summarize();
- });
-
- it("should work for time series", () => {
- H.changeBinningForDimension({
- name: "People → Birth Date",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- assertQueryBuilderState({
- columnType: "time",
- title: "Count by People → Birth Date: Year",
- values: ["1964", "1971", "1999"],
- });
-
- // Make sure time series footer works as well
- cy.findByTestId("timeseries-bucket-button").contains("Year").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quarter").click();
-
- cy.wait("@dataset");
- H.echartsContainer().get("text").should("contain", "Q1");
- });
-
- it("should work for number", () => {
- H.changeBinningForDimension({
- name: "Products → Price",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- assertQueryBuilderState({
- title: "Count by Products → Price: 50 bins",
- values: ["14", "20", "24", "100"],
- });
- });
-
- it("should work for longitude", () => {
- H.changeBinningForDimension({
- name: "People → Longitude",
- fromBinning: "Auto bin",
- toBinning: "Bin every 20 degrees",
- });
-
- assertQueryBuilderState({
- title: "Count by People → Longitude: 20°",
- values: ["180° W", "160° W", "60° W"],
- });
- });
- });
-
- context("via notebook mode", () => {
- beforeEach(() => {
- H.startNewQuestion();
-
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("QB Binning").click();
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a function or metric").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count of rows").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
- });
-
- it("should work for time series", () => {
- H.changeBinningForDimension({
- name: "People → Birth Date",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- assertQueryBuilderState({
- columnType: "time",
- mode: "notebook",
- title: "Count by People → Birth Date: Year",
- values: ["1964", "1971", "1999"],
- });
-
- // Make sure time series footer works as well
- cy.findByTestId("timeseries-bucket-button").contains("Year").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quarter").click();
-
- cy.wait("@dataset");
- H.echartsContainer()
- .get("text")
- .should("contain", "Q1 1965")
- .and("contain", "Q1 1972")
- .and("contain", "Q1 2000");
- });
-
- it("should work for number", () => {
- H.changeBinningForDimension({
- name: "Products → Price",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- assertQueryBuilderState({
- mode: "notebook",
- title: "Count by Products → Price: 50 bins",
- values: ["14", "20", "24", "100"],
- });
- });
-
- it("should work for longitude", () => {
- H.changeBinningForDimension({
- name: "People → Longitude",
- fromBinning: "Auto bin",
- toBinning: "Bin every 20 degrees",
- });
-
- assertQueryBuilderState({
- mode: "notebook",
- title: "Count by People → Longitude: 20°",
- values: ["180° W", "160° W", "60° W"],
- });
- });
- });
-
- context("via column popover", () => {
- beforeEach(() => {
- H.startNewQuestion();
-
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("QB Binning").click();
- });
-
- H.visualize();
- });
-
- it("should work for time series", () => {
- H.tableHeaderClick("People → Birth Date");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- // Reproduces metabase#16693
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by People → Birth Date: Month");
-
- assertOnXYAxisLabels({ xLabel: "People → Birth Date", yLabel: "Count" });
-
- H.echartsContainer()
- .get("text", { timeout: 1000 })
- .should("contain", "January");
-
- H.cartesianChartCircle();
-
- // Make sure time series footer works as well
- cy.findByTestId("timeseries-bucket-button").contains("Month").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quarter").click();
-
- // Reproduces metabase#16693
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by People → Birth Date: Quarter");
-
- H.echartsContainer().get("text").should("contain", "Q1");
- });
-
- it("should work for number", () => {
- H.tableHeaderClick("Products → Price");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- // Reproduces metabase#16693
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by Products → Price: Auto binned");
-
- assertOnXYAxisLabels({ xLabel: "Products → Price", yLabel: "Count" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("12.5");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("25");
-
- H.chartPathWithFillColor("#509EE3");
- });
-
- it("should work for longitude", () => {
- H.tableHeaderClick("People → Longitude");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- // Reproduces metabase#16693
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by People → Longitude: Auto binned");
-
- assertOnXYAxisLabels({
- xLabel: "People → Longitude",
- yLabel: "Count",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("170° W");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("160° W");
-
- H.chartPathWithFillColor("#509EE3");
- });
- });
-});
-
-function assertOnXYAxisLabels({ xLabel, yLabel } = {}) {
- H.echartsContainer().get("text").contains(xLabel);
-
- H.echartsContainer().get("text").contains(yLabel);
-}
-
-function waitAndAssertOnRequest(requestAlias) {
- cy.wait(requestAlias).then((xhr) => {
- expect(xhr.response.body.error).to.not.exist;
- });
-}
-
-function assertQueryBuilderState({
- columnType,
- title,
- mode = null,
- values,
-} = {}) {
- if (mode === "notebook") {
- H.visualize();
- } else {
- waitAndAssertOnRequest("@dataset");
- }
-
- const visualizationSelector = columnType === "time" ? "circle" : "bar";
-
- if (visualizationSelector === "circle") {
- H.cartesianChartCircle();
- } else {
- H.chartPathWithFillColor("#509EE3");
- }
-
- cy.findByText(title);
-
- H.echartsContainer().get("text").should("contain", "Count");
-
- if (values) {
- H.echartsContainer().within(() => {
- values.forEach((value) => {
- cy.findByText(value);
- });
- });
- }
-}
diff --git a/e2e/test/scenarios/binning/qb-implicit-joins.cy.spec.js b/e2e/test/scenarios/binning/qb-implicit-joins.cy.spec.js
deleted file mode 100644
index fe8e212a72e..00000000000
--- a/e2e/test/scenarios/binning/qb-implicit-joins.cy.spec.js
+++ /dev/null
@@ -1,168 +0,0 @@
-const { H } = cy;
-import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
-
-/**
- * The list of issues this spec covers:
- * - metabase#15648
- * -
- */
-
-describe("scenarios > binning > from a saved QB question using implicit joins", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- context("via simple question", () => {
- beforeEach(() => {
- H.visitQuestion(ORDERS_QUESTION_ID);
- H.summarize();
- });
-
- it("should work for time series", () => {
- H.changeBinningForDimension({
- name: "Birth Date",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- assertQueryBuilderState({
- title: "Count by User → Birth Date: Year",
- values: ["1958", "313"],
- });
-
- // Make sure time series assertQueryBuilderState works as well
- cy.findByTestId("timeseries-bucket-button").contains("Year").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Month").click();
-
- cy.get("[data-testid=cell-data]")
- .should("contain", "April 1958")
- .and("contain", "37");
- });
-
- it("should work for number", () => {
- H.changeBinningForDimension({
- name: "Price",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- assertQueryBuilderState({
- title: "Count by Product → Price: 50 bins",
- values: ["14 – 16", "96"],
- });
- });
-
- it("should work for longitude", () => {
- H.changeBinningForDimension({
- name: "Longitude",
- fromBinning: "Auto bin",
- toBinning: "Bin every 20 degrees",
- });
-
- assertQueryBuilderState({
- title: "Count by User → Longitude: 20°",
- values: ["180° W – 160° W", "75"],
- });
- });
- });
-
- context("via custom question", () => {
- beforeEach(() => {
- cy.visit(`/question/${ORDERS_QUESTION_ID}/notebook`);
- H.summarize({ mode: "notebook" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count of rows").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
- // Click "Order" accordion to collapse it and expose the other tables
- H.popover().findByText("Orders").click();
- });
-
- it("should work for time series", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("User").click();
- cy.findByPlaceholderText("Find...").type("birth");
-
- H.changeBinningForDimension({
- name: "Birth Date",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- assertQueryBuilderState({
- title: "Count by User → Birth Date: Year",
- mode: "notebook",
- values: ["1958", "313"],
- });
-
- // Make sure time series assertQueryBuilderStateter works as well
- cy.findByTestId("timeseries-bucket-button").contains("Year").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Month").click();
-
- cy.get("[data-testid=cell-data]")
- .should("contain", "April 1958")
- .and("contain", "37");
- });
-
- it("should work for number", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Product").click();
-
- H.changeBinningForDimension({
- name: "Price",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- assertQueryBuilderState({
- title: "Count by Product → Price: 50 bins",
- mode: "notebook",
- values: ["14 – 16", "96"],
- });
- });
-
- it("should work for longitude", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("User").click();
- cy.findByPlaceholderText("Find...").type("longitude");
-
- H.changeBinningForDimension({
- name: "Longitude",
- fromBinning: "Auto bin",
- toBinning: "Bin every 20 degrees",
- });
-
- assertQueryBuilderState({
- title: "Count by User → Longitude: 20°",
- mode: "notebook",
- values: ["180° W – 160° W", "75"],
- });
- });
- });
-});
-
-function waitAndAssertOnRequest(requestAlias) {
- cy.wait(requestAlias).then((xhr) => {
- expect(xhr.response.body.error).to.not.exist;
- });
-}
-
-function assertQueryBuilderState({ title, mode = null, values } = {}) {
- const [firstValue, lastValue] = values;
-
- if (mode === "notebook") {
- H.visualize();
- } else {
- waitAndAssertOnRequest("@dataset");
- }
-
- cy.findByText(title);
- cy.get("[data-testid=cell-data]")
- .should("contain", firstValue)
- .and("contain", lastValue);
-}
diff --git a/e2e/test/scenarios/binning/sql.cy.spec.js b/e2e/test/scenarios/binning/sql.cy.spec.js
deleted file mode 100644
index 80e3d54a5d6..00000000000
--- a/e2e/test/scenarios/binning/sql.cy.spec.js
+++ /dev/null
@@ -1,239 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
-
-const questionDetails = {
- name: "SQL Binning",
- native: {
- query:
- "SELECT ORDERS.CREATED_AT, ORDERS.TOTAL, PEOPLE.LONGITUDE FROM ORDERS JOIN PEOPLE ON orders.user_id = people.id",
- },
-};
-
-let questionId;
-
-describe("scenarios > binning > from a saved sql question", () => {
- before(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion(questionDetails, {
- loadMetadata: true,
- wrapId: true,
- });
-
- cy.get("@questionId").then((id) => (questionId = id));
-
- H.snapshot("binningSql");
- });
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore("binningSql");
- cy.signInAsAdmin();
- });
-
- context("via simple question", () => {
- beforeEach(() => {
- H.openTable({
- database: SAMPLE_DB_ID,
- table: `card__${questionId}`,
- mode: "notebook",
- });
-
- H.visualize();
- cy.findByTextEnsureVisible("LONGITUDE");
- H.summarize();
- });
-
- it("should work for time series", () => {
- /*
- * If `result_metadata` is not loaded (SQL question is not run before saving),
- * the granularity is much finer and one can see "by minute" as the default bucket (metabase#16671).
- */
- H.changeBinningForDimension({
- name: "CREATED_AT",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- waitAndAssertOnRequest("@dataset");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by CREATED_AT: Year");
- H.cartesianChartCircle();
- });
-
- it("should work for number", () => {
- H.changeBinningForDimension({
- name: "TOTAL",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- waitAndAssertOnRequest("@dataset");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by TOTAL: 50 bins");
- H.chartPathWithFillColor("#509EE3");
- });
-
- it("should work for longitude", () => {
- H.changeBinningForDimension({
- name: "LONGITUDE",
- fromBinning: "Auto bin",
- toBinning: "Bin every 10 degrees",
- });
-
- waitAndAssertOnRequest("@dataset");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by LONGITUDE: 10°");
- H.chartPathWithFillColor("#509EE3");
- });
- });
-
- context("via custom question", () => {
- beforeEach(() => {
- H.visitQuestionAdhoc(
- {
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${questionId}`,
- aggregation: [["count"]],
- },
- },
- },
- { mode: "notebook" },
- );
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Summarize").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
- });
-
- it("should work for time series", () => {
- H.changeBinningForDimension({
- name: "CREATED_AT",
- fromBinning: "by month",
- toBinning: "Year",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by CREATED_AT: Year");
-
- H.visualize((response) => {
- assertOnResponse(response);
- });
-
- H.cartesianChartCircle();
- });
-
- it("should work for number", () => {
- H.changeBinningForDimension({
- name: "TOTAL",
- fromBinning: "Auto bin",
- toBinning: "50 bins",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by TOTAL: 50 bins");
-
- H.visualize((response) => {
- assertOnResponse(response);
- });
-
- H.chartPathWithFillColor("#509EE3");
- });
-
- it("should work for longitude", () => {
- H.changeBinningForDimension({
- name: "LONGITUDE",
- fromBinning: "Auto bin",
- toBinning: "Bin every 10 degrees",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by LONGITUDE: 10°");
-
- H.visualize((response) => {
- assertOnResponse(response);
- });
-
- H.chartPathWithFillColor("#509EE3");
- });
- });
-
- context("via column popover", () => {
- beforeEach(() => {
- H.openTable({
- database: SAMPLE_DB_ID,
- table: `card__${questionId}`,
- });
- cy.findByTextEnsureVisible("LONGITUDE");
- });
-
- it("should work for time series", () => {
- H.tableHeaderClick("CREATED_AT");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- assertOnXYAxisLabels({ xLabel: "CREATED_AT", yLabel: "Count" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by CREATED_AT: Month");
- H.cartesianChartCircle();
-
- // Open a popover with bucket options from the time series footer
- cy.findByTestId("timeseries-bucket-button").contains("Month").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quarter").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by CREATED_AT: Quarter");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Q1 2026");
- });
-
- it("should work for number", () => {
- H.tableHeaderClick("TOTAL");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- assertOnXYAxisLabels({ xLabel: "TOTAL", yLabel: "Count" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by TOTAL: Auto binned");
- H.chartPathWithFillColor("#509EE3");
- });
-
- it("should work for longitude", () => {
- H.tableHeaderClick("LONGITUDE");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distribution").click();
-
- assertOnXYAxisLabels({ xLabel: "LONGITUDE", yLabel: "Count" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count by LONGITUDE: Auto binned");
- H.chartPathWithFillColor("#509EE3");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("170° W");
- });
- });
-});
-
-function assertOnXYAxisLabels({ xLabel, yLabel } = {}) {
- H.echartsContainer().get("text").contains(xLabel);
-
- H.echartsContainer().get("text").contains(yLabel);
-}
-
-function waitAndAssertOnRequest(requestAlias) {
- cy.wait(requestAlias).then(({ response }) => {
- assertOnResponse(response);
- });
-}
-
-function assertOnResponse(response) {
- expect(response.body.error).to.not.exist;
-}
diff --git a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
index 12768b7182a..8306b78b11d 100644
--- a/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
+++ b/e2e/test/scenarios/custom-column/cc-boolean-functions.cy.spec.ts
@@ -7,8 +7,7 @@ import type {
import type { CardId, DashboardParameterMapping } from "metabase-types/api";
import { createMockDashboardCard } from "metabase-types/api/mocks";
-const { ORDERS_ID, ORDERS, PEOPLE_ID, PEOPLE, PRODUCTS_ID, PRODUCTS } =
- SAMPLE_DATABASE;
+const { PEOPLE_ID, PEOPLE, PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;
describe("scenarios > custom column > boolean functions", () => {
const expressionName = "Boolean column";
@@ -17,184 +16,6 @@ describe("scenarios > custom column > boolean functions", () => {
H.restore();
cy.signInAsNormalUser();
cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("PUT", "/api/card/*").as("updateCard");
- });
-
- describe("expression editor", () => {
- const stringQuestionColumns = ["Category"];
- const stringQuestionDetails: StructuredQuestionDetails = {
- query: {
- "source-table": PRODUCTS_ID,
- fields: [["field", PRODUCTS.CATEGORY, null]],
- "order-by": [["asc", ["field", PRODUCTS.ID, null]]],
- limit: 1,
- },
- };
-
- const numberQuestionColumns = ["Total"];
- const numberQuestionDetails: StructuredQuestionDetails = {
- query: {
- "source-table": ORDERS_ID,
- fields: [["field", ORDERS.TOTAL, null]],
- "order-by": [["asc", ["field", ORDERS.ID, null]]],
- limit: 1,
- },
- };
-
- const dateQuestionColumns = ["Created At"];
- const dateQuestionDetails: StructuredQuestionDetails = {
- query: {
- "source-table": ORDERS_ID,
- fields: [["field", ORDERS.CREATED_AT, null]],
- "order-by": [["asc", ["field", ORDERS.CREATED_AT, null]]],
- limit: 1,
- },
- };
-
- function testExpression({
- questionDetails,
- questionColumns,
- newExpression,
- newExpressionRows,
- modifiedExpression,
- modifiedExpressionRows,
- }: {
- questionDetails: StructuredQuestionDetails;
- questionColumns: string[];
- newExpression: string;
- newExpressionRows: string[][];
- modifiedExpression: string;
- modifiedExpressionRows: string[][];
- }) {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- cy.log("add a new custom column");
- H.openNotebook();
- H.getNotebookStep("data").button("Custom column").click();
- H.enterCustomColumnDetails({
- formula: newExpression,
- name: expressionName,
- allowFastSet: true,
- format: true,
- });
- H.popover().button("Done").click();
- H.visualize();
- cy.wait("@dataset");
- H.assertTableData({
- columns: [...questionColumns, expressionName],
- firstRows: newExpressionRows,
- });
-
- cy.log("modify an existing custom column");
- H.openNotebook();
- H.getNotebookStep("expression").findByText(expressionName).click();
- H.enterCustomColumnDetails({
- formula: modifiedExpression,
- name: expressionName,
- allowFastSet: true,
- });
- H.popover().button("Update").click();
- H.visualize();
- cy.wait("@dataset");
- H.assertTableData({
- columns: [...questionColumns, expressionName],
- firstRows: modifiedExpressionRows,
- });
-
- cy.log("assert that the question can be saved");
- H.queryBuilderHeader().button("Save").click();
- H.modal().button("Save").click();
- cy.wait("@updateCard");
- H.queryBuilderHeader().button("Save").should("not.exist");
- }
-
- it("isNull", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: "isNull([Category])",
- newExpressionRows: [["Gizmo", "false"]],
- modifiedExpression: "notNull([Category])",
- modifiedExpressionRows: [["Gizmo", "true"]],
- });
- });
-
- it("isEmpty", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: "isEmpty([Category])",
- newExpressionRows: [["Gizmo", "false"]],
- modifiedExpression: "notEmpty([Category])",
- modifiedExpressionRows: [["Gizmo", "true"]],
- });
- });
-
- it("startsWith", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: 'startsWith([Category], "Gi")',
- newExpressionRows: [["Gizmo", "true"]],
- modifiedExpression: 'startsWith([Category], "mo")',
- modifiedExpressionRows: [["Gizmo", "false"]],
- });
- });
-
- it("endsWith", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: 'endsWith([Category], "Gi")',
- newExpressionRows: [["Gizmo", "false"]],
- modifiedExpression: 'endsWith([Category], "mo")',
- modifiedExpressionRows: [["Gizmo", "true"]],
- });
- });
-
- it("contains", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: 'contains([Category], "zm")',
- newExpressionRows: [["Gizmo", "true"]],
- modifiedExpression: 'contains([Category], "mz")',
- modifiedExpressionRows: [["Gizmo", "false"]],
- });
- });
-
- it("doesNotContain", () => {
- testExpression({
- questionDetails: stringQuestionDetails,
- questionColumns: stringQuestionColumns,
- newExpression: 'doesNotContain([Category], "zm")',
- newExpressionRows: [["Gizmo", "false"]],
- modifiedExpression: 'doesNotContain([Category], "mz")',
- modifiedExpressionRows: [["Gizmo", "true"]],
- });
- });
-
- it("between", () => {
- testExpression({
- questionDetails: numberQuestionDetails,
- questionColumns: numberQuestionColumns,
- newExpression: "between([Total], 20, 30)",
- newExpressionRows: [["39.72", "false"]],
- modifiedExpression: "between([Total], 30, 40)",
- modifiedExpressionRows: [["39.72", "true"]],
- });
- });
-
- it("timeInterval", () => {
- testExpression({
- questionDetails: dateQuestionDetails,
- questionColumns: dateQuestionColumns,
- newExpression: 'interval([Created At], -30, "year")',
- newExpressionRows: [["April 30, 2025, 6:56 PM", "true"]],
- modifiedExpression: 'interval([Created At], 2, "month")',
- modifiedExpressionRows: [["April 30, 2025, 6:56 PM", "false"]],
- });
- });
});
describe("query builder", () => {
@@ -250,18 +71,6 @@ describe("scenarios > custom column > boolean functions", () => {
});
});
- it("should be able to add a same-stage filter", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
- H.assertQueryBuilderRowCount(200);
- H.tableHeaderClick(expressionName);
- H.popover().within(() => {
- cy.findByText("Filter by this column").click();
- cy.findByLabelText("True").click();
- cy.findByText("Add filter").click();
- });
- H.assertQueryBuilderRowCount(51);
- });
-
it("should be able to add a same-stage aggregation", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
H.openNotebook();
@@ -282,27 +91,6 @@ describe("scenarios > custom column > boolean functions", () => {
});
});
- it("should be able to add a same-stage breakout", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
- H.openNotebook();
- H.getNotebookStep("expression").button("Summarize").click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByText(expressionName).click();
- H.visualize();
- cy.wait("@dataset");
- H.assertTableData({
- columns: [expressionName, "Count"],
- firstRows: [
- ["false", "149"],
- ["true", "51"],
- ],
- });
- });
-
it("should be able to add a same-stage sorting", () => {
H.createQuestion(questionDetails, { visitQuestion: true });
H.openNotebook();
@@ -507,40 +295,6 @@ describe("scenarios > custom column > boolean functions", () => {
firstRows: [["false"]],
});
});
-
- it("should be able to add a breakout and sorting for a boolean column (metabase#49305)", () => {
- H.createQuestion(questionDetails).then(({ body: card }) =>
- H.createQuestion(getNestedQuestionDetails(card.id), {
- visitQuestion: true,
- }),
- );
-
- cy.log("add a breakout");
- H.openNotebook();
- H.getNotebookStep("data").button("Summarize").click();
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByText(expressionName).click();
- H.visualize();
- cy.wait("@dataset");
- H.assertTableData({
- columns: [expressionName],
- firstRows: [["false"], ["true"]],
- });
-
- cy.log("add sorting");
- H.openNotebook();
- H.getNotebookStep("summarize").button("Sort").click();
- H.popover().findByText(expressionName).click();
- H.getNotebookStep("sort").icon("arrow_up").click();
- H.visualize();
- H.assertTableData({
- columns: [expressionName],
- firstRows: [["true"], ["false"]],
- });
- });
});
});
diff --git a/e2e/test/scenarios/custom-column/cc-cast-functions.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-cast-functions.cy.spec.ts
deleted file mode 100644
index 8b103c917a1..00000000000
--- a/e2e/test/scenarios/custom-column/cc-cast-functions.cy.spec.ts
+++ /dev/null
@@ -1,481 +0,0 @@
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
-
-const { H } = cy;
-
-type CastTestCase = {
- name: string;
- expression: string;
- filterOperator: string;
- filterValue: string;
- expectedRowCount: number;
- expectedTableData?: {
- columns: string[];
- firstRows: string[][];
- };
-};
-
-const TEXT_TEST_CASES: CastTestCase[] = [
- {
- name: "Boolean",
- expression: "text(false)",
- filterOperator: "Starts with",
- filterValue: "FA",
- expectedRowCount: 200,
- },
- {
- name: "Number",
- expression: "text(10.5)",
- filterOperator: "Ends with",
- filterValue: ".5",
- expectedRowCount: 200,
- },
- {
- name: "String",
- expression: 'text("abc")',
- filterOperator: "Is",
- filterValue: "abc",
- expectedRowCount: 200,
- },
- {
- name: "NumberColumn",
- expression: "text([ID])",
- filterOperator: "Contains",
- filterValue: "10",
- expectedRowCount: 12,
- },
- {
- name: "StringColumn",
- expression: "text([Category])",
- filterOperator: "Does not contain",
- filterValue: "gadget",
- expectedRowCount: 147,
- },
- {
- name: "DateColumn",
- expression: "text([Created At])",
- filterOperator: "Contains",
- filterValue: "2018",
- expectedRowCount: 53,
- },
- {
- name: "NumberExpression",
- expression: "text([ID] * 2)",
- filterOperator: "Starts with",
- filterValue: "10",
- expectedRowCount: 6,
- },
-];
-
-const INTEGER_TEST_CASES: CastTestCase[] = [
- {
- name: "String",
- expression: 'integer("10")',
- filterOperator: "Equal to",
- filterValue: "10",
- expectedRowCount: 200,
- },
- {
- name: "StringExpression",
- expression: 'integer(concat([ID], ""))',
- filterOperator: "Equal to",
- filterValue: "29",
- expectedRowCount: 1,
- },
- {
- name: "FloatLiteral",
- expression: "integer(10.4)",
- filterOperator: "Equal to",
- filterValue: "10",
- expectedRowCount: 200,
- },
- {
- name: "FloatColumn",
- expression: "integer([Price])",
- filterOperator: "Equal to",
- filterValue: "29",
- expectedRowCount: 4,
- },
- {
- name: "FloatExpression",
- expression: "integer(42.333 + 0.56)",
- filterOperator: "Equal to",
- filterValue: "43",
- expectedRowCount: 200,
- },
-];
-
-const DATE_TEST_CASES: CastTestCase[] = [
- {
- name: "String",
- expression: 'date("2025-03-20")',
- filterOperator: "On",
- filterValue: "March 20, 2025",
- expectedRowCount: 200,
- },
- {
- name: "StringExpression",
- expression: 'date(concat("2025-03-", case([ID] = 1, "10", "20")))',
- filterOperator: "Before",
- filterValue: "March 15, 2025",
- expectedRowCount: 1,
- },
- {
- name: "Datetime",
- expression: "date([Created At])",
- filterOperator: "Before",
- filterValue: "April 27, 2016",
- expectedRowCount: 1,
- expectedTableData: {
- columns: ["ID", "Datetime"],
- firstRows: [["36", "April 26, 2016"]],
- },
- },
- {
- name: "DatetimeExpression",
- expression: "date(dateTimeAdd([Created At], 1, 'day'))",
- filterOperator: "Before",
- filterValue: "April 28, 2016",
- expectedRowCount: 1,
- expectedTableData: {
- columns: ["ID", "DatetimeExpression"],
- firstRows: [["36", "April 27, 2016"]],
- },
- },
-];
-
-const DATETIME_STRING_TEST_CASES: CastTestCase[] = [
- {
- name: "String",
- expression: 'datetime("2025-03-20 12:03")',
- filterOperator: "On",
- filterValue: "March 20, 2025|12:03",
- expectedRowCount: 200,
- },
- {
- name: "StringExpression",
- expression:
- 'datetime(concat("2025-03-", case([ID] = 1, "10", "12"), " 12:03"))',
- filterOperator: "Before",
- filterValue: "March 11, 2025|12:03",
- expectedRowCount: 1,
- },
- {
- name: "StringExpressionWithIsoMode",
- expression:
- 'datetime(concat("2025-03-", case([ID] = 1, "10", "12"), " 12:03"), "iso")',
- filterOperator: "Before",
- filterValue: "March 11, 2025|12:03",
- expectedRowCount: 1,
- },
- {
- name: "StringWithIsoMode",
- expression: 'datetime("2025-03-20 12:03", "iso")',
- filterOperator: "On",
- filterValue: "March 20, 2025|12:03",
- expectedRowCount: 200,
- },
- {
- name: "StringWithSimpleMode",
- expression: 'datetime("20250320120300", "simple")',
- filterOperator: "On",
- filterValue: "March 20, 2025|12:03",
- expectedRowCount: 200,
- },
- {
- name: "StringExpressionWithSimpleMode",
- expression:
- 'datetime(concat("202503", case([ID] = 1, "10", "12"), "120300"), "simple")',
- filterOperator: "Before",
- filterValue: "March 11, 2025|12:03",
- expectedRowCount: 1,
- },
-];
-
-const DATETIME_NUMBER_TEST_CASES: CastTestCase[] = [
- {
- name: "NumberUnixSeconds",
- expression: 'datetime(1741694580, "unixSeconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixMilliseconds",
- expression: 'datetime(1741694580000, "unixMilliseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixMicroseconds",
- expression: 'datetime(1741694580000000, "unixMicroseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixNanoseconds",
- expression: 'datetime(1741694580000000000, "unixNanoseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
-
- {
- name: "NumberUnixSecondsExpression",
- expression: 'datetime(1741694580 * 1, "unixSeconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixMillisecondsExpression",
- expression: 'datetime(1741694580 * 1000, "unixMilliseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixMicrosecondsExpression",
- expression: 'datetime(1741694580000000 * 1, "unixMicroseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
- {
- name: "NumberUnixNanosecondsExpression",
- expression: 'datetime(1741694580 * 1000000000, "unixNanoseconds")',
- filterOperator: "On",
- filterValue: "March 11, 2025",
- expectedRowCount: 200,
- },
-];
-
-const FLOAT_TEST_CASES: CastTestCase[] = [
- {
- name: "Float",
- expression: 'float("12.5")',
- filterOperator: "Equal to",
- filterValue: "12.5",
- expectedRowCount: 200,
- },
- {
- name: "FloatExpression",
- expression: 'float(concat([ID], ".3333"))',
- filterOperator: "Less than",
- filterValue: "2",
- expectedRowCount: 1,
- },
-];
-
-describe(
- "scenarios > custom column > cast functions",
- { tags: "@external" },
- () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("should support text function", () => {
- testFilterWithExpressions(TEXT_TEST_CASES, addOperatorFilter);
- });
-
- it("should support integer function", () => {
- testFilterWithExpressions(INTEGER_TEST_CASES, addOperatorFilter);
- });
-
- it("should support float function", () => {
- testFilterWithExpressions(FLOAT_TEST_CASES, addOperatorFilter);
- });
-
- it("should support date function", () => {
- testFilterWithExpressions(DATE_TEST_CASES, addDateFilter);
- });
-
- it("should support datetime function on strings", () => {
- testFilterWithExpressions(DATETIME_STRING_TEST_CASES, addDateTimeFilter);
- });
-
- it("should support datetime function on numbers", () => {
- testFilterWithExpressions(DATETIME_NUMBER_TEST_CASES, addDateFilter);
- });
- },
-);
-
-describe("exercise binary datetime() cast function", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- const tests = [
- {
- query: "SELECT CAST('2024-05-21 10:10:03' AS bytea) AS date_time",
- expression: 'datetime([date_time], "isobytes")',
- },
- {
- query: "SELECT CAST('20240521101003' AS bytea) AS date_time",
- expression: 'datetime([date_time], "simplebytes")',
- },
- ];
-
- tests.forEach((test) => {
- it(`should correctly convert temporal bytes: ${test.expression}`, () => {
- H.createNativeQuestion(
- {
- native: {
- query: test.query,
- },
- },
- { wrapId: true },
- ).then((id) => {
- H.visitQuestionAdhoc(
- {
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": `card__${id}`,
- },
- },
- },
- { mode: "notebook" },
- );
- });
-
- addCustomColumn({
- name: "parsed_date",
- expression: test.expression,
- });
-
- H.visualize();
-
- cy.findAllByTestId("header-cell")
- .eq(1)
- .should("have.text", "parsed_date");
- cy.findAllByTestId("cell-data")
- .eq(3)
- .should("have.text", "May 21, 2024, 10:10 AM");
- });
- });
-});
-
-describe("exercise today() function", () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("should show today's date", () => {
- startNewQuestion();
- removeTableFields();
- H.visualize();
- H.assertQueryBuilderRowCount(200);
- H.openNotebook();
-
- addCustomColumn({
- name: "TODAY",
- expression: "today()",
- });
-
- const today = new Date();
- const dateString = today.toLocaleDateString("en-US", {
- year: "numeric",
- month: "long",
- day: "numeric",
- });
-
- H.visualize();
- cy.findAllByTestId("header-cell").eq(1).should("have.text", "TODAY");
- cy.findAllByTestId("cell-data").eq(3).should("have.text", dateString);
- });
-});
-
-function startNewQuestion() {
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("QA Postgres12").click();
- cy.findByText("Products").click();
- });
-}
-
-function removeTableFields() {
- H.getNotebookStep("data").button("Pick columns").click();
- H.popover().findByText("Select all").click();
- cy.realPress("Escape");
-}
-
-function addCustomColumn({
- name,
- expression,
-}: {
- name: string;
- expression: string;
-}) {
- H.getNotebookStep("data").button("Custom column").click();
- H.enterCustomColumnDetails({ formula: expression, name });
- H.popover().button("Done").click();
-}
-
-function removeCustomColumn({ name }: CastTestCase) {
- H.getNotebookStep("expression").findByText(name).icon("close").click();
-}
-
-function addOperatorFilter({ filterOperator, filterValue }: CastTestCase) {
- H.selectFilterOperator(filterOperator);
- H.popover().within(() => {
- cy.findByLabelText("Filter value").type(filterValue);
- cy.button("Add filter").click();
- });
-}
-
-function addDateFilter({ filterOperator, filterValue }: CastTestCase) {
- H.popover().within(() => {
- cy.findByText("Fixed date range…").click();
- cy.findByText(filterOperator).click();
- cy.findByLabelText("Date").clear().type(filterValue);
- cy.button("Add filter").click();
- });
-}
-
-function addDateTimeFilter({ filterOperator, filterValue }: CastTestCase) {
- const [dateValue, timeValue] = filterValue.split("|");
- H.popover().within(() => {
- cy.findByText("Fixed date range…").click();
- cy.findByText(filterOperator).click();
- cy.findByLabelText("Date").clear().type(dateValue);
- cy.findByText("Add time").click();
- cy.findByLabelText("Time").clear().type(timeValue);
- cy.button("Add filter").click();
- });
-}
-
-function testFilterWithExpressions(
- testCases: CastTestCase[],
- addFilter: (testCase: CastTestCase) => void,
-) {
- startNewQuestion();
- removeTableFields();
- H.visualize();
- H.assertQueryBuilderRowCount(200);
- H.openNotebook();
-
- testCases.forEach((testCase) => {
- cy.log(testCase.name);
- addCustomColumn(testCase);
- H.getNotebookStep("expression").button("Filter").click();
- H.popover().findByText(testCase.name).click();
- addFilter(testCase);
- H.visualize();
- H.assertQueryBuilderRowCount(testCase.expectedRowCount);
-
- if (testCase.expectedTableData) {
- // @ts-expect-error: assertTableData is not typed
- H.assertTableData(testCase.expectedTableData);
- }
-
- H.openNotebook();
- removeCustomColumn(testCase);
- });
-}
diff --git a/e2e/test/scenarios/custom-column/cc-literals.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-literals.cy.spec.ts
index 2200adb9216..edf8d1e242f 100644
--- a/e2e/test/scenarios/custom-column/cc-literals.cy.spec.ts
+++ b/e2e/test/scenarios/custom-column/cc-literals.cy.spec.ts
@@ -1,9 +1,5 @@
const { H } = cy;
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
-
describe("scenarios > custom column > literals", () => {
beforeEach(() => {
H.restore();
@@ -144,59 +140,6 @@ describe("scenarios > custom column > literals", () => {
firstRows: [["10", "10"]],
});
});
-
- it("should support custom columns in nested questions (QUE-726)", () => {
- const baseQuestionDetails = {
- name: "QUE-726 Base question",
- query: {
- "source-table": PRODUCTS_ID,
- fields: [
- ["field", PRODUCTS.ID, { "base-type": "type/Integer" }],
- ["field", PRODUCTS.TITLE, { "base-type": "type/Text" }],
- ["field", PRODUCTS.PRICE, { "base-type": "type/Float" }],
- ["expression", "Rustic"],
- ["expression", "MinPrice"],
- ],
- expressions: {
- Rustic: ["value", "Rustic Paper Wallet", { base_type: "type/Text" }],
- MinPrice: ["value", 20.0, { base_type: "type/Float" }],
- },
- },
- };
-
- H.createQuestion(baseQuestionDetails).then(({ body: { id } }) => {
- const nestedQuestion = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": `card__${id}`,
- filter: [
- "and",
- [
- "=",
- ["field", "TITLE", { "base-type": "type/Text" }],
- ["field", "Rustic", { "base-type": "type/Text" }],
- ],
- [
- ">",
- ["field", "PRICE", { "base-type": "type/Float" }],
- ["field", "MinPrice", { "base-type": "type/Float" }],
- ],
- ],
- },
- type: "query",
- },
- };
-
- H.visitQuestionAdhoc(nestedQuestion);
- H.assertTableData({
- columns: ["ID", "Title", "Price", "Rustic", "MinPrice"],
- firstRows: [
- ["1", "Rustic Paper Wallet", "29.46", "Rustic Paper Wallet", "20"],
- ],
- });
- });
- });
});
type CustomColumnInfo = { name: string; expression: string };
diff --git a/e2e/test/scenarios/custom-column/cc-shortcuts.cy.spec.ts b/e2e/test/scenarios/custom-column/cc-shortcuts.cy.spec.ts
index 5401a8536a9..ea469e5ce4f 100644
--- a/e2e/test/scenarios/custom-column/cc-shortcuts.cy.spec.ts
+++ b/e2e/test/scenarios/custom-column/cc-shortcuts.cy.spec.ts
@@ -8,30 +8,6 @@ function selectExtractColumn() {
H.popover().findByText("Extract columns").click();
}
-function selectCombineColumns() {
- H.popover().findByText("Combine columns").click();
-}
-
-function selectColumn(index: number, table: string, name?: string) {
- H.expressionEditorWidget().within(() => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("column-input").eq(index).click();
- });
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover()
- .last()
- .within(() => {
- if (name) {
- // both table and name were given
- cy.findByText(table).click();
- cy.findByText(name).click();
- } else {
- cy.findByText(table).click();
- }
- });
-}
-
describe("scenarios > question > custom column > expression shortcuts > extract", () => {
const DATE_EXTRACTIONS = [
{
@@ -216,143 +192,3 @@ describe("scenarios > question > custom column > expression shortcuts > extract"
});
});
});
-
-describe("scenarios > question > custom column > expression shortcuts > combine", () => {
- function addColumn() {
- H.expressionEditorWidget().within(() => {
- cy.findByText("Add column").click();
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be possible to select a combine columns shortcut", () => {
- H.openOrdersTable({ mode: "notebook", limit: 5 });
- H.addCustomColumn();
-
- selectCombineColumns();
-
- selectColumn(0, "Total");
-
- H.expressionEditorWidget().findByText("Total").should("exist");
-
- selectColumn(1, "Product", "Rating");
-
- H.expressionEditorWidget().within(() => {
- cy.findByText("Product → Rating").should("exist");
-
- cy.findByTestId("combine-example").should(
- "have.text",
- "123.45678901234567 123.45678901234567",
- );
-
- cy.findByText(/Separated by/).click();
- cy.findByLabelText("Separator").type("__");
-
- cy.findByTestId("combine-example").should(
- "have.text",
- "123.45678901234567__123.45678901234567",
- );
-
- cy.button("Done").click();
-
- H.CustomExpressionEditor.value().should(
- "equal",
- 'concat([Total], "__", [Product → Rating])',
- );
- cy.findByTestId("expression-name").should(
- "have.value",
- "Combined Total, Rating",
- );
- });
- });
-
- it("should be possible to cancel when using the combine column shortcut", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- selectCombineColumns();
-
- selectColumn(0, "Total");
- selectColumn(1, "Product", "Rating");
-
- H.expressionEditorWidget().within(() => {
- // Click the back button, in the header
- cy.findByText("Select columns to combine").click();
- });
-
- H.CustomExpressionEditor.value().should("equal", "");
- cy.findByTestId("expression-name").should("have.value", "");
- });
-
- it("should be possible to add and remove more than one column", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- selectCombineColumns();
-
- selectColumn(0, "Total");
- selectColumn(1, "Product", "Rating");
- addColumn();
- selectColumn(2, "User", "Email");
-
- cy.findByTestId("combine-example").should(
- "contain",
- "123.45678901234567 123.45678901234567 [email protected]",
- );
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByLabelText("Remove column").last().click();
-
- cy.findByTestId("combine-example").should(
- "contain",
- "123.45678901234567 123.45678901234567",
- );
- });
-
- it("should pick the correct default separator based on the type of the first column", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- selectCombineColumns();
-
- selectColumn(0, "User", "Email");
-
- H.expressionEditorWidget().within(() => {
- cy.findByText("Separated by (empty)").should("exist");
- cy.findByText(/Separated by/).click();
-
- cy.findByLabelText("Separator").should("have.value", "");
- });
- });
-});
-
-describe("scenarios > question > custom column > combine shortcuts", () => {
- beforeEach(() => {
- H.restore();
- H.resetSnowplow();
- cy.signInAsNormalUser();
- });
-
- afterEach(() => {
- H.expectNoBadSnowplowEvents();
- });
-
- it("should send an event for combine columns", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.addCustomColumn();
- selectCombineColumns();
-
- selectColumn(0, "User", "Email");
- selectColumn(1, "User", "Email");
-
- H.expressionEditorWidget().button("Done").click();
-
- H.expectUnstructuredSnowplowEvent({
- event: "column_combine_via_shortcut",
- custom_expressions_used: ["concat"],
- database_id: SAMPLE_DB_ID,
- question_id: 0,
- });
- });
-});
diff --git a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
index 303229fbd79..2b4aca78dfe 100644
--- a/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-1.cy.spec.js
@@ -567,23 +567,6 @@ describe("scenarios > question > custom column", () => {
H.CustomExpressionEditor.value().should("equal", "Sum([MyCC \\[2027\\]])");
});
- it("should work with `isNull` function (metabase#15922)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.getNotebookStep("data").button("Custom column").click();
- H.enterCustomColumnDetails({
- formula: "isnull([Discount])",
- name: "No discount",
- });
- cy.button("Done").click();
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
-
- cy.findAllByRole("gridcell").contains("37.65");
- cy.findAllByTestId("header-cell").contains("No discount");
- });
-
it("should be able to add a date range filter to a custom column", () => {
H.visitQuestionAdhoc({
display: "table",
diff --git a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
index cd6516a41aa..fd6b15e02c1 100644
--- a/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-3.cy.spec.js
@@ -1,10 +1,8 @@
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, PEOPLE_ID, PEOPLE, PRODUCTS, PRODUCTS_ID } =
- SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PEOPLE_ID, PEOPLE } = SAMPLE_DATABASE;
describe("scenarios > question > custom column > distinctIf", () => {
beforeEach(() => {
@@ -573,191 +571,6 @@ describe("scenarios > question > custom column > aggregation", () => {
});
});
- describe("scenarios > question > custom column > aggregation > as question source", () => {
- beforeEach(() => {
- H.createQuestion(
- {
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- [
- "aggregation-options",
- [
- "min",
- [
- "field",
- ORDERS.SUBTOTAL,
- {
- "base-type": "type/Float",
- },
- ],
- ],
- {
- name: "Foo",
- "display-name": "Foo",
- },
- ],
- [
- "aggregation-options",
- [
- "+",
- [
- "aggregation",
- 0,
- {
- "base-type": "type/Float",
- },
- ],
- [
- "avg",
- [
- "field",
- ORDERS.TAX,
- {
- "base-type": "type/Float",
- },
- ],
- ],
- ],
- {
- name: "Bar",
- "display-name": "Bar",
- },
- ],
- ],
- },
- },
- { wrapId: true, idAlias: "nestedQuestionId" },
- );
-
- cy.get("@nestedQuestionId").then((cardId) => {
- H.visitQuestionAdhoc(
- {
- type: "question",
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": `card__${cardId}`,
- },
- },
- },
- { mode: "notebook" },
- );
- });
- });
-
- it("should be possible to use a question with nested aggregations as the source of another question", () => {
- H.visualize();
- H.assertTableData({
- columns: ["Foo", "Bar"],
- firstRows: [["15.69", "19.55"]],
- });
- });
-
- it("should be possible to use nested aggregations in custom columns of a new question", () => {
- H.addCustomColumn();
- H.CustomExpressionEditor.type("[Foo] + [Bar]");
- H.CustomExpressionEditor.nameInput().type("Sum");
- H.popover().button("Done").click();
-
- H.visualize();
-
- H.assertTableData({
- columns: ["Foo", "Bar", "Sum"],
- firstRows: [["15.69", "19.55", "35.24"]],
- });
- });
-
- it("should be possible to use nested aggregations in filter clause of a new question", () => {
- H.filter({ mode: "notebook" });
- H.popover().within(() => {
- cy.findByText("Bar").click();
- cy.findByPlaceholderText("Min").type("5");
- cy.findByPlaceholderText("Max").type("20");
- cy.button("Add filter").click();
- });
- H.visualize();
- H.assertTableData({
- columns: ["Foo", "Bar"],
- firstRows: [["15.69", "19.55"]],
- });
- });
-
- // The notebook editor's join LHS picker doesn't expose card-source aggregation
- // columns, so we construct the join via MBQL and verify the rendered table.
- it("should be possible to use nested aggregations in join clause of a new question", () => {
- cy.get("@nestedQuestionId").then((cardId) => {
- H.visitQuestionAdhoc({
- type: "question",
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": `card__${cardId}`,
- joins: [
- {
- alias: "Products - Foo",
- strategy: "left-join",
- "source-table": PRODUCTS_ID,
- fields: [
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products - Foo",
- },
- ],
- ],
- condition: [
- "=",
- ["field", "Foo", { "base-type": "type/Float" }],
- [
- "field",
- PRODUCTS.PRICE,
- {
- "base-type": "type/Float",
- "join-alias": "Products - Foo",
- },
- ],
- ],
- },
- ],
- },
- },
- });
- });
-
- H.assertTableData({
- columns: ["Foo", "Bar", "Products - Foo → ID"],
- firstRows: [["15.69", "19.55", "61"]],
- });
- });
-
- it("should be possible to use nested aggregations in order by clause of a new question", () => {
- H.sort();
- H.popover().findByText("Bar").click();
-
- H.visualize();
- H.assertTableData({
- columns: ["Foo", "Bar"],
- firstRows: [["15.69", "19.55"]],
- });
- });
-
- it("should be possible to use nested aggregations in breakout of a new question", () => {
- H.summarize({ mode: "notebook" });
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByText("Bar").click();
-
- H.visualize();
- cy.findByTestId("scalar-value").should("have.text", "19.55");
- });
- });
-
describe("scenarios > question > custom column > aggregation > in a follow up stage", () => {
beforeEach(() => {
H.createQuestion(
diff --git a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
index bf557c81bf4..71767ca9cac 100644
--- a/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/custom-column/custom-column-reproductions-1.cy.spec.js
@@ -4,8 +4,7 @@ import { dedent } from "ts-dedent";
import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-const { PRODUCTS, PRODUCTS_ID, ORDERS, ORDERS_ID, REVIEWS, REVIEWS_ID } =
- SAMPLE_DATABASE;
+const { PRODUCTS, PRODUCTS_ID, ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
describe("issue 12445", { tags: ["@external", "@skip"] }, () => {
const CC_NAME = "Abbr";
@@ -43,63 +42,6 @@ describe("issue 12445", { tags: ["@external", "@skip"] }, () => {
});
});
});
-
-describe("issue 13289", () => {
- const CC_NAME = "Math";
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
-
- H.openOrdersTable({ mode: "notebook" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom column").click();
-
- // Add custom column that will be used later in summarize (group by)
- H.enterCustomColumnDetails({ formula: "1 + 1", name: CC_NAME });
- cy.button("Done").click();
- });
-
- it("should allow 'zoom in' drill-through when grouped by custom column (metabase#13289)", () => {
- H.summarize({ mode: "notebook" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count of rows").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
-
- H.popover().findByText(CC_NAME).click();
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.icon("add").last().click();
-
- H.popover().within(() => {
- cy.findByText("Created At").click();
- });
-
- H.visualize();
-
- cy.findByTestId("query-visualization-root").within(() => {
- H.cartesianChartCircle()
- .eq(5) // random circle in the graph (there is no specific reason for this index)
- .click();
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("See this month by week").click();
- cy.wait("@dataset");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("There was a problem with your question").should("not.exist");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Created At is Sep 1–30, 2025");
- });
-});
-
describe("issue 13751", { tags: "@external" }, () => {
const CC_NAME = "C-States";
const PG_DB_NAME = "QA Postgres12";
@@ -846,38 +788,6 @@ describe("issue 25189", { tags: "@skip" }, () => {
});
});
});
-
-describe("issue 32032", () => {
- const QUERY = {
- "source-table": REVIEWS_ID,
- expressions: {
- "Custom Reviewer": ["field", REVIEWS.REVIEWER, null],
- },
- fields: [
- ["field", REVIEWS.ID, { "base-type": "type/BigInteger" }],
- ["field", REVIEWS.REVIEWER, { "base-type": "type/Text" }],
- ["expression", "Custom Reviewer", { "base-type": "type/Text" }],
- ],
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.createQuestion({ query: QUERY }, { visitQuestion: true });
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should allow quick filter drills on custom columns", () => {
- H.tableInteractive().findAllByText("xavier").eq(1).click();
- H.popover().findByText("Is xavier").click();
- cy.wait("@dataset");
- H.main()
- .findByText(/There was a problem/i)
- .should("not.exist");
- H.tableInteractive().findAllByText("xavier").should("have.length", 2);
- });
-});
-
// broken. see https://github.com/metabase/metabase/issues/55673
describe("issue 42949", { tags: "@skip" }, () => {
beforeEach(() => {
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-1-stage.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-1-stage.cy.spec.ts
deleted file mode 100644
index 53ec0760178..00000000000
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-1-stage.cy.spec.ts
+++ /dev/null
@@ -1,697 +0,0 @@
-const { H } = cy;
-
-import * as QSHelpers from "./shared/dashboard-filters-query-stages";
-
-/**
- * Abbreviations used for card aliases in this test suite:
- * qbq = question-based question
- * qbm = question-based model
- * mbq = model-based question
- * mbm = model-based model
- */
-describe("scenarios > dashboard > filters > query stages", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- QSHelpers.createBaseQuestions();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("PUT", "/api/dashboard/**").as("updateDashboard");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashboardData",
- );
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashboardData",
- );
- cy.intercept("GET", "/api/embed/dashboard/*/dashcard/*/card/*").as(
- "embeddedDashboardData",
- );
- });
-
- describe("1-stage queries", () => {
- describe("Q1 - join, custom column, no aggregations, no breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ1Query,
- );
- });
-
- it("allows to map to all relevant columns", () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [
- [
- "Question-based Model",
- [
- ...QSHelpers.ORDERS_DATE_COLUMNS,
- "Reviews - Product → Created At",
- ],
- ],
- ["Product", QSHelpers.PRODUCTS_DATE_COLUMNS],
- ["Reviews - Product → Product", QSHelpers.PRODUCTS_DATE_COLUMNS],
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [
- [
- "Model-based Model",
- [
- ...QSHelpers.ORDERS_DATE_COLUMNS,
- "Reviews - Product → Created At",
- ],
- ],
- ["Product", QSHelpers.PRODUCTS_DATE_COLUMNS],
- ["Reviews - Product → Product", QSHelpers.PRODUCTS_DATE_COLUMNS],
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [
- [
- "Question-based Model",
- ["Reviews - Product → Reviewer", "Reviews - Product → Body"],
- ],
- ["Product", QSHelpers.PRODUCTS_TEXT_COLUMNS],
- ["Reviews - Product → Product", QSHelpers.PRODUCTS_TEXT_COLUMNS],
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [
- [
- "Model-based Model",
- ["Reviews - Product → Reviewer", "Reviews - Product → Body"],
- ],
- ["Product", QSHelpers.PRODUCTS_TEXT_COLUMNS],
- ["Reviews - Product → Product", QSHelpers.PRODUCTS_TEXT_COLUMNS],
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [
- [
- "Question-based Model",
- [
- ...QSHelpers.ORDERS_NUMBER_COLUMNS,
- "Net",
- "Reviews - Product → Rating",
- ],
- ],
- ["Product", QSHelpers.PRODUCTS_NUMBER_COLUMNS],
- [
- "Reviews - Product → Product",
- QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [
- [
- "Model-based Model",
- [
- ...QSHelpers.ORDERS_NUMBER_COLUMNS,
- "Net",
- "Reviews - Product → Rating",
- ],
- ],
- ["Product", QSHelpers.PRODUCTS_NUMBER_COLUMNS],
- [
- "Reviews - Product → Product",
- QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- }
- });
- });
-
- describe("Q2 - join, custom column, 2 aggregations, no breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ2Query,
- );
- });
-
- it("allows to map to all relevant columns (metabase#47184)", () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(2);
- QSHelpers.verifyNoDashcardMappingOptions(3);
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(2);
- QSHelpers.verifyNoDashcardMappingOptions(3);
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total"]]],
- );
- }
- });
- });
-
- describe("Q3 - join, custom column, no aggregations, 3 breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ3Query,
- );
- });
-
- it("allows to map to all relevant columns", { tags: "@skip" }, () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(2);
- QSHelpers.verifyNoDashcardMappingOptions(3);
- }
- });
- });
-
- describe("Q4 - join, custom column, 2 aggregations, 2 breakouts (metabase#47184)", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ4Query,
- );
- });
-
- it("allows to map to all relevant columns", { tags: "@skip" }, () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- ["Reviews", QSHelpers.REVIEWS_DATE_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Reviews", QSHelpers.REVIEWS_TEXT_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- ["Reviews", QSHelpers.REVIEWS_NUMBER_COLUMNS],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total"]]],
- );
- }
- });
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-1.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-1.cy.spec.ts
deleted file mode 100644
index 4f05df4e9ab..00000000000
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-1.cy.spec.ts
+++ /dev/null
@@ -1,226 +0,0 @@
-const { H } = cy;
-
-import * as QSHelpers from "./shared/dashboard-filters-query-stages";
-
-/**
- * Abbreviations used for card aliases in this test suite:
- * qbq = question-based question
- * qbm = question-based model
- * mbq = model-based question
- * mbm = model-based model
- */
-describe("scenarios > dashboard > filters > query stages", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- QSHelpers.createBaseQuestions();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("PUT", "/api/dashboard/**").as("updateDashboard");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashboardData",
- );
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashboardData",
- );
- cy.intercept("GET", "/api/embed/dashboard/*/dashcard/*/card/*").as(
- "embeddedDashboardData",
- );
- });
-
- describe("2-stage queries", () => {
- describe("Q5 - Q4 + 2nd stage with join, custom column, no aggregations, no breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ5Query,
- );
- });
-
- it("allows to map to all relevant columns", { tags: "@skip" }, () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Created At: Month", "User → Created At: Year"]]],
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Product → Category"]]],
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total", "5 * Count"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Total", "5 * Count"]]],
- );
- }
- });
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-2.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-2.cy.spec.ts
deleted file mode 100644
index ea8403c7a6c..00000000000
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-2.cy.spec.ts
+++ /dev/null
@@ -1,356 +0,0 @@
-const { H } = cy;
-
-import * as QSHelpers from "./shared/dashboard-filters-query-stages";
-
-/**
- * Abbreviations used for card aliases in this test suite:
- * qbq = question-based question
- * qbm = question-based model
- * mbq = model-based question
- * mbm = model-based model
- */
-describe("scenarios > dashboard > filters > query stages", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- QSHelpers.createBaseQuestions();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("PUT", "/api/dashboard/**").as("updateDashboard");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashboardData",
- );
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashboardData",
- );
- cy.intercept("GET", "/api/embed/dashboard/*/dashcard/*/card/*").as(
- "embeddedDashboardData",
- );
- });
-
- describe("2-stage queries", () => {
- describe("Q6 - Q4 + 2nd stage with join, custom column, 2 aggregations, no breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ6Query,
- );
- });
-
- it("allows to map to all relevant columns", () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Reviews - Created At: Month → Rating"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Count", "Sum of Reviews - Created At: Month → Rating"]]],
- );
- }
- });
-
- describe("applies filter to the the dashcard and allows to drill via dashcard header", () => {
- it("1st stage explicit join", () => {
- QSHelpers.setup1stStageExplicitJoinFilter();
- QSHelpers.apply1stStageExplicitJoinFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["1,813", "7,218"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["1,813", "7,218"],
- });
- });
-
- it("1st stage implicit join (data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromSourceFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["2,071", "8,252"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["2,071", "8,252"],
- });
- });
-
- it("1st stage implicit join (joined data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromJoinFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["4,447", "17,714"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["4,447", "17,714"],
- });
- });
-
- it("1st stage custom column", () => {
- QSHelpers.setup1stStageCustomColumnFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["971", "3,900"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["971", "3,900"],
- });
- });
-
- it("1st stage aggregation", () => {
- QSHelpers.setup1stStageAggregationFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["3", "13"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["3", "13"],
- });
- });
-
- it("1st stage breakout", () => {
- QSHelpers.setup1stStageBreakoutFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["4,447", "17,714"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["4,447", "17,714"],
- });
- });
-
- it("2nd stage explicit join", () => {
- QSHelpers.setup2ndStageExplicitJoinFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["16", "80"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["16", "80"],
- });
- });
-
- it("2nd stage custom column", () => {
- QSHelpers.setup2ndStageCustomColumnFilter();
- QSHelpers.apply2ndStageCustomColumnFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["31", "114"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["31", "114"],
- });
- });
- });
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-3.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-3.cy.spec.ts
deleted file mode 100644
index 6afcd133bec..00000000000
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-3.cy.spec.ts
+++ /dev/null
@@ -1,438 +0,0 @@
-const { H } = cy;
-
-import * as QSHelpers from "./shared/dashboard-filters-query-stages";
-
-/**
- * Abbreviations used for card aliases in this test suite:
- * qbq = question-based question
- * qbm = question-based model
- * mbq = model-based question
- * mbm = model-based model
- */
-describe("scenarios > dashboard > filters > query stages", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- QSHelpers.createBaseQuestions();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("PUT", "/api/dashboard/**").as("updateDashboard");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashboardData",
- );
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashboardData",
- );
- cy.intercept("GET", "/api/embed/dashboard/*/dashcard/*/card/*").as(
- "embeddedDashboardData",
- );
- });
-
- describe("2-stage queries", () => {
- describe("Q7 - Q4 + 2nd stage with join, custom column, no aggregations, 2 breakouts", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ7Query,
- );
- });
-
- it("allows to map to all relevant columns", () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- [
- "Summaries (2)",
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- [
- "Summaries (2)",
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [
- [
- null,
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [
- [
- null,
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ],
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ],
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
- });
-
- describe("applies filter to the the dashcard and allows to drill via dashcard header", () => {
- it("1st stage explicit join", () => {
- QSHelpers.setup1stStageExplicitJoinFilter();
- QSHelpers.apply1stStageExplicitJoinFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 953,
- queryBuilderCount: "Showing 953 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 953,
- queryBuilderCount: "Showing 953 rows",
- });
- });
-
- it("1st stage implicit join (data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromSourceFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 1044,
- queryBuilderCount: "Showing 1,044 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 1044,
- queryBuilderCount: "Showing 1,044 rows",
- });
- });
-
- it("1st stage implicit join (joined data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromJoinFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
- });
-
- it("1st stage custom column", () => {
- QSHelpers.setup1stStageCustomColumnFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 688,
- queryBuilderCount: "Showing 688 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 688,
- queryBuilderCount: "Showing 688 rows",
- });
- });
-
- it("1st stage aggregation", () => {
- QSHelpers.setup1stStageAggregationFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 3,
- queryBuilderCount: "Showing 3 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 3,
- queryBuilderCount: "Showing 3 rows",
- });
- });
-
- it("1st stage breakout", () => {
- QSHelpers.setup1stStageBreakoutFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
- });
-
- it("2nd stage explicit join", () => {
- QSHelpers.setup2ndStageExplicitJoinFilter();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 4,
- queryBuilderCount: "Showing 4 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 4,
- queryBuilderCount: "Showing 4 rows",
- });
- });
-
- it("2nd stage custom column", () => {
- QSHelpers.setup2ndStageCustomColumnFilter();
- QSHelpers.apply2ndStageCustomColumnFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 31,
- queryBuilderCount: "Showing 31 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 31,
- queryBuilderCount: "Showing 31 rows",
- });
- });
-
- it("2nd stage breakout", () => {
- QSHelpers.setup2ndStageBreakoutFilter();
- QSHelpers.apply2ndStageBreakoutFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 0,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 2,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 3,
- dashboardCount: 1077,
- queryBuilderCount: "Showing 1,077 rows",
- });
- });
- });
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-3-stage.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-3-stage.cy.spec.ts
deleted file mode 100644
index 9c904bcb11d..00000000000
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-3-stage.cy.spec.ts
+++ /dev/null
@@ -1,439 +0,0 @@
-const { H } = cy;
-
-import * as QSHelpers from "./shared/dashboard-filters-query-stages";
-
-/**
- * Abbreviations used for card aliases in this test suite:
- * qbq = question-based question
- * qbm = question-based model
- * mbq = model-based question
- * mbm = model-based model
- */
-describe("scenarios > dashboard > filters > query stages", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- QSHelpers.createBaseQuestions();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("PUT", "/api/dashboard/**").as("updateDashboard");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashboardData",
- );
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashboardData",
- );
- cy.intercept("GET", "/api/embed/dashboard/*/dashcard/*/card/*").as(
- "embeddedDashboardData",
- );
- });
-
- describe("3-stage queries", () => {
- describe("Q9 - Q8 + 3rd stage with 1 aggregation", () => {
- beforeEach(() => {
- QSHelpers.createAndVisitDashboardWithCardMatrix(
- QSHelpers.createQ9Query,
- );
- });
-
- it("allows to map to all relevant columns", () => {
- H.editDashboard();
-
- cy.log("## date columns");
- QSHelpers.getFilter("Date").click();
- verifyDateMappingOptions();
-
- cy.log("## text columns");
- QSHelpers.getFilter("Text").click();
- verifyTextMappingOptions();
-
- cy.log("## number columns");
- QSHelpers.getFilter("Number").click();
- verifyNumberMappingOptions();
-
- function verifyDateMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- ["Base Orders Question", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- ["Base Orders Model", QSHelpers.ORDERS_DATE_COLUMNS],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ...QSHelpers.REVIEWS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ...QSHelpers.PRODUCTS_DATE_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_DATE_COLUMNS],
- ["Summaries", ["Created At: Month", "User → Created At: Year"]],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
-
- function verifyTextMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- [
- "Summaries (2)",
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ...QSHelpers.REVIEWS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ...QSHelpers.PRODUCTS_TEXT_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_TEXT_COLUMNS],
- ["Summaries", ["Product → Category"]],
- [
- "Summaries (2)",
- [
- "Reviews - Created At: Month → Reviewer",
- "Product → Category",
- ],
- ],
- ],
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- );
- QSHelpers.verifyNoDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- );
- }
-
- function verifyNumberMappingOptions() {
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Question",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- [
- "Summaries (2)",
- ["Count", "Sum of Reviews - Created At: Month → Rating"],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_QUESTION_INDEX,
- [
- [
- "Base Orders Model",
- [...QSHelpers.ORDERS_NUMBER_COLUMNS, "Net"],
- ],
- [
- "Reviews",
- [
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ...QSHelpers.REVIEWS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- [
- "Product",
- [
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ...QSHelpers.PRODUCTS_NUMBER_COLUMNS,
- ],
- ], // TODO: https://github.com/metabase/metabase/issues/46845
- ["User", QSHelpers.PEOPLE_NUMBER_COLUMNS],
- ["Summaries", ["Count", "Sum of Total", "5 * Count"]],
- [
- "Summaries (2)",
- ["Count", "Sum of Reviews - Created At: Month → Rating"],
- ],
- ],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.QUESTION_BASED_MODEL_INDEX,
- [[null, ["Count"]]],
- );
- QSHelpers.verifyDashcardMappingOptions(
- QSHelpers.MODEL_BASED_MODEL_INDEX,
- [[null, ["Count"]]],
- );
- }
- });
-
- describe("applies filter to the the dashcard and allows to drill via dashcard header", () => {
- it("1st stage explicit join", () => {
- QSHelpers.setup1stStageExplicitJoinFilter();
- QSHelpers.apply1stStageExplicitJoinFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["953"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["953"],
- });
- });
-
- it("1st stage implicit join (data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromSourceFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["1,044"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["1,044"],
- });
- });
-
- it("1st stage implicit join (joined data source)", () => {
- QSHelpers.setup1stStageImplicitJoinFromJoinFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["1,077"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["1,077"],
- });
- });
-
- it("1st stage custom column", () => {
- QSHelpers.setup1stStageCustomColumnFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["688"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["688"],
- });
- });
-
- it("1st stage aggregation", () => {
- QSHelpers.setup1stStageAggregationFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["3"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["3"],
- });
- });
-
- it("1st stage breakout", () => {
- QSHelpers.setup1stStageBreakoutFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["1,077"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["1,077"],
- });
- });
-
- it("2nd stage explicit join", () => {
- QSHelpers.setup2ndStageExplicitJoinFilter();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["4"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["4"],
- });
- });
-
- it("2nd stage custom column", () => {
- QSHelpers.setup2ndStageCustomColumnFilter();
- QSHelpers.apply2ndStageCustomColumnFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["31"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["31"],
- });
- });
-
- it("2nd stage aggregation", () => {
- QSHelpers.setup2ndStageAggregationFilter();
- QSHelpers.apply2ndStageAggregationFilter();
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["6"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["6"],
- });
- });
-
- it("2nd stage breakout", () => {
- H.editDashboard();
-
- QSHelpers.getFilter("Text").click();
-
- H.getDashboardCard(0).findByText("Select…").click();
- H.popover().within(() => {
- QSHelpers.getPopoverItem("Product → Category", 1)
- .scrollIntoView()
- .click();
- });
-
- H.undoToast().icon("close").click();
-
- H.getDashboardCard(1).findByText("Select…").click();
- H.popover().within(() => {
- QSHelpers.getPopoverItem("Product → Category", 1)
- .scrollIntoView()
- .click();
- });
-
- H.saveDashboard();
-
- H.filterWidget().eq(0).click();
- H.popover().within(() => {
- cy.findByLabelText("Gadget").click();
- cy.button("Add filter").click();
- });
- cy.wait(["@dashboardData", "@dashboardData"]);
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 0,
- values: ["1,077"],
- });
-
- QSHelpers.goBackToDashboard();
-
- QSHelpers.verifyDashcardCellValues({
- dashcardIndex: 1,
- values: ["1,077"],
- });
- });
- });
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts
index a554f12f53c..2079f75ea08 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts
+++ b/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts
@@ -6,132 +6,6 @@ import * as QSHelpers from "./shared/dashboard-filters-query-stages";
const { ORDERS, PRODUCTS } = SAMPLE_DATABASE;
-describe("scenarios > dashboard > filters > query stages + temporal unit parameters", () => {
- describe("applies filter to the the dashcard and allows to drill via dashcard header", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("1st stage explicit join + unit of time parameter", () => {
- H.createDashboard(
- {
- name: "My new dashboard",
- },
- { wrapId: true, idAlias: "myNewDash" },
- );
-
- cy.get("@myNewDash").then((dashId: number | any) => {
- cy.request("POST", "/api/activity/recents", {
- context: "selection",
- model: "dashboard",
- model_id: dashId,
- });
- });
-
- H.startNewQuestion();
-
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
-
- H.getNotebookStep("filter")
- .findByText("Add filters to narrow your answer")
- .click();
- H.popover().within(() => {
- cy.findByText("Orders").click();
- cy.findByText("Product").click();
- cy.findByText("Category").click();
- cy.findByLabelText("Gizmo").click();
- cy.findByLabelText("Doohickey").click();
- cy.button("Add filter").click();
- });
-
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize").icon("add").click();
- H.popover().within(() => {
- cy.findByText("Sum of ...").click();
- cy.findByText("Total").click();
- });
-
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover()
- .findByLabelText("Created At")
- .findByLabelText("Temporal bucket")
- .realHover()
- .click();
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Week").click();
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .icon("add")
- .click();
- H.popover().within(() => {
- cy.findByText("Orders").click();
- cy.findByText("Product").click();
- cy.findByText("Category").click();
- });
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().button("Summarize").click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize", { stage: 1 })
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByLabelText("Created At: Week").click();
-
- H.visualize(); // need to visualize because startNewQuestion does not set "display" property on a card
- cy.wait("@dataset");
- H.saveQuestion("test"); // added to new dash automatically
-
- cy.findByLabelText("Add a filter or parameter").click();
- H.popover().findByText("Text or Category").click();
- H.getDashboardCard().findByText("Select…").click();
- cy.findAllByText("Category").first().click();
-
- cy.findByLabelText("Add a filter or parameter").click();
- H.popover().findByText("Time grouping").click();
- H.getDashboardCard().findByText("Select…").click();
- H.popover().findByText("Created At: Week").click();
-
- H.saveDashboard();
- H.filterWidget().eq(0).click();
- H.popover().within(() => {
- cy.findByText("Gizmo").click();
- cy.button("Add filter").click();
- });
-
- H.filterWidget().eq(1).click();
- H.popover().findByText("Quarter").click();
-
- H.getDashboardCard().findByText("Q1 2026").should("be.visible");
- H.getDashboardCard().findByTestId("legend-caption-title").click();
- cy.wait("@dataset");
-
- // assert that new filter was applied
- cy.findByTestId("qb-filters-panel").within(() => {
- cy.findByText("Product → Category is 2 selections").should(
- "be.visible",
- );
- cy.findByText("Product → Category is Gizmo").should("be.visible");
- });
-
- // assert that temporal unit parameter was applied
- cy.findByTestId("chart-container")
- .findByText("Q1 2026")
- .should("be.visible");
- });
- });
-});
-
describe("pivot tables", () => {
const QUESTION_PIVOT_INDEX = 0;
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filter-data-permissions.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filter-data-permissions.cy.spec.js
index 0033285a8b4..39d3f87f264 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filter-data-permissions.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filter-data-permissions.cy.spec.js
@@ -59,15 +59,4 @@ describe("support > permissions (metabase#8472)", () => {
cy.signIn("nodata");
filterDashboard();
});
-
- it("should not allow a nocollection user to visit the page, hence cannot see the filter", () => {
- cy.signIn("nocollection");
- cy.request({
- method: "GET",
- url: `/api/dashboard/${ORDERS_DASHBOARD_ID}`,
- failOnStatusCode: false,
- }).should((xhr) => {
- expect(xhr.status).to.equal(403);
- });
- });
});
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-boolean.cy.spec.ts b/e2e/test/scenarios/dashboard-filters/dashboard-filters-boolean.cy.spec.ts
index 08253dc47a6..2b9d671d6f0 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-boolean.cy.spec.ts
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-boolean.cy.spec.ts
@@ -7,10 +7,6 @@ import type {
NativeQuestionDetails,
StructuredQuestionDetails,
} from "e2e/support/helpers";
-import {
- createMockDashboardCard,
- createMockParameter,
-} from "metabase-types/api/mocks";
const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
@@ -255,32 +251,6 @@ describe(
H.assertQueryBuilderRowCount(53);
H.filterWidget().findByText("True").should("be.visible");
});
-
- it("should allow to use boolean parameters mapped to SQL query parameters in a public dashboard", () => {
- createNativeQuestionWithVariableAndDashboardWithMapping().then(
- ({ dashboardId }) => H.visitPublicDashboard(dashboardId),
- );
- testParameterWidget({
- allRowCountText: "200 rows",
- trueRowCountText: "53 rows",
- falseRowCountText: "54 rows",
- });
- });
-
- it("should allow to use boolean parameters mapped to SQL query parameters in an embedded dashboard", () => {
- createNativeQuestionWithVariableAndDashboardWithMapping().then(
- ({ dashboardId }) =>
- H.visitEmbeddedPage({
- resource: { dashboard: dashboardId },
- params: {},
- }),
- );
- testParameterWidget({
- allRowCountText: "200 rows",
- trueRowCountText: "53 rows",
- falseRowCountText: "54 rows",
- });
- });
});
},
);
@@ -386,45 +356,6 @@ function createNativeQuestionWithVariableAndDashboard() {
});
}
-function createNativeQuestionWithVariableAndDashboardWithMapping() {
- return createNativeQuestionWithVariableAndDashboard().then(
- ({ dashboardId, dashcardId, questionId }) => {
- cy.request("PUT", `/api/dashboard/${dashboardId}`, {
- dashcards: [
- createMockDashboardCard({
- id: dashcardId,
- dashboard_id: dashboardId,
- card_id: questionId,
- size_x: 6,
- size_y: 6,
- parameter_mappings: [
- {
- card_id: questionId,
- parameter_id: "boolean",
- target: ["variable", ["template-tag", "boolean"]],
- },
- ],
- }),
- ],
- parameters: [
- createMockParameter({
- id: "boolean",
- type: "boolean/=",
- slug: "boolean",
- name: "Boolean",
- }),
- ],
- enable_embedding: true,
- embedding_params: {
- boolean: "enabled",
- },
- }).then(() => {
- return { dashboardId };
- });
- },
- );
-}
-
function createAndMapParameter({
columnName = COLUMN_NAME,
parameterName = PARAMETER_NAME,
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js
deleted file mode 100644
index 360ab58590d..00000000000
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-explicit-join.cy.spec.js
+++ /dev/null
@@ -1,107 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
-
-const questionDetails = {
- name: "Orders join Products",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field-id", ORDERS.PRODUCT_ID],
- ["joined-field", "Products", ["field-id", PRODUCTS.ID]],
- ],
- alias: "Products",
- },
- ],
- limit: 5,
- },
-};
-
-const filter = {
- name: "Text",
- slug: "text",
- id: "7653fdfa",
- type: "string/=",
- sectionId: "string",
-};
-
-const dashboardDetails = {
- parameters: [filter],
-};
-
-describe("scenarios > dashboard > filters", () => {
- beforeEach(() => {
- cy.intercept("GET", `/api/dashboard/*/params/${filter.id}/values`).as(
- "filterValues",
- );
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: dashboardCard }) => {
- const { card_id, dashboard_id } = dashboardCard;
-
- const updatedCardDetails = {
- size_x: 21,
- size_y: 10,
- parameter_mappings: [
- {
- parameter_id: filter.id,
- card_id,
- target: [
- "dimension",
- [
- "field",
- PRODUCTS.TITLE,
- {
- "join-alias": "Products",
- },
- ],
- ],
- },
- ],
- };
-
- H.editDashboardCard(dashboardCard, updatedCardDetails);
-
- H.visitDashboard(dashboard_id);
- },
- );
- });
-
- it("should work properly when connected to the explicitly joined field", () => {
- H.filterWidget().click();
- cy.wait("@filterValues");
-
- cy.findByPlaceholderText("Search the list").type("Awe");
-
- selectFromDropdown(["Awesome Concrete Shoes", "Awesome Iron Hat"]);
-
- cy.button("Add filter").click();
-
- cy.location("search").should(
- "eq",
- "?text=Awesome+Concrete+Shoes&text=Awesome+Iron+Hat",
- );
-
- H.filterWidget().contains("2 selections");
-
- cy.findByTestId("dashcard").within(() => {
- cy.findAllByText("Awesome Concrete Shoes");
- cy.findAllByText("Awesome Iron Hat");
- });
- });
-});
-
-function selectFromDropdown(values) {
- values.forEach((value) => {
- cy.findByLabelText(value).should("be.visible").click();
- });
-}
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-nested.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-nested.cy.spec.js
deleted file mode 100644
index de2240c13f3..00000000000
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-nested.cy.spec.js
+++ /dev/null
@@ -1,136 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { PRODUCTS_ID } = SAMPLE_DATABASE;
-
-describe("scenarios > dashboard > filters > nested questions", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
- });
-
- it("dashboard filters should work on nested question (metabase#12614, metabase#13186, metabase#18113, metabase#32126)", () => {
- const filter = {
- name: "Text Filter",
- slug: "text",
- id: "27454068",
- type: "string/=",
- sectionId: "string",
- };
-
- H.createNativeQuestion({
- name: "18113 Source",
- native: {
- query: "select * from products limit 5",
- },
- display: "table",
- }).then(({ body: { id: Q1_ID } }) => {
- const nestedQuestion = {
- name: "18113 Nested",
- query: {
- "source-table": `card__${Q1_ID}`,
- },
- };
-
- const dashboardDetails = {
- name: "Nested Filters",
- parameters: [filter],
- };
-
- H.createQuestionAndDashboard({
- questionDetails: nestedQuestion,
- dashboardDetails,
- }).then(({ body: { dashboard_id } }) => {
- H.visitDashboard(dashboard_id);
- });
- });
-
- H.editDashboard();
- H.filterWidget({ isEditing: true, name: filter.name }).click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Select…").click();
-
- // This part reproduces metabase#13186
- cy.log("Reported failing in v0.36.4 (`Category` is missing)");
- H.popover().within(() => {
- cy.findByText(/Ean/i);
- cy.findByText(/Title/i);
- cy.findByText(/Vendor/i);
- cy.findByText(/Category/i).click();
- });
-
- H.saveDashboard();
-
- // Add multiple values (metabase#18113)
- H.filterWidget().click();
- H.dashboardParametersPopover().within(() => {
- H.fieldValuesCombobox().type("Gizmo,Gadget").blur();
- });
-
- cy.button("Add filter").click();
- cy.wait("@dashcardQuery");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("2 selections");
- H.tableInteractiveBody().findAllByRole("row").should("have.length", 2);
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Doohickey").should("not.exist");
-
- cy.reload();
- cy.wait("@dashcardQuery");
-
- cy.location("search").should("eq", "?text=Gizmo&text=Gadget");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("2 selections");
-
- H.editDashboard();
- H.filterWidget({ isEditing: true, name: filter.name }).click();
-
- H.getDashboardCard().within(() => {
- cy.findByText("Column to filter on");
- cy.findByText("18113 Source.CATEGORY").click();
- });
-
- // This part reproduces metabase#12614
- H.popover().within(() => {
- cy.findByText(/Ean/i);
- cy.findByText(/Title/i);
- cy.findByText(/Vendor/i);
- cy.findByText(/Category/i).click();
- });
- });
-
- it("should be possible to use ID filter on a nested question (metabase#17212)", () => {
- const baseQuestion = {
- query: { "source-table": PRODUCTS_ID },
- };
-
- H.createQuestion(baseQuestion).then(({ body: { id: baseQuestionId } }) => {
- const questionDetails = {
- query: { "source-table": `card__${baseQuestionId}` },
- };
-
- H.createQuestionAndDashboard({ questionDetails }).then(
- ({ body: { dashboard_id } }) => {
- H.visitDashboard(dashboard_id);
- },
- );
- });
-
- H.editDashboard();
-
- H.setFilter("ID");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("No valid fields").should("not.exist");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Select…").click();
- H.popover().contains("ID").click();
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-number-source.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-number-source.cy.spec.js
index 45a6ee28ffa..f1c78117e56 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-number-source.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-number-source.cy.spec.js
@@ -2,15 +2,7 @@ const { H } = cy;
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";
-const { ACCOUNTS, ORDERS_ID } = SAMPLE_DATABASE;
-
-const targetParameter = {
- id: "f8ec7c71",
- type: "number/=",
- name: "Number",
- slug: "number",
- sectionId: "number",
-};
+const { ORDERS_ID } = SAMPLE_DATABASE;
const targetQuestion = {
display: "scalar",
@@ -47,45 +39,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
H.filterWidget().findByText("Twenty").should("be.visible");
H.getDashboardCard().findByText("4").should("be.visible");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard(),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
-
- filterDashboard({ isDropdown: true });
- H.filterWidget().findByText("Twenty").should("be.visible");
- });
-
- it("should be able to use a static list source when embedded", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard(),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
-
- filterDashboard({ isDropdown: true });
- H.filterWidget().findByText("Twenty").should("be.visible");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard(),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
-
- filterDashboard({ isDropdown: true });
- H.filterWidget().findByText("Twenty").should("be.visible");
- });
});
describe("static list source (search)", () => {
@@ -108,32 +61,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
filterDashboard({ isLabeled: true });
H.filterWidget().findByText("Twenty").should("be.visible");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard("search"),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
-
- filterDashboard({ isLabeled: true });
- H.filterWidget().findByText("Twenty").should("be.visible");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard("search"),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
-
- filterDashboard({ isLabeled: true });
- H.filterWidget().findByText("Twenty").should("be.visible");
- });
});
describe("card source (dropdown)", () => {
@@ -241,41 +168,3 @@ const filterDashboard = ({ isLabeled = false, isDropdown = false } = {}) => {
cy.button("Add filter").click();
});
};
-
-const getDashboardResource = ({ dashboard_id }) => ({
- resource: { dashboard: dashboard_id },
- params: {},
-});
-
-const getTargetDashboard = (sourceSettings) => ({
- parameters: [
- {
- ...targetParameter,
- ...sourceSettings,
- },
- ],
- enable_embedding: true,
- embedding_params: {
- [targetParameter.slug]: "enabled",
- },
-});
-
-const getListDashboard = (values_query_type) => {
- return getTargetDashboard({
- values_source_type: "static-list",
- values_query_type,
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- });
-};
-
-const getParameterMapping = ({ card_id }) => ({
- parameter_mappings: [
- {
- card_id,
- parameter_id: targetParameter.id,
- target: ["dimension", ["field", ACCOUNTS.SEATS, null]],
- },
- ],
-});
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-source.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-source.cy.spec.js
index eba094a92d7..ede1dac2cfb 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-source.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-source.cy.spec.js
@@ -1,5 +1,5 @@
const { H } = cy;
-import { USER_GROUPS, WRITABLE_DB_ID } from "e2e/support/cypress_data";
+import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
@@ -21,14 +21,6 @@ const nativeSourceQuestion = {
},
};
-const targetParameter = {
- id: "f8ec7c71",
- type: "string/=",
- name: "Text",
- slug: "text",
- sectionId: "string",
-};
-
const targetQuestion = {
display: "scalar",
query: {
@@ -64,38 +56,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
archiveQuestion();
});
- it("should be able to use a structured question source when embedded", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: questionId } }) => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getStructuredDashboard(questionId),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
- },
- );
-
- filterDashboard();
- });
-
- it("should be able to use a structured question source when public", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: questionId } }) => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getStructuredDashboard(questionId),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
- },
- );
-
- filterDashboard();
- });
-
it("should be able to use a structured question source with string/contains parameter", () => {
H.createQuestion(structuredSourceQuestion, { wrapId: true });
H.createQuestionAndDashboard({
@@ -254,38 +214,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
cy.get("@questionId").then(H.visitQuestion);
archiveQuestion();
});
-
- it("should be able to use a native question source when embedded", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: questionId } }) => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getNativeDashboard(questionId),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
- },
- );
-
- filterDashboard();
- });
-
- it("should be able to use a native question source when public", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: questionId } }) => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getNativeDashboard(questionId),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
- },
- );
-
- filterDashboard();
- });
});
describe("static list source (dropdown)", () => {
@@ -306,32 +234,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
filterDashboard({ isLabeled: true });
H.filterWidget().findByText("Gizmo Label").should("be.visible");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard(),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
-
- filterDashboard({ isLabeled: true });
- H.filterWidget().findByText("Gizmo Label").should("be.visible");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard(),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
-
- filterDashboard({ isLabeled: true });
- H.filterWidget().findByText("Gizmo Label").should("be.visible");
- });
});
describe("static list source (search)", () => {
@@ -353,31 +255,6 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {
setSearchFilter("Gizmo Label");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard("search"),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitEmbeddedPage(getDashboardResource(card));
- });
-
- setSearchFilter("Gizmo Label");
- H.filterWidget().findByText("Gizmo Label").should("be.visible");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getListDashboard("search"),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- H.visitPublicDashboard(card.dashboard_id);
- });
-
- setSearchFilter("Gizmo Label");
- });
});
describe("field source", () => {
@@ -486,53 +363,12 @@ describe(
},
);
-describe("scenarios > dashboard > filters", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- H.blockUserGroupPermissions(USER_GROUPS.ALL_USERS_GROUP);
- });
-
- it("should sandbox parameter values in dashboards", () => {
- cy.sandboxTable({
- table_id: PRODUCTS_ID,
- attribute_remappings: {
- attr_uid: ["dimension", ["field", PRODUCTS.ID, null]],
- },
- });
-
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: questionId } }) => {
- H.createQuestionAndDashboard({
- questionDetails: targetQuestion,
- dashboardDetails: getStructuredDashboard(questionId),
- }).then(({ body: card }) => {
- H.editDashboardCard(card, getParameterMapping(card));
- cy.signOut();
- cy.signInAsSandboxedUser();
- H.visitDashboard(card.dashboard_id);
- H.assertDatasetReqIsSandboxed({
- requestAlias: `@dashcardQuery${card.id}`,
- });
- });
- },
- );
-
- filterDashboard({ isSandboxed: true });
- });
-});
-
const mapFilterToQuestion = (column = "Category") => {
cy.findByText("Select…").click();
H.popover().within(() => cy.findByText(column).click());
};
-const filterDashboard = ({
- isField = false,
- isSandboxed = false,
- isLabeled = false,
-} = {}) => {
+const filterDashboard = ({ isField = false, isLabeled = false } = {}) => {
cy.findByText("Text").click();
H.popover().within(() => {
@@ -540,12 +376,12 @@ const filterDashboard = ({
cy.findByText(GIZMO).should("be.visible");
cy.findByText("Doohickey").should(isField ? "be.visible" : "not.exist");
- cy.findByText("Gadget").should(isSandboxed ? "not.exist" : "be.visible");
- cy.findByText("Widget").should(isSandboxed ? "not.exist" : "be.visible");
+ cy.findByText("Gadget").should("be.visible");
+ cy.findByText("Widget").should("be.visible");
cy.findByPlaceholderText("Search the list").type("i");
cy.findByText("Gadget").should("not.exist");
- cy.findByText("Widget").should(isSandboxed ? "not.exist" : "be.visible");
+ cy.findByText("Widget").should("be.visible");
cy.findByText("Doohickey").should(isField ? "be.visible" : "not.exist");
cy.findByText(GIZMO).click();
@@ -565,64 +401,6 @@ const archiveQuestion = () => {
);
};
-const getDashboardResource = ({ dashboard_id }) => ({
- resource: { dashboard: dashboard_id },
- params: {},
-});
-
-const getTargetDashboard = (sourceSettings) => ({
- parameters: [
- {
- ...targetParameter,
- ...sourceSettings,
- },
- ],
- enable_embedding: true,
- embedding_params: {
- [targetParameter.slug]: "enabled",
- },
-});
-
-const getStructuredDashboard = (questionId) => {
- return getTargetDashboard({
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", PRODUCTS.CATEGORY, null],
- },
- });
-};
-
-const getNativeDashboard = (questionId) => {
- return getTargetDashboard({
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", "CATEGORY", { "base-type": "type/Text" }],
- },
- });
-};
-
-const getListDashboard = (values_query_type) => {
- return getTargetDashboard({
- values_source_type: "static-list",
- values_query_type,
- values_source_config: {
- values: [["Gadget"], ["Gizmo", "Gizmo Label"], "Widget"],
- },
- });
-};
-
-const getParameterMapping = ({ card_id }) => ({
- parameter_mappings: [
- {
- card_id,
- parameter_id: targetParameter.id,
- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- },
- ],
-});
-
function setSearchFilter(label) {
H.filterWidget().click();
H.popover().within(() => {
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-date.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-date.cy.spec.js
deleted file mode 100644
index a73f5ec7439..00000000000
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-date.cy.spec.js
+++ /dev/null
@@ -1,121 +0,0 @@
-const { H } = cy;
-
-import * as DateFilter from "../native-filters/helpers/e2e-date-filter-helpers";
-
-import {
- DASHBOARD_SQL_DATE_FILTERS,
- questionDetails,
-} from "./shared/dashboard-filters-sql-date";
-
-describe("scenarios > dashboard > filters > SQL > date", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { card_id, dashboard_id } }) => {
- H.visitQuestion(card_id);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- });
-
- it("should work when set through the filter widget", () => {
- Object.entries(DASHBOARD_SQL_DATE_FILTERS).forEach(([filter]) => {
- cy.log(`Make sure we can connect ${filter} filter`);
- H.setFilter("Date picker", filter);
-
- cy.findByText("Select…").click();
- H.popover().contains(filter).click();
- });
-
- H.saveDashboard();
-
- Object.entries(DASHBOARD_SQL_DATE_FILTERS).forEach(
- ([filter, { value, representativeResult }], index) => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.filterWidget().eq(index).click();
- dateFilterSelector({
- filterType: filter,
- filterValue: value,
- });
-
- cy.log(`Make sure ${filter} filter returns correct result`);
- cy.findByTestId("dashcard").within(() => {
- cy.contains(representativeResult);
- });
-
- H.clearFilterWidget(index);
- cy.wait("@dashcardQuery");
- },
- );
- });
-
- it("should work when set as the default filter", () => {
- H.setFilter("Date picker", "Month and Year");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Default value").next().click();
- DateFilter.setMonthAndYear({
- month: "Oct",
- year: "2025",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Select…").click();
- H.popover().contains("Month and Year").click();
- H.saveDashboard();
-
- // The default value should immediately be applied
- cy.findByTestId("dashcard").within(() => {
- cy.contains("Dagmar Fay");
- });
-
- // Make sure we can override the default value
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("October 2025").click();
- H.popover().contains("Aug").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Macy Olson");
- });
-});
-
-function dateFilterSelector({ filterType, filterValue } = {}) {
- switch (filterType) {
- case "Month and Year":
- DateFilter.setMonthAndYear(filterValue);
- break;
-
- case "Quarter and Year":
- DateFilter.setQuarterAndYear(filterValue);
- break;
-
- case "Single Date":
- DateFilter.setSingleDate(filterValue);
- cy.findByText("Add filter").click();
- break;
-
- case "Date Range":
- DateFilter.setDateRange(filterValue);
- cy.findByText("Add filter").click();
- break;
-
- case "Relative Date":
- DateFilter.setRelativeDate(filterValue);
- break;
-
- case "All Options":
- DateFilter.setAdHocFilter(filterValue);
- break;
-
- default:
- throw new Error("Wrong filter type!");
- }
-}
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js
deleted file mode 100644
index 14d70c6e167..00000000000
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js
+++ /dev/null
@@ -1,105 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-import { addWidgetStringFilter } from "../native-filters/helpers/e2e-field-filter-helpers";
-
-const { ORDERS } = SAMPLE_DATABASE;
-
-describe("scenarios > dashboard > filters > SQL > ID", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- describe("should work for the primary key", () => {
- beforeEach(() => {
- prepareDashboardWithFilterConnectedTo(ORDERS.ID);
- });
-
- it("when set through the filter widget", () => {
- H.saveDashboard();
-
- H.filterWidget().click();
- addWidgetStringFilter("15");
-
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("114.42");
- });
- });
-
- it("when set as the default filter", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Default value").next().click();
- addWidgetStringFilter("15");
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("114.42");
- });
- });
- });
-
- describe("should work for the foreign key", () => {
- beforeEach(() => {
- prepareDashboardWithFilterConnectedTo(ORDERS.USER_ID);
- });
-
- it("when set through the filter widget", () => {
- H.saveDashboard();
-
- H.filterWidget().click();
- addWidgetStringFilter("4");
-
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("47.68");
- });
- });
-
- it("when set as the default filter", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Default value").next().click();
- addWidgetStringFilter("4");
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("47.68");
- });
- });
- });
-});
-
-function prepareDashboardWithFilterConnectedTo(rowId) {
- const questionDetails = {
- name: "SQL with ID filter",
- native: {
- query: "select * from ORDERS where {{filter}}",
- "template-tags": {
- filter: {
- id: "3ff86eea-2559-5ab7-af10-e532a54661c5",
- name: "filter",
- "display-name": "Filter",
- type: "dimension",
- dimension: ["field", rowId, null],
- "widget-type": "id",
- default: null,
- },
- },
- },
- };
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { card_id, dashboard_id } }) => {
- H.visitQuestion(card_id);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- H.setFilter("ID");
-
- cy.findByText("Select…").click();
- H.popover().contains("Filter").click();
-}
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-location.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-location.cy.spec.js
deleted file mode 100644
index d0c82be05dc..00000000000
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-location.cy.spec.js
+++ /dev/null
@@ -1,90 +0,0 @@
-const { H } = cy;
-
-import {
- addWidgetStringFilter,
- applyFilterByType,
- selectFilterValueFromList,
-} from "../native-filters/helpers/e2e-field-filter-helpers";
-
-import {
- DASHBOARD_SQL_LOCATION_FILTERS,
- questionDetails,
-} from "./shared/dashboard-filters-sql-location";
-
-describe("scenarios > dashboard > filters > location", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { card_id, dashboard_id } }) => {
- H.visitQuestion(card_id);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- });
-
- it("should work when set through the filter widget", () => {
- Object.entries(DASHBOARD_SQL_LOCATION_FILTERS).forEach(([filter]) => {
- H.setFilter("Location", filter);
-
- cy.findByText("Select…").click();
- H.popover().contains(filter).click();
- });
-
- H.saveDashboard();
-
- Object.entries(DASHBOARD_SQL_LOCATION_FILTERS).forEach(
- ([filter, { value, representativeResult }], index) => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.filterWidget().eq(index).click();
- applyFilterByType(filter, value, { search: true });
-
- cy.findByTestId("dashcard").within(() => {
- cy.contains(representativeResult);
- });
-
- H.clearFilterWidget(index);
- cy.wait("@dashcardQuery");
- },
- );
- });
-
- it("should work when set as the default filter", () => {
- H.setFilter("Location", "Is");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Select…").click();
- H.popover().contains("Is").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Default value").next().click();
-
- selectFilterValueFromList("Rye", { search: true });
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").within(() => {
- cy.contains("Arnold Adams");
- });
-
- H.clearFilterWidget();
-
- cy.url().should("not.include", "Rye");
-
- H.filterWidget().click();
-
- addWidgetStringFilter("Pittsburg", { buttonLabel: "Update filter" });
-
- cy.findByTestId("dashcard").within(() => {
- cy.contains("Aracely Jenkins");
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-number.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-number.cy.spec.js
index f71798ffda3..0e726991276 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-number.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-number.cy.spec.js
@@ -1,90 +1,5 @@
const { H } = cy;
-import { addWidgetNumberFilter } from "../native-filters/helpers/e2e-field-filter-helpers";
-
-import {
- DASHBOARD_SQL_NUMBER_FILTERS,
- questionDetails,
-} from "./shared/dashboard-filters-sql-number";
-
-describe("scenarios > dashboard > filters > SQL > text/category", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { card_id, dashboard_id } }) => {
- H.visitQuestion(card_id);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- });
-
- it("should work when set through the filter widget", () => {
- Object.entries(DASHBOARD_SQL_NUMBER_FILTERS).forEach(([filter]) => {
- cy.log(`Make sure we can connect ${filter} filter`);
-
- H.setFilter("Number", filter);
-
- clickSelect();
- H.popover().contains(filter).click();
- });
-
- H.saveDashboard();
-
- Object.entries(DASHBOARD_SQL_NUMBER_FILTERS).forEach(
- ([filter, { value, representativeResult }], index) => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.filterWidget().eq(index).click();
- addWidgetNumberFilter(value);
-
- cy.log(`Make sure ${filter} filter returns correct result`);
- cy.findByTestId("dashcard").within(() => {
- cy.contains(representativeResult);
- });
-
- H.clearFilterWidget(index);
- cy.wait("@dashcardQuery");
- },
- );
- });
-
- it("should work when set as the default filter", () => {
- H.setFilter("Number", "Equal to");
- H.sidebar().findByText("Default value").next().click();
-
- addWidgetNumberFilter("3.8");
-
- clickSelect();
- H.popover().contains("Equal to").click();
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").within(() => {
- cy.contains("Small Marble Hat");
- cy.contains("Rustic Paper Wallet").should("not.exist");
- });
-
- H.clearFilterWidget();
-
- H.filterWidget().click();
-
- addWidgetNumberFilter("4.6", { buttonLabel: "Update filter" });
-
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("Ergonomic Linen Toucan");
- cy.contains("Small Marble Hat").should("not.exist");
- });
- });
-});
-
describe("scenarios > dashboard > filters > SQL > number", () => {
const questionDetails = {
name: "Question 1",
@@ -184,95 +99,3 @@ describe("scenarios > dashboard > filters > SQL > number", () => {
.and("contain", "4.4");
});
});
-
-describe("scenarios > dashboard > filters > SQL > number and multiple values", () => {
- const questionDetails = {
- name: "SQL",
- native: {
- query: "SELECT ID FROM products WHERE ID IN ({{number}})",
- "template-tags": {
- number: {
- id: "49596bcb-62bb-49d6-a92d-bf5dbfddf43b",
- name: "number",
- "display-name": "Number",
- type: "number",
- },
- },
- },
- };
-
- const parameterDetails = {
- id: "49596bcb-62bb-49d6-a92d-bf5dbfddf43b",
- type: "number/=",
- name: "Number",
- slug: "number",
- isMultiSelect: true,
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- enable_embedding: true,
- embedding_params: {
- number: "enabled",
- },
- };
-
- function setFilterAndVerify({ values } = {}) {
- H.filterWidget().click();
- H.popover().within(() => {
- H.multiAutocompleteInput().type(values.join(","));
- cy.button("Add filter").click();
- });
- values.forEach((value) => {
- H.getDashboardCard().within(() => {
- cy.findAllByText(value).should("have.length.gte", 1);
- cy.findAllByText(value).should("have.length.gte", 1);
- });
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow multiple values for Number variables", () => {
- cy.log("create a dashboard");
- H.createNativeQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashcard }) => {
- cy.wrap(dashcard.dashboard_id).as("dashboardId");
- });
-
- cy.log("set mapping");
- H.visitDashboard("@dashboardId");
- H.editDashboard();
- cy.findByTestId("fixed-width-filters").findByText("Number").click();
- H.selectDashboardFilter(H.getDashboardCard(), "Number");
- H.sidebar().findByLabelText("Multiple values").click();
- H.saveDashboard();
-
- cy.log("regular dashboard");
- setFilterAndVerify({ values: ["10", "20"] });
-
- cy.log("public dashboard");
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitPublicDashboard(dashboardId),
- );
- setFilterAndVerify({ values: ["10", "20"] });
-
- cy.log("embedded dashboard");
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitEmbeddedPage({
- resource: { dashboard: dashboardId },
- params: {},
- }),
- );
- setFilterAndVerify({ values: ["10", "20"] });
- });
-});
-
-function clickSelect() {
- H.getDashboardCard().findByText("Select…").click();
-}
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-field-filter.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-field-filter.cy.spec.js
index 04b8a130716..81d793b3dab 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-field-filter.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-field-filter.cy.spec.js
@@ -47,50 +47,6 @@ describe("scenarios > dashboard > filters > SQL > field filter > required ", ()
cy.signInAsAdmin();
});
- it("should apply default of the SQL field filter if the dashboard doesn't have a filter connected to it", () => {
- H.createNativeQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashboardCard }) => {
- const { dashboard_id } = dashboardCard;
- H.visitDashboard(dashboard_id);
- });
-
- // the native SQL filter is not mapped to the dashcard filter
- // the results should show the default value was applied
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("Gizmo");
- cy.contains("Widget").should("not.exist");
- });
- });
-
- it("should apply default of the SQL field filter if the dashboard filter is empty", () => {
- H.createNativeQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashboardCard }) => {
- const { card_id, dashboard_id } = dashboardCard;
- const mapFilterToCard = {
- parameter_mappings: [
- {
- parameter_id: filter.id,
- card_id,
- target: ["dimension", ["template-tag", "filter"]],
- },
- ],
- };
- H.editDashboardCard(dashboardCard, mapFilterToCard);
- H.visitDashboard(dashboard_id);
- });
-
- H.clearFilterWidget();
-
- // the results should show that the field filter was not applied
- cy.findByTestId("dashcard").within(() => {
- cy.findByText("Doohickey");
- });
- });
-
it("should respect default filter precedence (dashboard filter, then SQL field filters)", () => {
H.createNativeQuestionAndDashboard({
questionDetails: questionDetailsWithRequiredFilter,
diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-text-category.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-text-category.cy.spec.js
index ccafe3b54ab..d63572847a3 100644
--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-text-category.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-text-category.cy.spec.js
@@ -1,188 +1,9 @@
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import { applyFilterByType } from "../native-filters/helpers/e2e-field-filter-helpers";
-
-import {
- DASHBOARD_SQL_TEXT_FILTERS,
- questionDetails,
-} from "./shared/dashboard-filters-sql-text-category";
-
const { H } = cy;
const { PRODUCTS } = SAMPLE_DATABASE;
-describe("scenarios > dashboard > filters > SQL > text/category", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestionAndDashboard({ questionDetails }).then(
- ({ body: { card_id, dashboard_id } }) => {
- H.visitQuestion(card_id);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- });
-
- it("should work when set through the filter widget", () => {
- Object.entries(DASHBOARD_SQL_TEXT_FILTERS).forEach(([filter]) => {
- cy.log(`Make sure we can connect ${filter} filter`);
- H.setFilter("Text or Category", filter);
-
- cy.findByText("Select…").click();
- H.popover().contains(filter).click();
- });
-
- H.saveDashboard();
-
- Object.entries(DASHBOARD_SQL_TEXT_FILTERS).forEach(
- ([filter, { value, representativeResult }], index) => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.filterWidget().eq(index).click();
-
- if (["Is", "Is not"].includes(filter)) {
- cy.log("Wait for the correct popover to appear");
- cy.findByPlaceholderText(/search the list/i).should("be.visible");
- }
- applyFilterByType(filter, value);
-
- cy.log(`Make sure ${filter} filter returns correct result`);
- cy.findByTestId("dashcard").within(() => {
- cy.contains(representativeResult);
- });
-
- H.clearFilterWidget(index);
- cy.wait("@dashcardQuery");
- },
- );
- });
-
- it("should work when set as the default filter and when that filter is removed (metabase#20493)", () => {
- H.setFilter("Text or Category", "Is");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Select…").click();
- H.popover().contains("Is").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Default value").next().click();
-
- applyFilterByType("Is", "Gizmo");
-
- H.saveDashboard();
-
- cy.findByTestId("dashcard").within(() => {
- cy.contains("Rustic Paper Wallet");
- });
-
- H.clearFilterWidget();
-
- cy.url().should("not.include", "Gizmo");
-
- H.filterWidget().click();
-
- applyFilterByType("Is", "Doohickey", { buttonLabel: "Update filter" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Rustic Paper Wallet").should("not.exist");
- });
-});
-
-describe("scenarios > dashboard > filters > SQL > text and multiple values", () => {
- const questionDetails = {
- name: "SQL",
- native: {
- query: "SELECT ID, CATEGORY FROM products WHERE CATEGORY IN ({{text}})",
- "template-tags": {
- text: {
- id: "49596bcb-62bb-49d6-a92d-bf5dbfddf43b",
- name: "text",
- "display-name": "Text",
- type: "text",
- },
- },
- },
- };
-
- const parameterDetails = {
- id: "49596bcb-62bb-49d6-a92d-bf5dbfddf43b",
- type: "string/=",
- name: "Text",
- slug: "text",
- isMultiSelect: true,
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- enable_embedding: true,
- embedding_params: {
- text: "enabled",
- },
- };
-
- function setFilterAndVerify({ values } = {}) {
- H.filterWidget().click();
- H.popover().within(() => {
- H.multiAutocompleteInput().type(values.join(","));
- cy.button("Add filter").click();
- });
- values.forEach((value) => {
- H.getDashboardCard().within(() => {
- cy.findAllByText(value).should("have.length.gte", 1);
- cy.findAllByText(value).should("have.length.gte", 1);
- });
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow multiple values for Number variables", () => {
- cy.log("create a dashboard");
- H.createNativeQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashcard }) => {
- cy.wrap(dashcard.dashboard_id).as("dashboardId");
- });
-
- cy.log("set mapping");
- H.visitDashboard("@dashboardId");
- H.editDashboard();
- cy.findByTestId("fixed-width-filters").findByText("Text").click();
- H.selectDashboardFilter(H.getDashboardCard(), "Text");
- H.sidebar().findByLabelText("Multiple values").click();
- H.saveDashboard();
-
- cy.log("saved dashboard");
- setFilterAndVerify({ values: ["Gadget", "Widget"] });
-
- cy.log("public dashboard");
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitPublicDashboard(dashboardId),
- );
- setFilterAndVerify({ values: ["Gadget", "Widget"] });
-
- cy.log("embedded dashboard");
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitEmbeddedPage({
- resource: { dashboard: dashboardId },
- params: {},
- }),
- );
- setFilterAndVerify({ values: ["Gadget", "Widget"] });
- });
-});
-
describe("issue 68998", { tags: "@external" }, () => {
const sqlQueryDetails = `SELECT
PRODUCTS.CATEGORY,
diff --git a/e2e/test/scenarios/dashboard-filters/old-parameters.cy.spec.js b/e2e/test/scenarios/dashboard-filters/old-parameters.cy.spec.js
deleted file mode 100644
index 9c7e3104fc7..00000000000
--- a/e2e/test/scenarios/dashboard-filters/old-parameters.cy.spec.js
+++ /dev/null
@@ -1,207 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { PEOPLE, PEOPLE_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
-
-// the dashboard parameters used in these tests ('category' and 'location/...') are no longer accessible
-// via the UI but should still work as expected
-
-describe("scenarios > dashboard > OLD parameters", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- describe("question connected to a 'category' parameter", () => {
- beforeEach(() => {
- const filter = {
- id: "c2967a17",
- name: "Category",
- slug: "category",
- type: "category",
- };
-
- const questionDetails = {
- name: "Products table",
- query: {
- "source-table": PRODUCTS_ID,
- },
- };
-
- const dashboardDetails = {
- parameters: [filter],
- };
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: { id, card_id, dashboard_id } }) => {
- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
- dashcards: [
- {
- id,
- card_id,
- row: 0,
- col: 0,
- size_x: 11,
- size_y: 6,
- parameter_mappings: [
- {
- card_id,
- parameter_id: filter.id,
- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- },
- ],
- },
- ],
- });
-
- H.visitDashboard(dashboard_id);
- },
- );
- });
-
- it("should work", () => {
- cy.findAllByText("Doohickey");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Category").click();
- H.popover().within(() => {
- cy.findByText("Gadget").click();
- cy.findByText("Add filter").click();
- });
-
- // verify that the filter is applied
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Doohickey").should("not.exist");
- });
- });
-
- describe("question connected to a 'location/state' parameter", () => {
- beforeEach(() => {
- const filter = {
- id: "c2967a17",
- name: "City",
- slug: "city",
- type: "location/city",
- };
-
- const questionDetails = {
- name: "People table",
- query: {
- "source-table": PEOPLE_ID,
- },
- };
-
- const dashboardDetails = { parameters: [filter] };
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: { id, card_id, dashboard_id } }) => {
- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
- dashcards: [
- {
- id,
- card_id,
- row: 0,
- col: 0,
- size_x: 11,
- size_y: 6,
- parameter_mappings: [
- {
- card_id,
- parameter_id: filter.id,
- target: ["dimension", ["field", PEOPLE.CITY, null]],
- },
- ],
- },
- ],
- });
-
- H.visitDashboard(dashboard_id);
- },
- );
- });
-
- it("should work", () => {
- cy.findByLabelText("City").click();
- H.dashboardParametersPopover().within(() => {
- H.fieldValuesCombobox().type("Flagstaff{enter}{esc}");
- cy.findByText("Add filter").click();
- });
-
- H.assertTableRowsCount(1);
- });
- });
-
- describe("native question field filter connected to 'category' parameter", () => {
- beforeEach(() => {
- const filter = {
- id: "c2967a17",
- name: "Category",
- slug: "category",
- type: "category",
- };
-
- const questionDetails = {
- name: "Products SQL",
- native: {
- query: "select * from products where {{category}}",
- "template-tags": {
- category: {
- "display-name": "Field Filter",
- id: "abc123",
- name: "category",
- type: "dimension",
- "widget-type": "category",
- dimension: ["field", PRODUCTS.CATEGORY, null],
- default: ["Doohickey"],
- },
- },
- },
- display: "table",
- };
-
- const dashboardDetails = { parameters: [filter] };
-
- H.createNativeQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: { id, card_id, dashboard_id } }) => {
- cy.request("PUT", `/api/dashboard/${dashboard_id}`, {
- dashcards: [
- {
- id,
- card_id,
- row: 0,
- col: 0,
- size_x: 11,
- size_y: 6,
- parameter_mappings: [
- {
- card_id,
- parameter_id: "c2967a17",
- target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- },
- ],
- },
- ],
- });
-
- H.visitDashboard(dashboard_id);
- });
- });
-
- it("should work", () => {
- cy.findAllByText("Doohickey");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Category").click();
- H.popover().within(() => {
- cy.findByText("Gadget").click();
- cy.findByText("Add filter").click();
- });
-
- // verify that the filter is applied
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Doohickey").should("not.exist");
- });
- });
-});
diff --git a/e2e/test/scenarios/dashboard-filters/parameters.cy.spec.js b/e2e/test/scenarios/dashboard-filters/parameters.cy.spec.js
index f811e7a21b6..a5d9fb4f952 100644
--- a/e2e/test/scenarios/dashboard-filters/parameters.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/parameters.cy.spec.js
@@ -40,71 +40,6 @@ describe("scenarios > dashboard > parameters", () => {
cy.signInAsAdmin();
});
- it("one filter should search across multiple fields", () => {
- cy.intercept("GET", "/api/dashboard/**").as("dashboard");
-
- H.createDashboard({ name: "my dash" }).then(({ body: { id } }) => {
- // add the same question twice
- H.updateDashboardCards({
- dashboard_id: id,
- cards,
- });
-
- H.visitDashboard(id);
- });
-
- H.editDashboard();
-
- // add a category filter
- H.setFilter("Text or Category", "Is");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("A single value").click();
-
- // connect it to people.name and product.category
- // (this doesn't make sense to do, but it illustrates the feature)
- H.selectDashboardFilter(H.getDashboardCard(0), "Name");
-
- H.selectDashboardFilter(H.getDashboardCard(1), "Category");
-
- H.saveDashboard();
-
- // confirm that typing searches both fields
- H.filterWidget().contains("Text").click();
-
- // After typing "Ga", you should see this name!
- H.popover().within(() =>
- cy.findByPlaceholderText("Search the list").type("Ga"),
- );
- cy.wait("@dashboard");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().contains("Gabrielle Considine");
-
- // Continue typing a "d" and you see "Gadget"
- H.popover()
- .first()
- .within(() => cy.findByPlaceholderText("Search the list").type("d"));
- cy.wait("@dashboard");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover()
- .last()
- .within(() => {
- cy.findByText("Gadget").click();
- });
-
- H.popover()
- .first()
- .within(() => {
- cy.button("Add filter").click();
- });
-
- cy.location("search").should("eq", "?text=Gadget");
- cy.findAllByTestId("dashcard-container").first().should("contain", "0");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("dashcard-container").last().should("contain", "4,939");
- });
-
it("should be able to remove parameter (metabase#17933)", () => {
// Mirrored issue in metabase-enterprise#275
@@ -539,73 +474,6 @@ describe("scenarios > dashboard > parameters", () => {
});
});
- it("should be able to use linked filters to limit parameter choices", () => {
- const questionDetails = {
- query: {
- "source-table": PRODUCTS_ID,
- },
- };
-
- const parameter1Details = {
- id: "1b9cd9f1",
- name: "Category filter",
- slug: "category-filter",
- type: "string/=",
- sectionId: "string",
- };
-
- const parameter2Details = {
- id: "1b9cd9f2",
- name: "Vendor filter",
- slug: "vendor-filter",
- type: "string/=",
- sectionId: "string",
- };
-
- const dashboardDetails = {
- parameters: [parameter1Details, parameter2Details],
- };
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: { dashboard_id } }) => {
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(parameter1Details.name).click();
- H.selectDashboardFilter(H.getDashboardCard(), "Category");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(parameter2Details.name).click();
- H.selectDashboardFilter(H.getDashboardCard(), "Vendor");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Linked filters").click();
- H.sidebar().findByRole("switch").parent().get("label").click();
- H.saveDashboard();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(parameter2Details.name).click();
- H.popover().within(() => {
- cy.findByText("Barrows-Johns").should("exist");
- cy.findByText("Balistreri-Ankunding").should("exist");
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(parameter1Details.name).click();
- H.popover().within(() => {
- cy.findByText("Gadget").click();
- cy.button("Add filter").click();
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(parameter2Details.name).click();
- H.popover().within(() => {
- cy.findByText("Barrows-Johns").should("exist");
- cy.findByText("Balistreri-Ankunding").should("not.exist");
- });
- });
-
describe("when parameters are (dis)connected to dashcards", () => {
beforeEach(() => {
createDashboardWithCards({ cards }).then((dashboardId) =>
diff --git a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-1.cy.spec.js b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-1.cy.spec.js
index a46bf164a3e..8c6295add35 100644
--- a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-1.cy.spec.js
@@ -15,10 +15,7 @@ import {
createMockParameter,
} from "metabase-types/api/mocks";
-import {
- setAdHocFilter,
- setQuarterAndYear,
-} from "../native-filters/helpers/e2e-date-filter-helpers";
+import { setAdHocFilter } from "../native-filters/helpers/e2e-date-filter-helpers";
const {
ORDERS,
@@ -799,178 +796,6 @@ describe("issue 17551", () => {
});
});
-describe("issue 17775", () => {
- const questionDetails = {
- query: {
- "source-table": ORDERS_ID,
- expressions: {
- "CC Date": [
- "field",
- ORDERS.CREATED_AT,
- { "base-type": "type/DateTime" },
- ],
- },
- "order-by": [
- ["asc", ["field", ORDERS.ID, { "base-type": "type/BigInteger" }]],
- ],
- },
- };
-
- const parameters = [
- {
- name: "Quarter and Year",
- slug: "quarter_and_year",
- id: "f8ae0c97",
- type: "date/quarter-year",
- sectionId: "date",
- },
- ];
-
- const dashboardDetails = { parameters };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestionAndDashboard({ questionDetails, dashboardDetails }).then(
- ({ body: dashboardCard }) => {
- const { dashboard_id } = dashboardCard;
-
- const updatedSize = { size_x: 21, size_y: 8 };
-
- H.editDashboardCard(dashboardCard, updatedSize);
-
- H.visitDashboard(dashboard_id);
- },
- );
-
- H.editDashboard();
-
- // Make sure filter can be connected to the custom column using UI, rather than using API.
- H.filterWidget({ isEditing: true }).click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Column to filter on")
- .parent()
- .parent()
- .within(() => {
- cy.findByText("Select…").click();
- });
-
- H.popover().within(() => {
- cy.findByText("CC Date").click();
- });
-
- H.saveDashboard();
- });
-
- it("should be able to apply dashboard filter to a custom column (metabase#17775)", () => {
- H.filterWidget().click();
-
- setQuarterAndYear({ quarter: "Q1", year: "2026" });
-
- cy.findAllByText("44.43").should("have.length", 2);
- cy.findAllByText("March 26, 2026, 8:45 AM").should("have.length", 2);
- });
-});
-
-describe("issue 19494", () => {
- const filter1 = {
- name: "Card 1 Filter",
- slug: "card1_filter",
- id: "ab6f631",
- type: "string/=",
- sectionId: "string",
- };
-
- const filter2 = {
- name: "Card 2 Filter",
- slug: "card2_filter",
- id: "a9801ade",
- type: "string/=",
- sectionId: "string",
- };
- function connectFilterToCard({ filterName, cardPosition }) {
- H.filterWidget({ isEditing: true })
- .filter(`:contains("${filterName}")`)
- .click();
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByText("Select…").eq(cardPosition).click();
-
- H.popover().contains("Category").click();
- }
-
- function setDefaultFilter(value) {
- cy.findByText("No default").click();
-
- H.popover().contains(value).click();
-
- cy.button("Add filter").click();
- }
-
- function checkAppliedFilter(name, value) {
- cy.findByText(name, { exact: false })
- .closest('[data-testid="parameter-widget"]')
- .contains(value);
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- // Add two "Orders" questions to the existing "Orders in a dashboard" dashboard
- H.updateDashboardCards({
- dashboard_id: ORDERS_DASHBOARD_ID,
- cards: [
- {
- card_id: ORDERS_QUESTION_ID,
- row: 0,
- col: 0,
- size_x: 11,
- size_y: 8,
- },
- {
- card_id: ORDERS_QUESTION_ID,
- row: 0,
- col: 8,
- size_x: 11,
- size_y: 8,
- },
- ],
- });
-
- // Add two dashboard filters (not yet connected to any of the cards)
- cy.request("PUT", `/api/dashboard/${ORDERS_DASHBOARD_ID}`, {
- parameters: [filter1, filter2],
- });
- });
-
- it("should correctly apply different filters with default values to all cards of the same question (metabase#19494)", () => {
- // Instead of using the API to connect filters to the cards,
- // let's use UI to replicate user experience as closely as possible
- H.visitDashboard(ORDERS_DASHBOARD_ID);
-
- H.editDashboard();
-
- connectFilterToCard({ filterName: "Card 1 Filter", cardPosition: 0 });
- setDefaultFilter("Doohickey");
-
- connectFilterToCard({ filterName: "Card 2 Filter", cardPosition: -1 });
- setDefaultFilter("Gizmo");
-
- H.saveDashboard();
-
- checkAppliedFilter("Card 1 Filter", "Doohickey");
-
- H.getDashboardCard(0).should("contain", "148.23");
-
- checkAppliedFilter("Card 2 Filter", "Gizmo");
-
- H.getDashboardCard(1).should("contain", "110.93");
- });
-});
-
describe("issue 16177", () => {
beforeEach(() => {
H.restore();
@@ -2703,107 +2528,3 @@ describe("issue 42829", () => {
filterAndVerifyResults();
});
});
-
-describe("issue 43799", () => {
- const modelDetails = {
- name: "43799",
- type: "model",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- alias: "People - User",
- condition: [
- "=",
- [
- "field",
- ORDERS.USER_ID,
- {
- "base-type": "type/Integer",
- },
- ],
- [
- "field",
- PEOPLE.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "People - User",
- },
- ],
- ],
- "source-table": PEOPLE_ID,
- },
- ],
- aggregation: [
- [
- "sum",
- [
- "field",
- ORDERS.TOTAL,
- {
- "base-type": "type/Float",
- },
- ],
- ],
- [
- "sum",
- [
- "field",
- ORDERS.SUBTOTAL,
- {
- "base-type": "type/Float",
- },
- ],
- ],
- ],
- breakout: [
- [
- "field",
- PEOPLE.SOURCE,
- {
- "base-type": "type/Text",
- "join-alias": "People - User",
- },
- ],
- [
- "field",
- PRODUCTS.CATEGORY,
- {
- "base-type": "type/Text",
- "source-field": ORDERS.PRODUCT_ID,
- },
- ],
- ],
- },
- };
-
- beforeEach(() => {
- cy.signInAsNormalUser();
- });
-
- it("should be able to map a parameter to an explicitly joined column in the model query", () => {
- H.createDashboardWithQuestions({ questions: [modelDetails] }).then(
- ({ dashboard }) => {
- H.visitDashboard(dashboard.id);
- },
- );
- H.editDashboard();
- cy.findByTestId("dashboard-header")
- .findByLabelText("Add a filter or parameter")
- .click();
- H.popover().findByText("Text or Category").click();
- H.getDashboardCard().findByText("Select…").click();
- H.popover().findByText("People - User → Source").click();
- H.saveDashboard();
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText("Google").click();
- cy.button("Add filter").click();
- });
- H.getDashboardCard().findByText("43799").click();
- cy.findByTestId("qb-filters-panel")
- .findByText("People - User → Source is Google")
- .should("be.visible");
- H.assertQueryBuilderRowCount(4);
- });
-});
diff --git a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-2.cy.spec.js b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-2.cy.spec.js
index c91de3b5b5f..f80af64a554 100644
--- a/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-2.cy.spec.js
+++ b/e2e/test/scenarios/filters-reproductions/dashboard-filters-reproductions-2.cy.spec.js
@@ -1,10 +1,6 @@
const { H } = cy;
-import {
- SAMPLE_DB_ID,
- USER_GROUPS,
- WRITABLE_DB_ID,
-} from "e2e/support/cypress_data";
+import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
ORDERS_DASHBOARD_ID,
@@ -26,142 +22,6 @@ const {
PEOPLE_ID,
} = SAMPLE_DATABASE;
-describe("issue 44288", () => {
- const questionDetails = {
- name: "SQL question",
- type: "question",
- query: { "source-table": PRODUCTS_ID, limit: 10 },
- };
-
- const modelDetails = {
- name: "SQL model",
- type: "model",
- native: { query: "SELECT * FROM PRODUCTS LIMIT 10" },
- };
-
- const parameterDetails = {
- name: "Text",
- slug: "text",
- id: "27454068",
- type: "string/=",
- sectionId: "string",
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- enable_embedding: true,
- embedding_params: {
- [parameterDetails.slug]: "enabled",
- },
- };
-
- function getDashcardDetails(dashboard, question, model) {
- return {
- dashboard_id: dashboard.id,
- cards: [
- {
- card_id: question.id,
- parameter_mappings: [
- {
- card_id: question.id,
- parameter_id: parameterDetails.id,
- target: [
- "dimension",
- ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],
- ],
- },
- ],
- },
- {
- card_id: model.id,
- parameter_mappings: [
- {
- card_id: model.id,
- parameter_id: parameterDetails.id,
- target: [
- "dimension",
- ["field", "CATEGORY", { "base-type": "type/Text" }],
- ],
- },
- ],
- },
- ],
- };
- }
-
- function verifyMapping() {
- cy.findByTestId("edit-dashboard-parameters-widget-container")
- .findByText(parameterDetails.name)
- .click();
- H.getDashboardCard(0).within(() => {
- cy.findByText(/Category/i).should("be.visible");
- });
- H.getDashboardCard(1).within(() => {
- cy.findByText(/Category/i).should("not.exist");
- cy.findByText(/Models are data sources/).should("be.visible");
- });
- }
-
- function verifyFilter() {
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText("Gadget").click();
- cy.button("Add filter").click();
- });
- H.getDashboardCard(0).within(() => {
- cy.findAllByText("Gadget").should("have.length.gte", 1);
- cy.findByText("Doohickey").should("not.exist");
- });
- H.getDashboardCard(1).within(() => {
- cy.findAllByText("Gadget").should("have.length.gte", 1);
- cy.findAllByText("Doohickey").should("have.length.gte", 1);
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.createQuestion(questionDetails).then(({ body: question }) => {
- H.createNativeQuestion(modelDetails).then(({ body: model }) => {
- H.createDashboard(dashboardDetails).then(({ body: dashboard }) => {
- H.updateDashboardCards(
- getDashcardDetails(dashboard, question, model),
- );
- cy.wrap(dashboard.id).as("dashboardId");
- });
- });
- });
- cy.signOut();
- });
-
- it("should ignore parameter mappings to a native model in a dashboard (metabase#44288)", () => {
- cy.log("regular dashboards");
- cy.signInAsNormalUser();
- H.visitDashboard("@dashboardId");
- H.editDashboard();
- verifyMapping();
- H.saveDashboard({ awaitRequest: false });
- verifyFilter();
- cy.signOut();
-
- cy.log("public dashboards");
- cy.signInAsAdmin();
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitPublicDashboard(dashboardId),
- );
- verifyFilter();
-
- cy.log("embedded dashboards");
- cy.get("@dashboardId").then((dashboardId) =>
- H.visitEmbeddedPage({
- resource: { dashboard: dashboardId },
- params: {},
- }),
- );
- verifyFilter();
- });
-});
-
describe("issue 27579", () => {
beforeEach(() => {
H.restore();
@@ -262,143 +122,6 @@ describe("issue 32804", () => {
});
});
-describe("issue 44231", () => {
- const parameterDetails = {
- id: "92eb69ea",
- name: "ID",
- sectionId: "id",
- slug: "id",
- type: "id",
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- enable_embedding: true,
- embedding_params: {
- [parameterDetails.slug]: "enabled",
- },
- };
-
- function getPkCardDetails(type) {
- return {
- name: "Products",
- type,
- query: { "source-table": PRODUCTS_ID },
- };
- }
-
- function getFkCardDetails(type) {
- return {
- name: "Orders",
- type: "model",
- query: { "source-table": ORDERS_ID },
- };
- }
-
- function getDashcardDetails(type, dashboard, pkCard, fkCard) {
- return {
- dashboard_id: dashboard.id,
- cards: [
- {
- card_id: pkCard.id,
- parameter_mappings: [
- {
- card_id: pkCard.id,
- parameter_id: parameterDetails.id,
- target: [
- "dimension",
- [
- "field",
- type === "model" ? "ID" : PRODUCTS.ID,
- { "base-type": "type/BigInteger" },
- ],
- ],
- },
- ],
- },
- {
- card_id: fkCard.id,
- parameter_mappings: [
- {
- card_id: fkCard.id,
- parameter_id: parameterDetails.id,
- target: [
- "dimension",
- [
- "field",
- type === "model" ? "PRODUCT_ID" : ORDERS.PRODUCT_ID,
- { "base-type": "type/BigInteger" },
- ],
- ],
- },
- ],
- },
- ],
- };
- }
-
- function verifyFilterByRemappedValue() {
- const productId = 144;
- const productName = "Aerodynamic Bronze Hat";
-
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText(productName).click();
- cy.button("Add filter").click();
- });
- H.getDashboardCard(0).findByText(productName).should("be.visible");
- H.getDashboardCard(1)
- .findAllByText(String(productId))
- .should("have.length.above", 0);
- }
-
- function verifyFieldMapping(type) {
- H.createDashboardWithQuestions({
- dashboardDetails,
- questions: [getPkCardDetails(type), getFkCardDetails(type)],
- }).then(({ dashboard, questions: [pkCard, fkCard] }) => {
- H.updateDashboardCards(
- getDashcardDetails(type, dashboard, pkCard, fkCard),
- );
-
- H.visitDashboard(dashboard.id);
- verifyFilterByRemappedValue();
-
- H.visitPublicDashboard(dashboard.id);
- verifyFilterByRemappedValue();
-
- H.visitEmbeddedPage({
- resource: { dashboard: dashboard.id },
- params: {},
- });
- verifyFilterByRemappedValue();
- });
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- cy.request("PUT", `/api/field/${PRODUCTS.ID}`, {
- has_field_values: "list",
- });
- cy.request("PUT", `/api/field/${ORDERS.PRODUCT_ID}`, {
- has_field_values: "list",
- });
- cy.request("PUT", `/api/field/${PRODUCTS.TITLE}`, {
- semantic_type: "type/Name",
- });
- });
-
- it("should allow filtering by remapped values with questions (metabase#44231)", () => {
- verifyFieldMapping("question");
- });
-
- it("should allow filtering by remapped values with models (metabase#44231)", () => {
- verifyFieldMapping("model");
- });
-});
-
describe("44047", () => {
const questionDetails = {
name: "Question",
@@ -742,122 +465,6 @@ describe("issue 44790", () => {
});
});
-describe("issue 34955", () => {
- function checkAppliedFilter(name, value) {
- cy.contains('[data-testid="parameter-widget"]', name, {
- exact: false,
- }).contains(value);
- }
-
- const ccName = "Custom Created At";
-
- const questionDetails = {
- name: "34955",
- query: {
- "source-table": ORDERS_ID,
- expressions: {
- [ccName]: [
- "field",
- ORDERS.CREATED_AT,
- { "base-type": "type/DateTime" },
- ],
- },
- fields: [
- [
- "field",
- ORDERS.ID,
- {
- "base-type": "type/BigInteger",
- },
- ],
- [
- "field",
- ORDERS.CREATED_AT,
- {
- "base-type": "type/DateTime",
- },
- ],
- [
- "expression",
- ccName,
- {
- "base-type": "type/DateTime",
- },
- ],
- ],
- limit: 2,
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestionAndDashboard({
- questionDetails,
- cardDetails: {
- size_x: 16,
- size_y: 8,
- },
- }).then(({ body: { dashboard_id } }) => {
- cy.wrap(dashboard_id).as("dashboardId");
-
- H.visitDashboard(dashboard_id);
- H.editDashboard();
-
- H.setFilter("Date picker", "Single Date", "On");
- connectFilterToColumn(ccName);
-
- H.setFilter("Date picker", "Date Range", "Between");
- connectFilterToColumn(ccName);
-
- H.saveDashboard();
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByRole("columnheader").eq(-2).should("have.text", "Created At");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByRole("columnheader").eq(-1).should("have.text", ccName);
- H.tableInteractiveBody()
- .findAllByRole("gridcell")
- .filter(":contains(May 15, 2027, 8:04 AM)")
- .should("have.length", 2);
- });
- });
-
- it("should connect specific date filter (`Between`) to the temporal custom column (metabase#34955)", () => {
- cy.get("@dashboardId").then((dashboard_id) => {
- // Apply filter through URL to prevent the typing flakes
- cy.visit(`/dashboard/${dashboard_id}?on=&between=2027-01-01~2027-03-01`);
- checkAppliedFilter("Between", "January 1, 2027 - March 1, 2027");
-
- cy.findAllByTestId("cell-data")
- .filter(":contains(January 1, 2027, 7:26 AM)")
- .should("have.length", 2);
- });
-
- cy.get("@dashboardId").then((dashboard_id) => {
- // Apply filter through URL to prevent the typing flakes
- cy.visit(`/dashboard/${dashboard_id}?on=2027-01-01&between=`);
- checkAppliedFilter("On", "January 1, 2027");
-
- cy.findAllByTestId("cell-data")
- .filter(":contains(January 1, 2027, 7:26 AM)")
- .should("have.length", 2);
- });
- });
-
- function connectFilterToColumn(column) {
- H.getDashboardCard().within(() => {
- cy.findByText("Column to filter on");
- cy.findByText("Select…").click();
- });
-
- H.popover().within(() => {
- cy.findByText(column).click();
- });
- }
-});
-
describe("issue 35852", () => {
const model = {
name: "35852 - sql",
@@ -1479,61 +1086,6 @@ describe("issue 52484", () => {
});
});
-describe("issue 40396", { tags: "@external " }, () => {
- const tableName = "many_data_types";
-
- beforeEach(() => {
- H.restore("postgres-writable");
- H.resetTestTable({ type: "postgres", table: tableName });
- cy.signInAsAdmin();
- H.resyncDatabase({ dbId: WRITABLE_DB_ID });
- cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
- "dashcardQuery",
- );
- });
-
- it("should be possible to use dashboard filters with native enum fields (metabase#40396)", () => {
- cy.log("create a dashboard with a question with a type/Enum field");
- cy.request("GET", "/api/table").then(({ body: tables }) => {
- const table = tables.find((table) => table.name === tableName);
- cy.request("GET", `/api/table/${table.id}/query_metadata`).then(
- ({ body: metadata }) => {
- const field = metadata.fields.find((field) => field.name === "enum");
- cy.request("PUT", `/api/field/${field.id}`, {
- semantic_type: "type/Enum",
- });
-
- H.createQuestionAndDashboard({
- questionDetails: {
- database: table.db_id,
- query: { "source-table": table.id },
- },
- }).then(({ body: { dashboard_id } }) => {
- H.visitDashboard(dashboard_id);
- cy.wait("@dashcardQuery");
- });
- },
- );
- });
-
- cy.log("verify that a enum field can be mapped to a parameter");
- H.editDashboard();
- H.setFilter("Text or Category", "Is");
- H.selectDashboardFilter(H.getDashboardCard(), "Enum");
- H.saveDashboard();
-
- cy.log("verify that filtering on a enum field works");
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText("beta").click();
- cy.button("Add filter").click();
- });
- cy.wait("@dashcardQuery");
- H.tableInteractiveScrollContainer().scrollTo("right");
- H.getDashboardCard().findAllByText("beta").should("have.length.gte", 1);
- });
-});
-
describe("issue 52627", () => {
const questionDetails = {
display: "bar",
@@ -2135,109 +1687,6 @@ describe("issue 44090", () => {
});
});
-describe("issue 47951", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- });
-
- it("should do X (metabase#47951)", () => {
- cy.log("set up permissions");
- cy.updatePermissionsGraph({
- [USER_GROUPS.ALL_USERS_GROUP]: {
- [SAMPLE_DB_ID]: {
- "view-data": "unrestricted",
- "create-queries": "no",
- },
- },
- [USER_GROUPS.DATA_GROUP]: {
- [SAMPLE_DB_ID]: {
- "view-data": "unrestricted",
- "create-queries": "no",
- },
- },
- });
-
- cy.log("set up remapping");
- cy.request("PUT", `/api/field/${ORDERS.PRODUCT_ID}`, {
- has_field_values: "list",
- });
- cy.request("PUT", `/api/field/${REVIEWS.PRODUCT_ID}`, {
- has_field_values: "list",
- });
- cy.request("POST", `/api/field/${ORDERS.PRODUCT_ID}/dimension`, {
- name: "Product ID",
- type: "external",
- human_readable_field_id: PRODUCTS.TITLE,
- });
- cy.request("POST", `/api/field/${REVIEWS.PRODUCT_ID}/dimension`, {
- name: "Product ID",
- type: "external",
- human_readable_field_id: PRODUCTS.TITLE,
- });
-
- cy.log("create a dashboard");
- const parameter = createMockParameter({
- id: "p1",
- slug: "p1",
- type: "id",
- sectionId: "id",
- default: 1,
- });
- H.createDashboardWithQuestions({
- dashboardDetails: {
- parameters: [parameter],
- },
- questions: [
- { name: "q1", query: { "source-table": ORDERS_ID } },
- { name: "q2", query: { "source-table": REVIEWS_ID } },
- ],
- }).then(({ dashboard: dashboard, questions: [card1, card2] }) => {
- H.updateDashboardCards({
- dashboard_id: dashboard.id,
- cards: [
- {
- card_id: card1.id,
- parameter_mappings: [
- {
- card_id: card1.id,
- parameter_id: parameter.id,
- target: ["dimension", ["field", ORDERS.PRODUCT_ID, null]],
- },
- ],
- },
- {
- card_id: card2.id,
- parameter_mappings: [
- {
- card_id: card2.id,
- parameter_id: parameter.id,
- target: ["dimension", ["field", REVIEWS.PRODUCT_ID, null]],
- },
- ],
- },
- ],
- });
- cy.wrap(dashboard.id).as("dashboardId");
- });
-
- cy.log("log in as a normal user and open the dashboard");
- cy.signInAsNormalUser();
- H.visitDashboard("@dashboardId");
-
- cy.log("check remapping for default values");
- H.filterWidget().findByText("Rustic Paper Wallet").should("be.visible");
-
- cy.log("check remapping for dropdown values");
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText("Rustic Paper Wallet").should("be.visible");
- cy.findByText("Aerodynamic Bronze Hat").should("be.visible");
- });
- });
-});
-
describe("issue 59306", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/filters-reproductions/filters-reproductions.cy.spec.js b/e2e/test/scenarios/filters-reproductions/filters-reproductions.cy.spec.js
index 0646b875f9c..d334c928d5f 100644
--- a/e2e/test/scenarios/filters-reproductions/filters-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/filters-reproductions/filters-reproductions.cy.spec.js
@@ -144,38 +144,6 @@ describe("issue 20551", () => {
});
});
});
-
-describe("issue 20683", { tags: "@external" }, () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("should filter postgres with the 'current quarter' filter (metabase#20683)", () => {
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("QA Postgres12").click();
- cy.findByText("Orders").click();
- });
-
- H.getNotebookStep("filter")
- .findByText(/Add filter/)
- .click();
-
- H.popover().within(() => {
- cy.findByText("Created At").click();
- cy.findByText("Relative date range…").click();
- cy.findByText("Previous").click();
- cy.findByText("Current").click();
- cy.findByText("Quarter").click();
- });
-
- H.visualize();
-
- H.queryBuilderMain().findByText("No results").should("be.visible");
- });
-});
-
describe("issue 21979", () => {
beforeEach(() => {
H.restore();
@@ -227,52 +195,6 @@ describe("issue 21979", () => {
.should("be.visible");
});
});
-
-describe("issue 22230", () => {
- const questionDetails = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [["max", ["field", PEOPLE.NAME, null]]],
- breakout: [["field", PEOPLE.SOURCE, null]],
- },
- type: "query",
- display: "table",
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.visitQuestionAdhoc(questionDetails, { mode: "notebook" });
- });
-
- it("should be able to filter on an aggregation (metabase#22230)", () => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().findByText("Filter").click();
-
- H.clauseStepPopover().within(() => {
- cy.findByText("Max of Name").click();
- cy.findByText("Contains").click();
- });
- cy.findByRole("menu").findByText("Starts with").click();
-
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter some text").type("Zo").blur();
- cy.button("Add filter").click();
- });
-
- H.visualize();
-
- H.assertQueryBuilderRowCount(2);
- H.queryBuilderMain(() => {
- cy.findByText("Zora Schamberger").should("be.visible");
- cy.findByText("Zoie Kozey").should("be.visible");
- });
- });
-});
-
describe("issue 22730", () => {
beforeEach(() => {
H.restore();
@@ -434,191 +356,6 @@ describe("issue 45410", () => {
});
});
});
-
-describe("issue 25378", () => {
- const questionDetails = {
- name: "25378",
- 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",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.visitQuestionAdhoc(questionDetails, { mode: "notebook" });
- });
-
- it("should be able to use relative date filter on a breakout after the aggregation (metabase#25378)", () => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().findByText("Filter").click();
-
- H.clauseStepPopover().within(() => {
- cy.findByText("Created At: Month").click();
- cy.findByText("Relative date range…").click();
- cy.findByDisplayValue("days").click();
- });
- cy.findByRole("listbox").findByText("months").click();
-
- H.clauseStepPopover().within(() => {
- cy.findByLabelText("Starting from…").click();
- cy.button("Add filter").click();
- });
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
- });
-});
-
-describe("issue 25927", () => {
- const query = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
- ],
- },
- expressions: {
- "Custom Count": ["field", "count", { "base-type": "type/Integer" }],
- },
- },
- type: "query",
- },
- display: "table",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.visitQuestionAdhoc(query);
- });
-
- it("column filter should work for questions with custom column (metabase#25927)", () => {
- H.tableHeaderClick("Created At: Month");
- H.popover().within(() => {
- cy.findByText("Filter by this column").click();
- cy.findByText("Previous 30 days").click();
- });
-
- cy.wait("@dataset");
-
- // Click on the filter again to try updating it
- cy.findByTestId("qb-filters-panel")
- .contains("Created At: Month is in the previous 30 days")
- .click();
-
- H.popover().button("Update filter").should("not.be.disabled");
- });
-});
-
-describe("issue 25990", () => {
- const questionDetails = {
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People - User" }],
- ],
- alias: "People - User",
- },
- ],
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
- ],
- },
- filter: [">", ["field", "count", { "base-type": "type/Integer" }], 0],
- },
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should allow to filter by a column in a joined table (metabase#25990)", () => {
- H.visitQuestionAdhoc(questionDetails);
-
- H.queryBuilderHeader()
- .button(/Filter/)
- .click();
-
- H.popover().within(() => {
- cy.findByText("People").click();
- cy.findByText("ID").click();
- cy.findByPlaceholderText("Enter an ID").type("10").blur();
- cy.button("Apply filter").click();
- });
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel")
- .findByText("People - User → ID is 10")
- .should("be.visible");
- });
-});
-
-describe("issue 25994", () => {
- const questionDetails = {
- dataset_query: {
- type: "query",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [
- ["min", ["field", PRODUCTS.CREATED_AT, { "temporal-unit": "day" }]],
- ],
- breakout: [["field", PRODUCTS.CATEGORY, null]],
- },
- database: SAMPLE_DB_ID,
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.visitQuestionAdhoc(questionDetails, { mode: "notebook" });
- });
-
- it("should be possible to use 'between' dates filter after aggregation (metabase#25994)", () => {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().findByText("Filter").click();
-
- H.popover().within(() => {
- cy.findByText("Min of Created At: Day").click();
- cy.findByText("Fixed date range…").click();
-
- // It doesn't really matter which dates we select so let's go with whatever is offered
- cy.button("Add filter").click();
- });
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
- });
-});
-
describe("issue 26861", { tags: "@skip" }, () => {
const filter = {
id: "a3b95feb-b6d2-33b6-660b-bb656f59b1d7",
@@ -847,48 +584,6 @@ describe("issue 34794", () => {
.should("be.visible");
});
});
-
-describe("issue 36508", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should treat 'Number of distinct values' aggregation as numerical (metabase#36508)", () => {
- H.createQuestion(
- {
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [
- ["distinct", ["field", PEOPLE.EMAIL, { "base-type": "type/Text" }]],
- ],
- breakout: [["field", PEOPLE.SOURCE, { "base-type": "type/Text" }]],
- limit: 5,
- },
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("qb-header")
- .button(/Filter/)
- .click();
-
- H.popover().within(() => {
- cy.findByText("Summaries").click();
- cy.findByText("Distinct values of Email").click();
- cy.findByText("Between").click();
- });
-
- H.popover()
- .eq(1)
- .within(() => {
- cy.findByText("Equal to").should("exist");
- cy.findByText("Greater than").should("exist");
- cy.findByText("Less than").should("exist");
- });
- });
-});
-
describe("metabase#32985", () => {
const questionDetails = {
database: SAMPLE_DB_ID,
@@ -1145,76 +840,6 @@ describe("issue 45877", () => {
});
});
});
-
-describe("issue 47887", () => {
- beforeEach(() => {
- H.restore("setup");
- cy.signInAsAdmin();
- });
-
- it("Case expression with type/Date default value and type/DateTime case value has Date filter popover enabled (metabase#47887)", () => {
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": PEOPLE_ID,
- expressions: {
- asdfdsa: [
- "case",
- [
- [
- [
- "=",
- [
- "field",
- SAMPLE_DATABASE.PEOPLE.NAME,
- { "base-type": "type/Text" },
- ],
- "Won",
- ],
- [
- "datetime-add",
- [
- "field",
- SAMPLE_DATABASE.PEOPLE.CREATED_AT,
- { "base-type": "type/DateTimeWithLocalTZ" },
- ],
- 0,
- "month",
- ],
- ],
- ],
- {
- default: [
- "datetime-add",
- [
- "field",
- SAMPLE_DATABASE.PEOPLE.BIRTH_DATE,
- { "base-type": "type/Date" },
- ],
- 0,
- "month",
- ],
- },
- ],
- },
- },
- parameters: [],
- },
- });
-
- cy.findByTestId("notebook-button").click();
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().findByText("Filter").click();
-
- H.popover().within(() => {
- cy.findByLabelText("asdfdsa").click();
- cy.findByText("Fixed date range…").click();
- });
- });
-});
-
describe("Issue 48851", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/filters/filter-sources.cy.spec.js b/e2e/test/scenarios/filters/filter-sources.cy.spec.js
deleted file mode 100644
index 5da8424d448..00000000000
--- a/e2e/test/scenarios/filters/filter-sources.cy.spec.js
+++ /dev/null
@@ -1,656 +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, ORDERS_ID, ORDERS } = SAMPLE_DATABASE;
-
-const tableQuestion = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: { "source-table": ORDERS_ID },
- },
- visualization_settings: {},
-};
-
-const tableQuestionWithExpression = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- expressions: {
- Total100: ["+", ["field", ORDERS.TOTAL, null], 100],
- },
- },
- },
- visualization_settings: {},
-};
-
-const tableQuestionWithJoin = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- },
- },
- visualization_settings: {},
-};
-
-const tableQuestionWithJoinAndFields = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- fields: [["field", PRODUCTS.RATING, { "join-alias": "Products" }]],
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- },
- },
-};
-
-const tableWithAggregations = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- ["count"],
- ["sum", ["field", ORDERS.QUANTITY, { "base-type": "type/Integer" }]],
- ],
- breakout: [["field", ORDERS.PRODUCT_ID, { "base-type": "type/Integer" }]],
- },
- },
- visualization_settings: {},
-};
-
-const structuredQuestion = {
- display: "table",
- database: SAMPLE_DB_ID,
- query: { "source-table": ORDERS_ID },
- visualization_settings: {},
-};
-
-const nativeQuestion = {
- display: "table",
- database: SAMPLE_DB_ID,
- native: {
- query: "SELECT * FROM ORDERS",
- },
- visualization_settings: {},
-};
-
-const nestedQuestion = (card) => ({
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${card.id}`,
- },
- },
- visualization_settings: {},
-});
-
-const nestedQuestionWithExpression = (card) => ({
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${card.id}`,
- expressions: {
- Total100: ["+", ["field", "TOTAL", { "base-type": "type/Float" }], 100],
- },
- },
- },
- visualization_settings: {},
-});
-
-const nestedQuestionWithJoin = (card) => ({
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${card.id}`,
- joins: [
- {
- alias: "Products",
- strategy: "left-join",
- fields: "all",
- condition: [
- "=",
- ["field", "PRODUCT_ID", { "base-type": "type/Integer" }],
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products",
- },
- ],
- ],
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- },
- visualization_settings: {},
-});
-
-const nestedQuestionWithJoinAndFields = (card) => ({
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${card.id}`,
- joins: [
- {
- alias: "Products",
- strategy: "left-join",
- fields: [["field", PRODUCTS.RATING, { "join-alias": "Products" }]],
- condition: [
- "=",
- ["field", "PRODUCT_ID", { "base-type": "type/Integer" }],
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products",
- },
- ],
- ],
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- },
- visualization_settings: {},
-});
-
-const nestedQuestionWithAggregations = (card) => ({
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": `card__${card.id}`,
- aggregation: [
- ["count"],
- ["sum", ["field", "QUANTITY", { "base-type": "type/Integer" }]],
- ],
- breakout: [["field", "PRODUCT_ID", { "base-type": "type/Integer" }]],
- },
- },
- visualization_settings: {},
-});
-
-describe("scenarios > filters > filter sources", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- describe("tables", () => {
- it("column from a table", () => {
- H.visitQuestionAdhoc(tableQuestion, { mode: "notebook" });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("Tax").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("6.1");
- cy.button("Add filter").click();
- });
- assertFilterName("Tax is equal to 6.1");
- H.visualize();
- H.assertQueryBuilderRowCount(10);
- });
-
- it("column from an expression based on another table column", () => {
- H.visitQuestionAdhoc(tableQuestionWithExpression, { mode: "notebook" });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("Total100").click();
- H.selectFilterOperator("Greater than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("250.5");
- cy.button("Add filter").click();
- });
- assertFilterName("Total100 is greater than 250.5");
- H.visualize();
- H.assertQueryBuilderRowCount(239);
- });
-
- it("column from an explicit join", () => {
- H.visitQuestionAdhoc(tableQuestionWithJoin, { mode: "notebook" });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Vendor").click();
- cy.findByText("Aufderhar-Boehm").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Vendor is Aufderhar-Boehm");
- H.visualize();
- H.assertQueryBuilderRowCount(95);
- });
-
- it("column from an explicit join with fields", () => {
- H.visitQuestionAdhoc(tableQuestionWithJoinAndFields, {
- mode: "notebook",
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Rating").click();
- });
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("3.7");
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Rating is equal to 3.7");
- H.visualize();
- H.assertQueryBuilderRowCount(883);
- });
-
- it("column from an implicit join", () => {
- H.visitQuestionAdhoc(tableQuestion, { mode: "notebook" });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Product").click();
- cy.findByText("Ean").click();
- });
- H.selectFilterOperator("Is");
- H.clauseStepPopover().within(() => {
- cy.findByText("0001664425970").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Product → Ean is 0001664425970");
- H.visualize();
- H.assertQueryBuilderRowCount(104);
- });
-
- it("column from a nested aggregation without column", () => {
- H.visitQuestionAdhoc(tableWithAggregations, { mode: "notebook" });
- addNewFilter();
- H.clauseStepPopover().findByText("Count").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("90");
- cy.button("Add filter").click();
- });
- assertFilterName("Count is equal to 90", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(7);
- });
-
- it("column from a nested aggregation with column", () => {
- H.visitQuestionAdhoc(tableWithAggregations, { mode: "notebook" });
- addNewFilter();
- H.clauseStepPopover().findByText("Sum of Quantity").click();
- H.selectFilterOperator("Less than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("350");
- cy.button("Add filter").click();
- });
- assertFilterName("Sum of Quantity is less than 350", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(115);
- });
-
- it("column from a nested breakout", () => {
- H.visitQuestionAdhoc(tableWithAggregations, { mode: "notebook" });
- addNewFilter();
- H.clauseStepPopover().within(() => {
- cy.findByText("Product ID").click();
- cy.findByPlaceholderText("Enter an ID").type("10");
- cy.button("Add filter").click();
- });
- assertFilterName("Product ID is 10", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(1);
- });
- });
-
- describe("nested structured questions", () => {
- it("column from a question", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestion(card), { mode: "notebook" });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("Tax").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("6.1");
- cy.button("Add filter").click();
- });
- assertFilterName("Tax is equal to 6.1");
- H.visualize();
- H.assertQueryBuilderRowCount(10);
- });
-
- it("column from an expression based on a question column", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithExpression(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("Total100").click();
- H.selectFilterOperator("Greater than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("250.5");
- cy.button("Add filter").click();
- });
- assertFilterName("Total100 is greater than 250.5");
- H.visualize();
- H.assertQueryBuilderRowCount(239);
- });
-
- it("column from an explicit join", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoin(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Vendor").click();
- cy.findByText("Aufderhar-Boehm").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Vendor is Aufderhar-Boehm");
- H.visualize();
- H.assertQueryBuilderRowCount(95);
- });
-
- it("column from an explicit join with fields", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoinAndFields(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Rating").click();
- });
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("3.7");
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Rating is equal to 3.7");
- H.visualize();
- H.assertQueryBuilderRowCount(883);
- });
-
- it("column from an implicit join with fields", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoinAndFields(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Ean").click();
- });
- H.selectFilterOperator("Is");
- H.clauseStepPopover().within(() => {
- cy.findByText("0001664425970").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Ean is 0001664425970");
- H.visualize();
- H.assertQueryBuilderRowCount(104);
- });
-
- it("column from a nested aggregation without column", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().findByText("Count").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("90");
- cy.button("Add filter").click();
- });
- assertFilterName("Count is equal to 90", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(7);
- });
-
- it("column from a nested aggregation with column", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().findByText("Sum of Quantity").click();
- H.selectFilterOperator("Less than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("350");
- cy.button("Add filter").click();
- });
- assertFilterName("Sum of Quantity is less than 350", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(115);
- });
-
- it("column from a nested breakout", () => {
- H.createQuestion(structuredQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().within(() => {
- cy.findByText("Product ID").click();
- cy.findByPlaceholderText("Enter an ID").type("10");
- cy.button("Add filter").click();
- });
- assertFilterName("Product ID is 10", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(1);
- });
- });
-
- describe("nested native questions", () => {
- it("column from a question", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestion(card), { mode: "notebook" });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("TAX").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("6.1");
- cy.button("Add filter").click();
- });
- assertFilterName("TAX is equal to 6.1");
- H.visualize();
- H.assertQueryBuilderRowCount(10);
- });
-
- it("column from an expression based on a question column", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithExpression(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().findByText("Total100").click();
- H.selectFilterOperator("Greater than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("250.5");
- cy.button("Add filter").click();
- });
- assertFilterName("Total100 is greater than 250.5");
- H.visualize();
- H.assertQueryBuilderRowCount(239);
- });
-
- it("column from an explicit join", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoin(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Vendor").click();
- cy.findByText("Aufderhar-Boehm").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Vendor is Aufderhar-Boehm");
- H.visualize();
- H.assertQueryBuilderRowCount(95);
- });
-
- it("column from an explicit join with fields", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoinAndFields(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Rating").click();
- });
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("3.7");
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Rating is equal to 3.7");
- H.visualize();
- H.assertQueryBuilderRowCount(883);
- });
-
- it("column from an implicit join with fields", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithJoinAndFields(card), {
- mode: "notebook",
- });
- });
- H.filter({ mode: "notebook" });
- H.clauseStepPopover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Ean").click();
- });
- H.selectFilterOperator("Is");
- H.clauseStepPopover().within(() => {
- cy.findByText("0001664425970").click();
- cy.button("Add filter").click();
- });
- assertFilterName("Products → Ean is 0001664425970");
- H.visualize();
- H.assertQueryBuilderRowCount(104);
- });
-
- it("column from a nested aggregation without column", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().findByText("Count").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("90");
- cy.button("Add filter").click();
- });
- assertFilterName("Count is equal to 90", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(7);
- });
-
- it("column from a nested aggregation with column", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().findByText("Sum of QUANTITY").click();
- H.selectFilterOperator("Less than");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("350");
- cy.button("Add filter").click();
- });
- assertFilterName("Sum of QUANTITY is less than 350", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(115);
- });
-
- it("column from a nested breakout", () => {
- H.createNativeQuestion(nativeQuestion).then(({ body: card }) => {
- H.visitQuestionAdhoc(nestedQuestionWithAggregations(card), {
- mode: "notebook",
- });
- });
- addNewFilter();
- H.clauseStepPopover().findByText("PRODUCT_ID").click();
- H.selectFilterOperator("Equal to");
- H.clauseStepPopover().within(() => {
- cy.findByPlaceholderText("Enter a number").type("10");
- cy.button("Add filter").click();
- });
- assertFilterName("PRODUCT_ID is equal to 10", { stage: 1 });
- H.visualize();
- H.assertQueryBuilderRowCount(1);
- });
- });
-});
-
-function addNewFilter() {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().findByText("Filter").click();
-}
-
-function assertFilterName(filterName, options) {
- H.getNotebookStep("filter", options)
- .findByText(filterName)
- .should("be.visible");
-}
diff --git a/e2e/test/scenarios/filters/filter-types.cy.spec.js b/e2e/test/scenarios/filters/filter-types.cy.spec.js
index 80d816d8b10..ec1f84de572 100644
--- a/e2e/test/scenarios/filters/filter-types.cy.spec.js
+++ b/e2e/test/scenarios/filters/filter-types.cy.spec.js
@@ -1,255 +1,5 @@
const { H } = cy;
-const STRING_CASES = [
- {
- title: "is",
- columnName: "Category",
- operator: "Is",
- options: ["Widget"],
- expectedDisplayName: "Category is Widget",
- expectedRowCount: 54,
- },
- {
- title: "is, multiple options",
- columnName: "Category",
- operator: "Is",
- options: ["Widget", "Gadget"],
- expectedDisplayName: "Category is 2 selections",
- expectedRowCount: 107,
- },
- {
- title: "is not",
- columnName: "Category",
- operator: "Is not",
- options: ["Widget"],
- expectedDisplayName: "Category is not Widget",
- expectedRowCount: 146,
- },
- {
- title: "contains",
- columnName: "Title",
- operator: "Contains",
- values: ["Al"],
- expectedDisplayName: "Title contains Al",
- expectedRowCount: 47,
- },
- {
- title: "contains, multiple options",
- columnName: "Title",
- operator: "Contains",
- values: ["Al", "Me"],
- expectedDisplayName: "Title contains 2 selections",
- expectedRowCount: 68,
- },
- {
- title: "contains, multiple options, case sensitive",
- columnName: "Title",
- operator: "Contains",
- values: ["Al", "Me"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title contains 2 selections",
- expectedRowCount: 28,
- },
- {
- title: "contains, case sensitive",
- columnName: "Title",
- operator: "Contains",
- values: ["Al"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title contains Al",
- expectedRowCount: 16,
- },
- {
- title: "does not contain",
- columnName: "Title",
- operator: "Does not contain",
- values: ["Al"],
- expectedDisplayName: "Title does not contain Al",
- expectedRowCount: 153,
- },
- {
- title: "does not contain, multiple options",
- columnName: "Title",
- operator: "Does not contain",
- values: ["Al", "Me"],
- expectedDisplayName: "Title does not contain 2 selections",
- expectedRowCount: 132,
- },
- {
- title: "does not contain, multiple options, case sensitive",
- columnName: "Title",
- operator: "Does not contain",
- values: ["Al", "Me"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title does not contain 2 selections",
- expectedRowCount: 172,
- },
- {
- title: "does not contain, case sensitive",
- columnName: "Title",
- operator: "Does not contain",
- values: ["Al"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title does not contain Al",
- expectedRowCount: 184,
- },
- {
- title: "starts with",
- columnName: "Title",
- operator: "Starts with",
- values: ["sm"],
- expectedDisplayName: "Title starts with sm",
- expectedRowCount: 11,
- },
- {
- title: "starts with, multiple options",
- columnName: "Title",
- operator: "Starts with",
- values: ["sm", "Me"],
- expectedDisplayName: "Title starts with 2 selections",
- expectedRowCount: 25,
- },
- {
- title: "starts with, multiple options, case sensitive",
- columnName: "Title",
- operator: "Starts with",
- values: ["sm", "Me"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title starts with 2 selections",
- expectedRowCount: 14,
- },
- {
- title: "starts with, case sensitive",
- columnName: "Title",
- operator: "Starts with",
- values: ["sm"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title starts with sm",
- expectedRowCount: 0,
- },
- {
- title: "ends with",
- columnName: "Title",
- operator: "Ends with",
- values: ["At"],
- expectedDisplayName: "Title ends with At",
- expectedRowCount: 22,
- },
- {
- title: "ends with, multiple options",
- columnName: "Title",
- operator: "Ends with",
- values: ["At", "es"],
- expectedDisplayName: "Title ends with 2 selections",
- expectedRowCount: 38,
- },
- {
- title: "ends with, multiple options, case sensitive",
- columnName: "Title",
- operator: "Ends with",
- values: ["At", "es"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title ends with 2 selections",
- expectedRowCount: 16,
- },
- {
- title: "ends with, case sensitive",
- columnName: "Title",
- operator: "Ends with",
- values: ["At"],
- options: ["Case sensitive"],
- expectedDisplayName: "Title ends with At",
- expectedRowCount: 0,
- },
- {
- title: "is empty",
- columnName: "Title",
- operator: "Is empty",
- expectedDisplayName: "Title is empty",
- expectedRowCount: 0,
- },
- {
- title: "is not empty",
- columnName: "Title",
- operator: "Not empty",
- expectedDisplayName: "Title is not empty",
- expectedRowCount: 200,
- },
-];
-
-const NUMBER_CASES = [
- {
- title: "equal to",
- columnName: "Rating",
- operator: "Equal to",
- values: ["4"],
- expectedDisplayName: "Rating is equal to 4",
- expectedRowCount: 37,
- },
- {
- title: "equal to, multiple values",
- columnName: "Rating",
- operator: "Equal to",
- values: ["4", "5"],
- expectedDisplayName: "Rating is equal to 2 selections",
- expectedRowCount: 40,
- },
- {
- title: "not equal to",
- columnName: "Rating",
- operator: "Not equal to",
- values: ["4"],
- expectedDisplayName: "Rating is not equal to 4",
- expectedRowCount: 163,
- },
- {
- title: "greater than",
- columnName: "Price",
- operator: "Greater than",
- values: ["47.5"],
- expectedDisplayName: "Price is greater than 47.5",
- expectedRowCount: 111,
- },
- {
- title: "less than",
- columnName: "Price",
- operator: "Less than",
- values: ["47.5"],
- expectedDisplayName: "Price is less than 47.5",
- expectedRowCount: 89,
- },
- {
- title: "greater than or equal to",
- columnName: "Price",
- operator: "Greater than or equal to",
- values: ["47.5"],
- expectedDisplayName: "Price is greater than or equal to 47.5",
- expectedRowCount: 111,
- },
- {
- title: "less than or equal to",
- columnName: "Price",
- operator: "Less than or equal to",
- values: ["47.5"],
- expectedDisplayName: "Price is less than or equal to 47.5",
- expectedRowCount: 89,
- },
- {
- title: "is empty",
- columnName: "Price",
- operator: "Is empty",
- expectedDisplayName: "Price is empty",
- expectedRowCount: 0,
- },
- {
- title: "not empty",
- columnName: "Price",
- operator: "Not empty",
- expectedDisplayName: "Price is not empty",
- expectedRowCount: 200,
- },
-];
-
const DATE_SHORTCUT_CASES = [
{
title: "today",
@@ -293,240 +43,12 @@ const DATE_SHORTCUT_CASES = [
},
];
-const EXCLUDE_DATE_CASES = [
- {
- title: "day of week",
- label: "Days of the week…",
- options: ["Monday"],
- expectedDisplayName: "Created At excludes Mondays",
- expectedRowCount: 170, // this might change based on a year
- },
- {
- title: "day of week, multiple",
- label: "Days of the week…",
- options: ["Monday", "Wednesday"],
- expectedDisplayName: "Created At excludes 2 day of week selections",
- expectedRowCount: 142, // this might change based on a year
- },
- {
- title: "month of year",
- label: "Months of the year…",
- options: ["July"],
- expectedDisplayName: "Created At excludes each Jul",
- expectedRowCount: 182,
- },
- {
- title: "month of year, multiple",
- label: "Months of the year…",
- options: ["July", "May"],
- expectedDisplayName: "Created At excludes 2 month of year selections",
- expectedRowCount: 163,
- },
- {
- title: "quarter of year",
- label: "Quarters of the year…",
- options: ["1st"],
- expectedDisplayName: "Created At excludes Q1 each year",
- expectedRowCount: 154,
- },
- {
- title: "quarter of year, multiple",
- label: "Quarters of the year…",
- options: ["1st", "4th"],
- expectedDisplayName: "Created At excludes 2 quarter of year selections",
- expectedRowCount: 102,
- },
- {
- title: "hour of day",
- label: "Hours of the day…",
- options: ["1 AM"],
- expectedDisplayName: "Created At excludes the hour of 1 AM",
- expectedRowCount: 191,
- },
- {
- title: "quarter of year, multiple",
- label: "Hours of the day…",
- options: ["1 AM", "10 AM", "5 PM"],
- expectedDisplayName: "Created At excludes 3 hour of day selections",
- expectedRowCount: 183,
- },
- {
- title: "empty values",
- label: "Empty values",
- expectedDisplayName: "Created At is not empty",
- expectedRowCount: 200,
- },
- {
- title: "not empty values",
- label: "Not empty values",
- expectedDisplayName: "Created At is empty",
- expectedRowCount: 0,
- },
-];
-
-const RELATIVE_DATE_CASES = [
- // Past
- {
- title: "yesterday",
- offset: "Previous",
- unit: "day",
- value: 1,
- expectedDisplayName: "Created At is today or yesterday",
- includeCurrent: true,
- },
- {
- title: "previous 7 days",
- offset: "Previous",
- unit: "days",
- value: 7,
- expectedDisplayName: "Created At is in the previous 7 days",
- },
- {
- title: "previous 3 weeks starting a quarter ago",
- offset: "Previous",
- unit: "weeks",
- value: 3,
- offsetUnit: "quarter",
- offsetValue: 1,
- expectedDisplayName:
- "Created At is in the previous 3 weeks, starting 1 quarter ago",
- },
- {
- title: "previous month",
- offset: "Previous",
- unit: "month",
- value: 1,
- expectedDisplayName: "Created At is in the previous month or this month",
- includeCurrent: true,
- },
- {
- title: "previous 3 months",
- offset: "Previous",
- unit: "months",
- value: 3,
- expectedDisplayName: "Created At is in the previous 3 months",
- },
- {
- title: "previous two quarters",
- offset: "Previous",
- unit: "quarters",
- value: 2,
- expectedDisplayName:
- "Created At is in the previous 2 quarters or this quarter",
- includeCurrent: true,
- },
-
- // Next
- {
- title: "next 6 hours",
- offset: "Next",
- unit: "hours",
- value: 6,
- expectedDisplayName: "Created At is in the next 6 hours or this hour",
- includeCurrent: true,
- },
- {
- title: "tomorrow",
- offset: "Next",
- unit: "day",
- value: 1,
- expectedDisplayName: "Created At is tomorrow",
- },
- {
- title: "next 7 days starting next month",
- offset: "Next",
- unit: "days",
- value: 7,
- offsetUnit: "month",
- offsetValue: 1,
- expectedDisplayName:
- "Created At is in the next 7 days, starting 1 month from now",
- },
- {
- title: "next year",
- offset: "Next",
- unit: "year",
- value: 1,
- expectedDisplayName: "Created At is in the next year",
- },
-];
-
describe("scenarios > filters > filter types", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
- describe("string filters", () => {
- STRING_CASES.forEach(
- ({
- title,
- columnName,
- operator,
- values = [],
- options = [],
- expectedDisplayName,
- expectedRowCount,
- }) => {
- it(title, () => {
- H.openProductsTable({ mode: "notebook" });
- H.filter({ mode: "notebook" });
-
- H.clauseStepPopover().findByText(columnName).click();
- H.selectFilterOperator(operator);
- H.clauseStepPopover().within(() => {
- values.forEach((value) => {
- cy.findByLabelText("Filter value")
- .focus()
- .type(`${value},`, { delay: 50 })
- .blur();
- });
- options.forEach((option) => cy.findByText(option).click());
- cy.button("Add filter").click();
- });
-
- assertFilterName(expectedDisplayName);
- H.visualize();
- H.assertQueryBuilderRowCount(expectedRowCount);
- });
- },
- );
- });
-
- describe("number filters", () => {
- NUMBER_CASES.forEach(
- ({
- title,
- columnName,
- operator,
- values = [],
- expectedDisplayName,
- expectedRowCount,
- }) => {
- it(title, () => {
- H.openProductsTable({ mode: "notebook" });
- H.filter({ mode: "notebook" });
-
- H.clauseStepPopover().findByText(columnName).click();
- H.selectFilterOperator(operator);
- H.clauseStepPopover().within(() => {
- values.forEach((value) => {
- cy.findByLabelText("Filter value")
- .focus()
- .type(`${value},`, { delay: 50 })
- .blur();
- });
- cy.button("Add filter").click();
- });
-
- assertFilterName(expectedDisplayName);
- H.visualize();
- H.assertQueryBuilderRowCount(expectedRowCount);
- });
- },
- );
- });
-
describe("date filters", () => {
describe("shortcuts", () => {
DATE_SHORTCUT_CASES.forEach(
@@ -546,76 +68,6 @@ describe("scenarios > filters > filter types", () => {
},
);
});
-
- describe("relative filters", () => {
- RELATIVE_DATE_CASES.forEach(
- ({
- title,
- offset,
- value,
- unit,
- offsetUnit,
- offsetValue,
- includeCurrent,
- expectedDisplayName,
- }) => {
- it(title, () => {
- H.openProductsTable({ mode: "notebook" });
- H.filter({ mode: "notebook" });
-
- H.clauseStepPopover().within(() => {
- cy.findByText("Created At").click();
- cy.findByText("Relative date range…").click();
- cy.findByRole("tab", { name: offset }).click();
- });
-
- H.relativeDatePicker.setValue({ value, unit }, H.clauseStepPopover);
-
- if (includeCurrent) {
- H.relativeDatePicker.toggleCurrentInterval(H.clauseStepPopover);
- } else if (offsetUnit && offsetValue) {
- H.relativeDatePicker.addStartingFrom(
- {
- value: offsetValue,
- unit: offsetUnit,
- },
- H.clauseStepPopover,
- );
- }
-
- H.clauseStepPopover().button("Add filter").click();
-
- assertFilterName(expectedDisplayName);
- H.visualize();
- assertFiltersExist();
- });
- },
- );
- });
-
- describe("exclude dates", () => {
- EXCLUDE_DATE_CASES.forEach(
- ({ title, label, options, expectedDisplayName, expectedRowCount }) => {
- it(title, () => {
- H.openProductsTable({ mode: "notebook" });
- H.filter({ mode: "notebook" });
-
- H.clauseStepPopover().within(() => {
- cy.findByText("Created At").click();
- cy.findByText("Exclude…").click();
- cy.findByText(label).click();
- if (options) {
- options.forEach((option) => cy.findByText(option).click());
- cy.button("Add filter").click();
- }
- });
- assertFilterName(expectedDisplayName);
- H.visualize();
- H.assertQueryBuilderRowCount(expectedRowCount);
- });
- },
- );
- });
});
});
diff --git a/e2e/test/scenarios/filters/filter.cy.spec.js b/e2e/test/scenarios/filters/filter.cy.spec.js
index f8ca4814cd5..582b4c127a2 100644
--- a/e2e/test/scenarios/filters/filter.cy.spec.js
+++ b/e2e/test/scenarios/filters/filter.cy.spec.js
@@ -42,52 +42,6 @@ describe("scenarios > question > filter", () => {
});
});
- it("'Between Dates' filter should behave consistently (metabase#12872)", () => {
- H.createQuestion(
- {
- name: "12872",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- filter: [
- "and",
- [
- "between",
- ["field", PRODUCTS.CREATED_AT, null],
- "2028-04-15",
- "2028-04-15",
- ],
- [
- "between",
- ["field", PRODUCTS.CREATED_AT, { "join-alias": "Products" }],
- "2028-04-15",
- "2028-04-15",
- ],
- ],
- joins: [
- {
- alias: "Products",
- condition: [
- "=",
- ["field", PRODUCTS.ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- fields: "all",
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- display: "scalar",
- },
- { visitQuestion: true },
- );
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("12872");
- cy.log("At the moment of unfixed issue, it's showing '0'");
- cy.findByTestId("scalar-value").contains("1");
- });
-
it("should filter based on remapped values (metabase#13235)", () => {
// set "Filtering on this field" = "A list of all values"
cy.request("PUT", `/api/field/${ORDERS.PRODUCT_ID}`, {
@@ -115,35 +69,6 @@ describe("scenarios > question > filter", () => {
cy.findAllByText("Fantastic Wool Shirt").should("not.exist");
});
- it("should filter using Custom Expression from aggregated results (metabase#12839)", () => {
- const CE_NAME = "Simple Math";
-
- H.createQuestion(
- {
- name: "12839",
- query: {
- filter: [">", ["field", CE_NAME, { "base-type": "type/Float" }], 0],
- "source-query": {
- aggregation: [
- [
- "aggregation-options",
- ["+", ["count"], 1],
- { name: CE_NAME, "display-name": CE_NAME },
- ],
- ],
- breakout: [["field", PRODUCTS.CATEGORY, null]],
- "source-table": PRODUCTS_ID,
- },
- },
- },
- { visitQuestion: true },
- );
-
- cy.log("Reported failing on v0.35.4");
- cy.log(`Error message: **Column 'source.${CE_NAME}' not found;**`);
- cy.findAllByText("Gizmo");
- });
-
it("should not drop aggregated filters (metabase#11957)", () => {
const AGGREGATED_FILTER = "Count is less than or equal to 20";
@@ -219,46 +144,6 @@ describe("scenarios > question > filter", () => {
.should("be.visible");
});
- it("should handle post-aggregation filter on questions with joined table (metabase#14811)", () => {
- H.createQuestion(
- {
- name: "14811",
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [
- [
- "sum",
- [
- "field",
- PRODUCTS.PRICE,
- { "source-field": ORDERS.PRODUCT_ID },
- ],
- ],
- ],
- breakout: [
- [
- "field",
- PRODUCTS.CATEGORY,
- { "source-field": ORDERS.PRODUCT_ID },
- ],
- ],
- },
- filter: [
- "=",
- ["field", "CATEGORY", { "base-type": "type/Text" }],
- "Widget",
- ],
- },
- },
- { visitQuestion: true },
- );
-
- cy.get("[data-testid=cell-data]").contains("Widget");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 1 row");
- });
-
it("should reject Enter when the filter expression is invalid", () => {
H.openReviewsTable({ mode: "notebook" });
H.filter({ mode: "notebook" });
@@ -905,128 +790,6 @@ describe("scenarios > question > filter", () => {
});
});
- ["True", "False"].forEach((condition) => {
- const regexCondition = new RegExp(`${condition}`, "i");
- // We must use and return strings instead of boolean and numbers
- const integerAssociatedWithCondition = condition === "True" ? "0" : "1";
-
- describe(`should be able to filter on the boolean column ${condition.toUpperCase()} (metabase#16386)`, () => {
- beforeEach(H.setupBooleanQuery);
-
- it("from the column popover (metabase#16386-1)", () => {
- H.tableHeaderClick("boolean");
-
- H.popover().findByText("Filter by this column").click();
-
- H.popover().within(() => {
- // Not sure exactly what this popover will look like when this issue is fixed.
- // In one of the previous versions it said "Update filter" instead of "Add filter".
- // If that's the case after the fix, this part of the test might need to be updated accordingly.
- cy.findByLabelText(regexCondition)
- .check({ force: true }) // the radio input is hidden
- .should("be.checked");
- cy.button("Add filter").click();
- cy.wait("@dataset");
- });
-
- assertOnTheResult();
- });
-
- it("from the custom question (metabase#16386-3)", () => {
- H.openNotebook();
-
- H.filter({ mode: "notebook" });
-
- H.popover().within(() => {
- cy.findByText("boolean").click();
- addBooleanFilter();
- });
-
- H.visualize(() => {
- assertOnTheResult();
- });
- });
-
- it("from custom expressions", () => {
- H.openNotebook();
-
- H.filter({ mode: "notebook" });
-
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({ formula: `boolean = ${condition}` });
- H.expressionEditorWidget().button("Done").click();
-
- H.visualize(() => {
- assertOnTheResult();
- });
- });
-
- function addBooleanFilter() {
- // This is really inconvenient way to ensure that the element is selected, but it's the only one currently
- cy.findByLabelText(regexCondition)
- .check({ force: true })
- .should("be.checked");
- cy.button("Add filter").click();
- }
-
- function assertOnTheResult() {
- // Filter name
- cy.findByTextEnsureVisible(`boolean is ${condition.toLowerCase()}`);
- cy.get("[data-testid=cell-data]").should(
- "contain",
- integerAssociatedWithCondition,
- );
- }
- });
- });
-
- describe("should handle boolean arguments", () => {
- beforeEach(H.setupBooleanQuery);
-
- it("with case", () => {
- H.openNotebook();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom column").click();
- H.enterCustomColumnDetails({
- formula: "Case(boolean, 45, -10)",
- name: "Test",
- });
-
- cy.button("Done").click();
-
- H.filter({ mode: "notebook" });
-
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({ formula: "boolean = true" });
- H.expressionEditorWidget().button("Done").click();
-
- H.visualize(() => {
- cy.contains("45").should("exist");
- cy.contains("-10").should("not.exist");
- });
- });
-
- it("with CountIf", () => {
- H.openNotebook();
- H.summarize({ mode: "notebook" });
- H.popover().contains("Custom Expression").click();
- H.enterCustomColumnDetails({
- formula: "CountIf(boolean)",
- name: "count if boolean is true",
- });
- H.expressionEditorWidget().button("Done").click();
- cy.findByTestId("aggregate-step")
- .contains("count if boolean is true")
- .should("exist");
- H.visualize(() => {
- cy.contains("2").should("exist");
- });
- });
- });
-
it("should close the dropdown but not the popover on escape when the combobox is opened", () => {
const optionName = "Abbey Satterfield";
H.openPeopleTable({ mode: "notebook" });
diff --git a/e2e/test/scenarios/joins/joins-custom-expressions.cy.spec.ts b/e2e/test/scenarios/joins/joins-custom-expressions.cy.spec.ts
index 1db2ce1d07d..cdbb2a64cf0 100644
--- a/e2e/test/scenarios/joins/joins-custom-expressions.cy.spec.ts
+++ b/e2e/test/scenarios/joins/joins-custom-expressions.cy.spec.ts
@@ -2,150 +2,12 @@ import { ORDERS_MODEL_ID } from "e2e/support/cypress_sample_instance_data";
const { H } = cy;
-type TestCase = {
- operator: string;
- lhsExpression: string;
- rhsExpression: string;
- expectedRowCount: number;
-};
-
-const TEST_CASES: TestCase[] = [
- {
- operator: "=",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1112,
- },
- {
- operator: "=",
- lhsExpression: "false",
- rhsExpression: "false",
- expectedRowCount: 1112,
- },
- {
- operator: "=",
- lhsExpression: '"A"',
- rhsExpression: '"A"',
- expectedRowCount: 1112,
- },
- {
- operator: "!=",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1,
- },
- {
- operator: "!=",
- lhsExpression: "false",
- rhsExpression: "false",
- expectedRowCount: 1,
- },
- {
- operator: "!=",
- lhsExpression: '"A"',
- rhsExpression: '"A"',
- expectedRowCount: 1,
- },
- {
- operator: ">",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1,
- },
- {
- operator: ">=",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1112,
- },
- {
- operator: "<",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1,
- },
- {
- operator: "<=",
- lhsExpression: "1",
- rhsExpression: "1",
- expectedRowCount: 1112,
- },
- {
- operator: ">",
- lhsExpression: "[ID] + 1",
- rhsExpression: "[ID] - 1",
- expectedRowCount: 2,
- },
- {
- operator: ">=",
- lhsExpression: "[ID] + 1",
- rhsExpression: "[ID] - 1",
- expectedRowCount: 3,
- },
- {
- operator: "<",
- lhsExpression: "[ID] + [User ID]",
- rhsExpression: "[ID] - [Product ID]",
- expectedRowCount: 1109,
- },
- {
- operator: "<=",
- lhsExpression: "[ID] + [User ID]",
- rhsExpression: "[ID] - [Product ID]",
- expectedRowCount: 1110,
- },
- {
- operator: "=",
- lhsExpression: "year([Created At])",
- rhsExpression: "year([Created At])",
- expectedRowCount: 452,
- },
-];
-
describe("scenarios > joins > custom expressions", () => {
beforeEach(() => {
H.restore();
cy.signInAsNormalUser();
});
- describe("should support expressions in join conditions", () => {
- TEST_CASES.forEach(
- ({ operator, lhsExpression, rhsExpression, expectedRowCount }) => {
- it(`${lhsExpression} ${operator} ${rhsExpression}`, () => {
- H.openOrdersTable({ mode: "notebook" });
-
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Reviews").click();
- });
- H.popover().within(() => {
- cy.findByText("Custom Expression").click();
- H.enterCustomColumnDetails({ formula: lhsExpression });
- cy.button("Done").click();
- });
- H.popover().within(() => {
- cy.findByText("Custom Expression").click();
- H.enterCustomColumnDetails({ formula: rhsExpression });
- cy.button("Done").click();
- });
- H.getNotebookStep("join").findByLabelText("Change operator").click();
- H.popover().findByText(operator).click();
-
- H.filter({ mode: "notebook" });
- H.popover().within(() => {
- cy.findByText("ID").click();
- cy.findByPlaceholderText("Enter an ID").type("1");
- cy.button("Add filter").click();
- });
-
- H.visualize();
- H.assertQueryBuilderRowCount(expectedRowCount);
- });
- },
- );
- });
-
it("should support expressions in join conditions referencing model columns", () => {
H.visitModel(ORDERS_MODEL_ID);
H.openNotebook();
diff --git a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
index 69e09ae9f4d..414e9296e34 100644
--- a/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/joins/joins-reproductions.cy.spec.js
@@ -12,96 +12,6 @@ const {
REVIEWS,
REVIEWS_ID,
} = SAMPLE_DATABASE;
-
-describe("issue 12928", () => {
- const SOURCE_QUESTION_NAME = "12928_Q1";
- const JOINED_QUESTION_NAME = "12928_Q2";
-
- const SOURCE_QUESTION_DETAILS = {
- name: SOURCE_QUESTION_NAME,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }],
- ["field", PEOPLE.SOURCE, { "join-alias": "People - User" }],
- ],
- joins: [
- {
- alias: "Products",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- fields: "all",
- "source-table": PRODUCTS_ID,
- },
- {
- alias: "People - User",
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People - User" }],
- ],
- fields: "all",
- "source-table": PEOPLE_ID,
- },
- ],
- },
- };
-
- const JOINED_QUESTION_DETAILS = {
- name: JOINED_QUESTION_NAME,
- query: {
- "source-table": REVIEWS_ID,
- aggregation: [["avg", ["field", REVIEWS.RATING, null]]],
- breakout: [["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }]],
- joins: [
- {
- alias: "Products",
- condition: [
- "=",
- ["field", REVIEWS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- fields: "all",
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should join saved questions that themselves contain joins (metabase#12928)", () => {
- H.createQuestion(SOURCE_QUESTION_DETAILS);
- H.createQuestion(JOINED_QUESTION_DETAILS, {
- wrapId: true,
- idAlias: "joinedQuestionId",
- });
-
- H.startNewQuestion();
- H.selectSavedQuestionsToJoin(SOURCE_QUESTION_NAME, JOINED_QUESTION_NAME);
- H.popover().findByText("Products → Category").click();
- H.popover().findByText("Products → Category").click();
-
- H.visualize();
-
- cy.get("@joinedQuestionId").then(() => {
- H.assertJoinValid({
- lhsSampleColumn: "Products → Category",
- rhsSampleColumn: `${JOINED_QUESTION_NAME} - Products → Category → Category`,
- });
- });
-
- H.assertQueryBuilderRowCount(20);
- });
-});
-
describe("issue 14793", () => {
const XRAY_DATASETS = 11; // enough to load most questions
@@ -288,50 +198,6 @@ describe("issue 17710", () => {
});
});
});
-
-describe("issue 17767", () => {
- const { ORDERS, ORDERS_ID, PRODUCTS } = SAMPLE_DATABASE;
-
- const questionDetails = {
- name: "17767",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [["field", PRODUCTS.ID, { "source-field": ORDERS.PRODUCT_ID }]],
- limit: 2,
- },
- };
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should be able to do subsequent joins on question with the aggregation that uses implicit joins (metabase#17767)", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- H.openNotebook();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Join data").click();
-
- // Join "Previous results" with
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Reviews").click();
- });
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("xavier");
- });
-});
-
describe("issue 17968", () => {
beforeEach(() => {
H.restore();
@@ -408,171 +274,6 @@ describe("issue 18502", () => {
cy.findByText("April 2025");
});
});
-
-describe("issue 18512", () => {
- function getQuestionDetails(name, catFilter) {
- return {
- name,
- query: {
- "source-table": REVIEWS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", REVIEWS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- filter: [
- "=",
- ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }],
- catFilter,
- ],
- aggregation: [
- ["distinct", ["field", PRODUCTS.ID, { "join-alias": "Products" }]],
- ],
- breakout: [
- [
- "field",
- PRODUCTS.CREATED_AT,
- { "join-alias": "Products", "temporal-unit": "month" },
- ],
- ],
- },
- };
- }
-
- const question1 = getQuestionDetails("18512#1", "Doohickey");
- const question2 = getQuestionDetails("18512#2", "Gizmo");
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should join two saved questions with the same implicit/explicit grouped field (metabase#18512)", () => {
- H.createQuestion(question1);
- H.createQuestion(question2);
-
- H.startNewQuestion();
- H.selectSavedQuestionsToJoin("18512#1", "18512#2");
-
- H.popover().findByText("Products → Created At: Month").click();
- H.popover().findByText("Products → Created At: Month").click();
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Products → Created At: Month");
- });
-});
-
-describe("issue 18589", () => {
- function joinTable(table) {
- cy.findByText("Join data").click();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText(table).click();
- });
- }
-
- function selectFromDropdown(option, clickOpts) {
- H.popover().findByText(option).click(clickOpts);
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should not bin numeric fields in join condition by default (metabase#18589)", () => {
- H.openOrdersTable({ mode: "notebook" });
-
- joinTable("Reviews");
- selectFromDropdown("Quantity");
- selectFromDropdown("Rating");
-
- H.summarize({ mode: "notebook" });
- selectFromDropdown("Count of rows");
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("2,860,368");
- });
-});
-
-describe("issue 18630", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- const QUERY_WITH_FIELD_CLAUSE = {
- "source-query": {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People - User" }],
- ],
- alias: "People - User",
- },
- ],
- expressions: {
- coalesce: [
- "coalesce",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People - User" }],
- ],
- },
- aggregation: [["count"]],
- breakout: [["expression", "coalesce"]],
- },
- joins: [
- {
- fields: "all",
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", "coalesce", { "base-type": "type/Float" }],
- ["field", PEOPLE.ID, { "join-alias": "People" }],
- ],
- alias: "People",
- },
- ],
- limit: 3,
- };
-
- const questionDetails = {
- name: "18630",
- query: QUERY_WITH_FIELD_CLAUSE,
- };
-
- it("should normally open queries with field literals in joins (metabase#18630)", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- // The query runs and we assert the page is not blank,
- // which was caused by an infinite loop and a stack overflow.
- cy.findByDisplayValue(questionDetails.name);
- cy.get("[data-testid=cell-data]").contains("29494 Anderson Drive");
- cy.findByTestId("question-row-count").should("have.text", "Showing 3 rows");
- });
-});
-
describe("issue 18818", () => {
beforeEach(() => {
cy.intercept("POST", "/api/dataset").as("dataset");
@@ -751,18 +452,6 @@ describe("issue 22859 - multiple levels of nesting", () => {
getJoinedTableColumnHeader();
});
-
- it("third level of nesting with joins should result in proper column aliasing (metabase#22859-2)", () => {
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("22859-Q2").click();
- });
-
- H.visualize();
-
- getJoinedTableColumnHeader();
- });
});
describe("issue 23293", () => {
@@ -905,137 +594,6 @@ describe("issue 27380", () => {
cy.findByText("Product → Created At: Week");
});
});
-
-describe("issue 27873", () => {
- const questionDetails = {
- dataset_query: {
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PEOPLE_ID,
- condition: [
- "=",
- ["field", ORDERS.USER_ID, null],
- ["field", PEOPLE.ID, { "join-alias": "People - User" }],
- ],
- alias: "People - User",
- },
- ],
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.TOTAL, { binning: { strategy: "default" } }],
- ["field", PEOPLE.SOURCE, { "join-alias": "People - User" }],
- ],
- },
- database: SAMPLE_DB_ID,
- },
- display: "table",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should show a group by column from the joined field in the summarize sidebar (metabase#27873)", () => {
- H.visitQuestionAdhoc(questionDetails);
- H.summarize();
-
- cy.findByTestId("aggregation-item").should("have.text", "Count");
- cy.findByTestId("pinned-dimensions")
- .should("contain", "Total")
- .and("contain", "People - User → Source");
- });
-});
-
-describe("issue 29795", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow join based on native query (metabase#29795)", () => {
- const NATIVE_QUESTION = "native question";
- const LIMIT = 5;
- H.createNativeQuestion(
- {
- name: NATIVE_QUESTION,
- native: { query: `SELECT * FROM "PUBLIC"."ORDERS" LIMIT ${LIMIT}` },
- },
- { loadMetadata: true },
- );
-
- H.openOrdersTable({ mode: "notebook", limit: LIMIT });
-
- cy.icon("join_left_outer").click();
-
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(NATIVE_QUESTION).click();
- });
-
- H.popover().within(() => {
- cy.findByRole("option", { name: "ID" }).click();
- });
-
- H.popover().within(() => {
- cy.findByRole("option", { name: "USER_ID" }).click();
- });
-
- H.visualize();
- H.tableInteractive().within(() => {
- cy.findByText("User ID").should("be.visible");
- cy.findByText("native question → USER_ID").should("be.visible");
- });
- });
-});
-
-describe("issue 30743", () => {
- const query = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- aggregation: [["count"]],
- breakout: [["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }]],
- },
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.visitQuestionAdhoc(query, { mode: "notebook" });
- });
-
- it("should be possible to sort on the breakout column (metabase#30743)", () => {
- cy.findByLabelText("Sort").click();
- H.popover().findByText("Products").click();
- H.popover().contains("Category").click();
-
- H.visualize();
- // Check bars count
- H.chartPathWithFillColor("#509EE3").should("have.length", 4);
- });
-});
-
describe("issue 31769", () => {
const Q1 = {
"source-table": ORDERS_ID,
diff --git a/e2e/test/scenarios/metrics/metrics-collection.cy.spec.js b/e2e/test/scenarios/metrics/metrics-collection.cy.spec.js
index 9021456f356..1f1219e3fdd 100644
--- a/e2e/test/scenarios/metrics/metrics-collection.cy.spec.js
+++ b/e2e/test/scenarios/metrics/metrics-collection.cy.spec.js
@@ -1,10 +1,5 @@
const { H } = cy;
-import { USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import {
- FIRST_COLLECTION_ID,
- ORDERS_MODEL_ID,
-} from "e2e/support/cypress_sample_instance_data";
const { ORDERS_ID, ORDERS } = SAMPLE_DATABASE;
@@ -19,17 +14,6 @@ const ORDERS_SCALAR_METRIC = {
collection_position: 1,
};
-const ORDERS_SCALAR_MODEL_METRIC = {
- name: "Orders model metric",
- type: "metric",
- query: {
- "source-table": `card__${ORDERS_MODEL_ID}`,
- aggregation: [["count"]],
- },
- display: "scalar",
- collection_position: 1,
-};
-
const ORDERS_TIMESERIES_METRIC = {
name: "Count of orders over time",
type: "metric",
@@ -209,27 +193,6 @@ describe("scenarios > metrics > collection", () => {
.findByText("This item has been permanently deleted.")
.should("be.visible");
});
-
- it("should be able to view a model-based metric without collection access to the source model", () => {
- cy.signInAsAdmin();
- cy.updateCollectionGraph({
- [USER_GROUPS.ALL_USERS_GROUP]: {
- root: "none",
- [FIRST_COLLECTION_ID]: "read",
- },
- });
- H.createQuestion({
- ...ORDERS_SCALAR_MODEL_METRIC,
- collection_id: FIRST_COLLECTION_ID,
- }).then(() => {
- cy.signIn("nocollection");
- H.visitCollection(FIRST_COLLECTION_ID);
- });
- H.getPinnedSection()
- .findByTestId("scalar-value")
- .should("not.be.empty")
- .and("be.visible");
- });
});
function openArchive() {
diff --git a/e2e/test/scenarios/metrics/metrics-dashboard.cy.spec.js b/e2e/test/scenarios/metrics/metrics-dashboard.cy.spec.js
index 6fbb1007a76..354818481c0 100644
--- a/e2e/test/scenarios/metrics/metrics-dashboard.cy.spec.js
+++ b/e2e/test/scenarios/metrics/metrics-dashboard.cy.spec.js
@@ -1,11 +1,6 @@
const { H } = cy;
-import { USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import {
- FIRST_COLLECTION_ID,
- ORDERS_DASHBOARD_ID,
- ORDERS_MODEL_ID,
-} from "e2e/support/cypress_sample_instance_data";
+import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";
const { ORDERS_ID, ORDERS, PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;
@@ -19,16 +14,6 @@ const ORDERS_SCALAR_METRIC = {
display: "scalar",
};
-const ORDERS_SCALAR_MODEL_METRIC = {
- name: "Orders model metric",
- type: "metric",
- query: {
- "source-table": `card__${ORDERS_MODEL_ID}`,
- aggregation: [["count"]],
- },
- display: "scalar",
-};
-
const ORDERS_TIMESERIES_METRIC = {
name: "Count of orders over time",
type: "metric",
@@ -226,21 +211,6 @@ describe("scenarios > metrics > dashboard", () => {
.should("be.visible");
});
- it("should be able to add a filter and drill thru without the metric aggregation clause (metabase#42656)", () => {
- H.createDashboardWithQuestions({
- questions: [ORDERS_TIMESERIES_METRIC],
- }).then(({ dashboard }) => {
- H.visitDashboard(dashboard.id);
- });
- H.getDashboardCard().within(() => {
- H.cartesianChartCircle()
- .eq(23) // random dot
- .click({ force: true });
- });
- H.popover().findByText("See these Orders").click();
- H.assertQueryBuilderRowCount(445);
- });
-
it("should be able to replace a card with a metric", () => {
H.createQuestion(ORDERS_SCALAR_METRIC);
H.visitDashboard(ORDERS_DASHBOARD_ID);
@@ -296,44 +266,4 @@ describe("scenarios > metrics > dashboard", () => {
.should("be.visible");
H.assertQueryBuilderRowCount(8);
});
-
- it("should be able to view a model-based metric without data access", () => {
- cy.signInAsAdmin();
- H.createDashboardWithQuestions({
- questions: [ORDERS_SCALAR_METRIC],
- }).then(({ dashboard }) => {
- cy.signIn("nodata");
- H.visitDashboard(dashboard.id);
- });
- H.getDashboardCard()
- .findByTestId("scalar-container")
- .findByText("18,760")
- .should("be.visible");
- });
-
- it("should be able to view a model-based metric without collection access to the source model", () => {
- cy.signInAsAdmin();
- cy.updateCollectionGraph({
- [USER_GROUPS.ALL_USERS_GROUP]: {
- root: "none",
- [FIRST_COLLECTION_ID]: "read",
- },
- });
- H.createDashboardWithQuestions({
- dashboardDetails: { collection_id: FIRST_COLLECTION_ID },
- questions: [
- {
- ...ORDERS_SCALAR_MODEL_METRIC,
- collection_id: FIRST_COLLECTION_ID,
- },
- ],
- }).then(({ dashboard }) => {
- cy.signIn("nocollection");
- H.visitDashboard(dashboard.id);
- });
- H.getDashboardCard()
- .findByTestId("scalar-container")
- .findByText("18,760")
- .should("be.visible");
- });
});
diff --git a/e2e/test/scenarios/metrics/metrics-editing.cy.spec.js b/e2e/test/scenarios/metrics/metrics-editing.cy.spec.js
index dcdacb92adb..cf59857b09a 100644
--- a/e2e/test/scenarios/metrics/metrics-editing.cy.spec.js
+++ b/e2e/test/scenarios/metrics/metrics-editing.cy.spec.js
@@ -46,26 +46,6 @@ const PRODUCTS_SCALAR_METRIC = {
display: "scalar",
};
-const ORDERS_MULTI_STAGE_QUESTION = {
- name: "Orders question multi-stage",
- type: "question",
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- ORDERS.CREATED_AT,
- { "base-type": "type/DateTime", "temporal-unit": "month" },
- ],
- ],
- },
- filter: [">", ["field", "count", { "base-type": "type/Integer" }], 10],
- },
- display: "table",
-};
-
function startNewMetricWithTable(database, table) {
H.startNewMetric();
H.MetricPage.queryEditor().should("be.visible");
@@ -148,19 +128,6 @@ function addStringCategoryFilter({ tableName, columnName, values }) {
});
}
-function addNumberBetweenFilter({ tableName, columnName, minValue, maxValue }) {
- startNewFilter();
- H.popover().within(() => {
- if (tableName) {
- cy.findByText(tableName).click();
- }
- cy.findByText(columnName).click();
- cy.findByPlaceholderText("Min").type(String(minValue));
- cy.findByPlaceholderText("Max").type(String(maxValue));
- cy.button("Add filter").click();
- });
-}
-
function addBreakout({ tableName, columnName, bucketName, stageIndex }) {
startNewBreakout({ stageIndex });
if (tableName) {
@@ -227,23 +194,6 @@ describe("scenarios > metrics > editing", () => {
});
});
- it("should be able to change the query definition of a metric based on a model", () => {
- cy.intercept("PUT", "/api/card/*").as("updateCard");
- cy.intercept("GET", "/api/card/*").as("getCard");
- H.createQuestion(ORDERS_SCALAR_MODEL_METRIC).then(({ body: card }) =>
- cy.visit(`/metric/${card.id}/query`),
- );
- H.MetricPage.queryEditor().should("be.visible");
- addBreakout({ tableName: "Product", columnName: "Created At" });
- H.MetricPage.saveButton().click();
- cy.wait(["@updateCard", "@getCard", "@getCard"]);
- H.MetricPage.aboutTab().click();
- verifyLineAreaBarChart({
- xAxis: "Product → Created At: Month",
- yAxis: "Count",
- });
- });
-
it("should pin new metrics automatically", () => {
cy.visit("/browse/metrics");
cy.findByTestId("browse-metrics-header")
@@ -306,58 +256,6 @@ describe("scenarios > metrics > editing", () => {
verifyScalarValue("4,939");
});
- it("should create a metric based on a saved question", () => {
- startNewMetricWithSavedItem("Our analytics", "Orders");
- addStringCategoryFilter({
- tableName: "Product",
- columnName: "Category",
- values: ["Gadget"],
- });
- saveNewMetric();
- verifyScalarValue("4,939");
- });
-
- it("should create a metric based on a multi-stage saved question", () => {
- H.createQuestion(ORDERS_MULTI_STAGE_QUESTION);
- startNewMetricWithSavedItem(
- "Our analytics",
- ORDERS_MULTI_STAGE_QUESTION.name,
- );
- addNumberBetweenFilter({
- columnName: "Count",
- minValue: 5,
- maxValue: 100,
- });
- saveNewMetric();
- verifyScalarValue("5");
- });
-
- it("should create a metric based on a model", () => {
- startNewMetricWithSavedItem("Our analytics", "Orders Model");
- addStringCategoryFilter({
- tableName: "Product",
- columnName: "Category",
- values: ["Gadget"],
- });
- saveNewMetric();
- verifyScalarValue("4,939");
- });
-
- it("should create a metric based on a multi-stage model", () => {
- H.createQuestion({ ...ORDERS_MULTI_STAGE_QUESTION, type: "model" });
- startNewMetricWithSavedItem(
- "Our analytics",
- ORDERS_MULTI_STAGE_QUESTION.name,
- );
- addNumberBetweenFilter({
- columnName: "Count",
- minValue: 5,
- maxValue: 100,
- });
- saveNewMetric();
- verifyScalarValue("5");
- });
-
it("should not allow to create a multi-stage metric", () => {
startNewMetricWithSavedItem("Our analytics", "Orders Model");
getActionButton("Summarize").should("not.exist");
diff --git a/e2e/test/scenarios/metrics/metrics-question.cy.spec.js b/e2e/test/scenarios/metrics/metrics-question.cy.spec.js
index ad2867d2cbc..a24c8257fa0 100644
--- a/e2e/test/scenarios/metrics/metrics-question.cy.spec.js
+++ b/e2e/test/scenarios/metrics/metrics-question.cy.spec.js
@@ -1,10 +1,5 @@
const { H } = cy;
-import { USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import {
- FIRST_COLLECTION_ID,
- ORDERS_MODEL_ID,
-} from "e2e/support/cypress_sample_instance_data";
const { ORDERS_ID, ORDERS } = SAMPLE_DATABASE;
@@ -18,16 +13,6 @@ const ORDERS_SCALAR_METRIC = {
display: "scalar",
};
-const ORDERS_SCALAR_MODEL_METRIC = {
- name: "Orders model metric",
- type: "metric",
- query: {
- "source-table": `card__${ORDERS_MODEL_ID}`,
- aggregation: [["count"]],
- },
- display: "scalar",
-};
-
const ORDERS_TIMESERIES_METRIC = {
name: "Count of orders over time",
type: "metric",
@@ -201,44 +186,6 @@ describe("scenarios > metrics > question", () => {
cy.button(/Summarize/).should("not.exist");
});
});
-
- it("should be able to view a model-based metric without data access", () => {
- H.createQuestion(ORDERS_SCALAR_MODEL_METRIC).then(({ body: card }) => {
- cy.signInAsSandboxedUser();
- H.visitMetric(card.id);
- });
- cy.findByTestId("scalar-container")
- .findByText("18,760")
- .should("be.visible");
- H.MetricPage.aboutPage().within(() => {
- cy.button(/Filter/).should("not.exist");
- cy.button(/Summarize/).should("not.exist");
- });
- });
-
- it("should be able to view a model-based metric without collection access to the source model", () => {
- cy.signInAsAdmin();
- cy.updateCollectionGraph({
- [USER_GROUPS.ALL_USERS_GROUP]: {
- root: "none",
- [FIRST_COLLECTION_ID]: "read",
- },
- });
- H.createQuestion({
- ...ORDERS_SCALAR_MODEL_METRIC,
- collection_id: FIRST_COLLECTION_ID,
- }).then(({ body: card }) => {
- cy.signIn("nocollection");
- H.visitMetric(card.id);
- });
- cy.findByTestId("scalar-container")
- .findByText("18,760")
- .should("be.visible");
- H.MetricPage.aboutPage().within(() => {
- cy.button(/Filter/).should("not.exist");
- cy.button(/Summarize/).should("not.exist");
- });
- });
});
describe("metrics", () => {
diff --git a/e2e/test/scenarios/metrics/reproductions/metrics-reproductions.cy.spec.ts b/e2e/test/scenarios/metrics/reproductions/metrics-reproductions.cy.spec.ts
index 36400ea4754..a8ffee3b18d 100644
--- a/e2e/test/scenarios/metrics/reproductions/metrics-reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/metrics/reproductions/metrics-reproductions.cy.spec.ts
@@ -200,50 +200,3 @@ describe("issue 32037", () => {
});
});
});
-
-describe("issue 30574", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should not throw when diving a metric by another metric with a custom aggregation expression with a custom name (metabase#30574)", () => {
- cy.visit("/browse/metrics");
-
- cy.log("create the first metric");
- H.main().findByText("Create metric").click();
- H.MetricPage.queryEditor().should("be.visible");
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- H.MetricPage.saveButton().click();
- H.modal().within(() => {
- cy.findByLabelText("Name").clear().type("M1");
- cy.button("Save").click();
- });
- H.MetricPage.aboutPage().should("be.visible");
-
- cy.log("create the second metric");
- H.navigationSidebar().findByText("Metrics").click();
- H.main().findByLabelText("Create a new metric").click();
- H.MetricPage.queryEditor().should("be.visible");
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- H.getNotebookStep("summarize").findByText("Count").click();
- H.popover().findByText("Custom Expression").click();
- H.enterCustomColumnDetails({
- name: "X",
- formula: "[M1]/[M1]",
- });
- H.popover().button("Update").click();
- H.MetricPage.saveButton().click();
- H.modal().within(() => {
- cy.findByLabelText("Name").clear().type("M2");
- cy.button("Save").click();
- });
- H.MetricPage.aboutPage().should("be.visible");
- });
-});
diff --git a/e2e/test/scenarios/models/models-metadata.cy.spec.js b/e2e/test/scenarios/models/models-metadata.cy.spec.js
index b127eddb166..e18d266d794 100644
--- a/e2e/test/scenarios/models/models-metadata.cy.spec.js
+++ b/e2e/test/scenarios/models/models-metadata.cy.spec.js
@@ -159,29 +159,6 @@ describe("scenarios > models metadata", () => {
.and("not.contain", "Subtotal");
});
- it("should allow setting column relations (metabase#29318)", () => {
- H.createNativeQuestion(
- {
- name: "Native Model",
- type: "model",
- native: {
- query: "SELECT * FROM ORDERS LIMIT 5",
- },
- },
- { visitQuestion: true },
- );
- H.openQuestionActions();
- H.popover().findByTextEnsureVisible("Edit metadata").click();
- H.waitForLoaderToBeRemoved();
- H.openColumnOptions("USER_ID");
- H.setColumnType("No semantic type", "Foreign Key");
- H.sidebar().findByPlaceholderText("Select a target").click();
- H.popover().findByText("People → ID").click();
- H.saveMetadataChanges();
- // TODO: Not much to do with it at the moment beyond saving it.
- // Check that the relation is automatically suggested in the notebook once it is implemented.
- });
-
it("should keep metadata in sync with the query", () => {
H.createNativeQuestion(
{
@@ -377,38 +354,6 @@ describe("scenarios > models metadata", () => {
});
});
- it("should show implicit joins on FK columns with real DB columns (#37067)", () => {
- cy.get("@modelId").then((modelId) => {
- cy.visit(`/model/${modelId}`);
- cy.wait("@dataset");
-
- // Drill to People table
- // FK column is mapped to real DB column
- H.queryBuilderHeader()
- .button(/Filter/)
- .click();
-
- H.popover().within(() => {
- cy.get("[data-element-id=list-section-header]").should(
- "have.length",
- 2, // Just the two we're expecting and not the other fake FK.
- );
- cy.findByText("User").click();
- cy.findByText("Source").click();
- cy.findByText("Twitter").click();
- cy.button("Apply filter").click();
- });
- cy.wait("@dataset");
- cy.findByTestId("question-row-count")
- .invoke("text")
- .should("match", /Showing \d+ rows/);
- cy.findByTestId("question-row-count").should(
- "not.contain",
- "Showing 100 rows",
- );
- });
- });
-
it("should allow drills on FK columns from dashboards (metabase#42130)", () => {
cy.get("@modelId").then((modelId) => {
H.createDashboard().then((response) => {
@@ -472,37 +417,6 @@ describe("scenarios > models metadata", () => {
.should("be.visible");
});
});
-
- it("does not confuse the names of various native model columns mapped to the same database field", () => {
- H.createNativeQuestion(
- {
- type: "model",
- native: {
- query: "select 1 as A, 2 as B, 3 as C",
- },
- },
- { idAlias: "modelId", wrapId: true },
- );
-
- cy.get("@modelId").then((modelId) => {
- H.setModelMetadata(modelId, (field, index) => ({
- ...field,
- id: ORDERS.ID,
- display_name: `ID${index + 1}`,
- semantic_type: "type/PK",
- }));
-
- H.visitModel(modelId);
- });
-
- H.openNotebook();
- cy.findByTestId("fields-picker").click();
- H.popover().within(() => {
- cy.findByText("ID1").should("be.visible");
- cy.findByText("ID2").should("be.visible");
- cy.findByText("ID3").should("be.visible");
- });
- });
});
function drillFK({ id }) {
diff --git a/e2e/test/scenarios/models/models-with-aggregation-and-breakout.cy.spec.js b/e2e/test/scenarios/models/models-with-aggregation-and-breakout.cy.spec.js
deleted file mode 100644
index bf7c310cd41..00000000000
--- a/e2e/test/scenarios/models/models-with-aggregation-and-breakout.cy.spec.js
+++ /dev/null
@@ -1,39 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-import { turnIntoModel } from "./helpers/e2e-models-helpers";
-const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
-
-describe("scenarios > models with aggregation and breakout", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("PUT", "/api/card/*").as("updateCard");
-
- H.createQuestion(
- {
- name: "model with aggregation & breakout",
- display: "line",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["distinct", ["field", ORDERS.PRODUCT_ID, null]]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
- ],
- },
- },
- { visitQuestion: true },
- );
- });
-
- it("should be possible to convert a question with an aggregation and breakout into a model", () => {
- turnIntoModel();
- cy.wait("@updateCard");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Created At: Month");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distinct values of Product ID");
- });
-});
diff --git a/e2e/test/scenarios/models/models.cy.spec.js b/e2e/test/scenarios/models/models.cy.spec.js
index 227e5a0a531..c21ecfac7fe 100644
--- a/e2e/test/scenarios/models/models.cy.spec.js
+++ b/e2e/test/scenarios/models/models.cy.spec.js
@@ -175,71 +175,6 @@ describe("scenarios > models", () => {
cy.location("pathname").should("eq", "/collection/root");
});
- it("allows to turn a native question with a long alias into a model (metabase#47584)", () => {
- const nativeQuery = `
- SELECT
- count(*) AS coun,
- state AS Total_number_of_people_from_each_state_separated_by_state_and_then_we_do_a_count
- FROM people
- GROUP BY
- Total_number_of_people_from_each_state_separated_by_state_and_then_we_do_a_count`;
- H.createNativeQuestion(
- {
- name: "People Model with long alias",
- native: {
- query: nativeQuery,
- },
- },
- { visitQuestion: true, wrapId: true },
- );
-
- turnIntoModel();
- H.openQuestionActions();
- assertIsModel();
-
- cy.get("@questionId").then((questionId) => {
- cy.wait("@dataset").then(({ response }) => {
- expect(response.body.error).to.not.exist;
- });
- });
-
- H.filter();
- H.popover().findByText("COUN").click();
- H.selectFilterOperator("Greater than");
- H.popover().within(() => {
- cy.findByLabelText("Filter value").type("30");
- cy.button("Apply filter").click();
- });
- cy.wait("@dataset").then(({ response }) => {
- expect(response.body.error).to.not.exist;
- });
-
- assertQuestionIsBasedOnModel({
- model: "People Model with long alias",
- collection: "Our analytics",
- table: "People",
- });
-
- cy.get("@questionId").then((questionId) => {
- saveQuestionBasedOnModel({ modelId: questionId, name: "Q1" });
- });
-
- assertQuestionIsBasedOnModel({
- questionName: "Q1",
- model: "People Model with long alias",
- collection: "Our analytics",
- table: "People",
- });
-
- cy.findByTestId("qb-header").findAllByText("Our analytics").first().click();
- getCollectionItemCard("People Model with long alias").within(() => {
- cy.icon("model");
- });
- getCollectionItemRow("Q1").icon("table2");
-
- cy.location("pathname").should("eq", "/collection/root");
- });
-
it("changes model's display to table", () => {
H.visitQuestion(ORDERS_BY_YEAR_QUESTION_ID);
@@ -703,7 +638,7 @@ describe("scenarios > models", () => {
};
beforeEach(() => {
- H.createQuestion(modelDetails, { wrapId: true, idAlias: "modelId" });
+ H.createQuestion(modelDetails);
});
it("should allow adding models to dashboards", () => {
@@ -723,23 +658,6 @@ describe("scenarios > models", () => {
});
});
});
-
- it("should allow using models in native queries", () => {
- cy.intercept("POST", "/api/dataset").as("query");
- cy.get("@modelId").then((id) => {
- H.startNewNativeQuestion();
- H.NativeEditor.type(`select * from {{#${id}}}`, {
- parseSpecialCharSequences: false,
- });
- });
- cy.findByTestId("native-query-editor-container").icon("play").click();
- cy.wait("@query");
- H.tableInteractive().within(() => {
- cy.findByText("USER_ID");
- cy.findByText("PRODUCT_ID");
- cy.findByText("TAX");
- });
- });
});
});
diff --git a/e2e/test/scenarios/models/reproductions-1.cy.spec.ts b/e2e/test/scenarios/models/reproductions-1.cy.spec.ts
index a7206634f98..6138375e2f7 100644
--- a/e2e/test/scenarios/models/reproductions-1.cy.spec.ts
+++ b/e2e/test/scenarios/models/reproductions-1.cy.spec.ts
@@ -3,14 +3,12 @@ const { H } = cy;
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
ORDERS_DASHBOARD_ID,
- ORDERS_MODEL_ID,
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
import type { StructuredQuestionDetails } from "e2e/support/helpers";
import type { CardId, FieldReference } from "metabase-types/api";
-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =
- SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
describe("issue 29943", () => {
function reorderTotalAndCustomColumns() {
@@ -238,146 +236,6 @@ describe("issue 23103", () => {
});
});
-describe("issue 39150", { viewportWidth: 1600 }, () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("allows custom columns with the same name in nested models (metabase#39150-1)", () => {
- const ccName = "CC Rating";
-
- H.createQuestion({
- name: "Source Model",
- type: "model",
- query: {
- "source-table": PRODUCTS_ID,
- expressions: {
- [ccName]: [
- "ceil",
- [
- "field",
- PRODUCTS.RATING,
- {
- "base-type": "type/Float",
- },
- ],
- ],
- },
- limit: 2,
- },
- }).then(({ body: { id: sourceModelId } }) => {
- H.createQuestion(
- {
- name: "Nested Model",
- type: "model",
- query: {
- "source-table": `card__${sourceModelId}`,
- },
- },
- { visitQuestion: true },
- );
- });
-
- H.openNotebook();
- cy.findByTestId("action-buttons").findByText("Custom column").click();
-
- H.enterCustomColumnDetails({
- formula: "floor([Rating])",
- name: ccName,
- blur: true,
- });
-
- cy.button("Done").click();
-
- H.visualize();
-
- cy.findAllByTestId("header-cell")
- .filter(`:contains('${ccName}')`)
- .should("have.length", 2);
- });
-
- it("allows custom columns with the same name as the aggregation column from the souce model (metabase#39150-2)", () => {
- H.createQuestion({
- name: "Source Model",
- type: "model",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- PRODUCTS.CATEGORY,
- {
- "base-type": "type/Text",
- },
- ],
- ],
- limit: 2,
- },
- }).then(({ body: { id: sourceModelId } }) => {
- H.createQuestion(
- {
- type: "model",
- query: {
- "source-table": `card__${sourceModelId}`,
- },
- },
- { visitQuestion: true },
- );
- });
-
- H.openNotebook();
- cy.findByTestId("action-buttons").findByText("Custom column").click();
-
- H.enterCustomColumnDetails({
- formula: "[Count] + 1",
- name: "Count",
- blur: true,
- });
-
- cy.button("Done").click();
-
- H.visualize();
-
- cy.findAllByTestId("header-cell")
- .filter(":contains('Count')")
- .should("have.length", 2);
-
- H.saveQuestion("Nested Model", { wrapId: true, idAlias: "nestedModelId" });
-
- cy.log("Make sure this works for the deeply nested models as well");
- cy.get("@nestedModelId").then((nestedModelId) => {
- H.createQuestion(
- {
- type: "model",
- query: {
- "source-table": `card__${nestedModelId}`,
- },
- },
- { visitQuestion: true },
- );
- });
-
- H.openNotebook();
- cy.findByTestId("action-buttons").findByText("Custom column").click();
-
- H.enterCustomColumnDetails({
- formula: "[Count] + 5",
- name: "Count",
- blur: true,
- });
-
- cy.button("Done").click();
-
- H.visualize();
-
- cy.findAllByTestId("header-cell")
- .filter(":contains('Count')")
- .should("have.length", 3);
- });
-});
-
describe("issue 41785, issue 46756", () => {
beforeEach(() => {
H.restore();
@@ -579,106 +437,6 @@ describe("issue 40635", () => {
cy.button("Done").click();
}
});
-
-describe("issue 33427", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("does not confuse the names of various native model columns mapped to the same database field (metabase#33427)", () => {
- H.createNativeQuestion(
- {
- type: "model",
- native: {
- query: `
- select o.ID, p1.title as created_by, p2.title as updated_by
- from ORDERS o
- join PRODUCTS p1 on p1.ID = o.PRODUCT_ID
- join PRODUCTS p2 on p2.ID = o.USER_ID;
- `,
- },
- },
- { visitQuestion: true },
- );
-
- assertColumnHeaders();
-
- cy.findByLabelText("Move, trash, and more…").click();
- H.popover().findByText("Edit metadata").click();
- H.waitForLoaderToBeRemoved();
-
- H.openColumnOptions("CREATED_BY");
- H.mapColumnTo({ table: "Products", column: "Title" });
- H.renameColumn("Title", "CREATED_BY");
-
- H.openColumnOptions("UPDATED_BY");
- H.mapColumnTo({ table: "Products", column: "Title" });
- H.renameColumn("Title", "UPDATED_BY");
-
- assertColumnHeaders();
- H.saveMetadataChanges();
-
- assertColumnHeaders();
-
- H.openNotebook();
- H.getNotebookStep("data").button("Pick columns").click();
- H.popover().within(() => {
- cy.findByText("CREATED_BY").should("be.visible");
- cy.findByText("UPDATED_BY").should("be.visible");
- });
- });
-
- function assertColumnHeaders() {
- cy.findAllByTestId("header-cell")
- .should("contain", "CREATED_BY")
- .and("contain", "UPDATED_BY");
- }
-});
-
-describe("issue 25113", () => {
- const questionDetails: StructuredQuestionDetails = {
- name: "People Question",
- type: "question",
- query: {
- "source-table": PEOPLE_ID,
- fields: [["field", PEOPLE.ID, null]],
- },
- };
-
- const modelDetails: StructuredQuestionDetails = {
- ...questionDetails,
- name: "People Model",
- type: "model",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should not mistakenly override model column metadata with raw field metadata (metabase#25113)", () => {
- H.createQuestion(modelDetails, { visitQuestion: true });
- H.openQuestionActions("Edit metadata");
- H.waitForLoaderToBeRemoved();
- H.openColumnOptions("ID");
- H.renameColumn("ID", "ID renamed");
- H.saveMetadataChanges();
-
- H.createQuestion(questionDetails, { visitQuestion: true });
- H.openNotebook();
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("People Model").click();
- });
- H.popover().findByText("ID").click();
- H.popover().findByText("ID renamed").click();
- H.visualize();
- H.assertTableData({ columns: ["ID", "People Model → ID renamed"] });
- });
-});
-
describe("issue 39749", () => {
const modelDetails: StructuredQuestionDetails = {
type: "model",
@@ -1103,52 +861,6 @@ describe("issue 35840", () => {
checkColumnMapping(["Our analytics", questionName]);
});
});
-
-describe("issue 36161", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should allow to override metadata for custom columns (metabase#36161)", () => {
- cy.log("Go straight to model query definition");
- cy.visit(`/model/${ORDERS_MODEL_ID}/query`);
- H.tableInteractiveBody().should("be.visible").and("contain", "37.65");
-
- cy.log("Deselect all columns (except for ID)");
- H.getNotebookStep("data").button("Pick columns").click();
- H.popover().findByText("Select all").click();
-
- cy.log("Add two custom columns based on the ID");
- H.getNotebookStep("data").button("Custom column").click();
- H.enterCustomColumnDetails({ formula: "[ID]", name: "ID2" });
- H.popover().button("Done").click();
- H.getNotebookStep("expression").icon("add").click();
- H.enterCustomColumnDetails({ formula: "[ID]", name: "ID3" });
- H.popover().button("Done").click();
- H.runButtonOverlay().click();
- cy.wait("@dataset");
-
- cy.log("Rename custom columns");
- cy.findByTestId("editor-tabs-columns-name").click();
- H.openColumnOptions("ID2");
- H.renameColumn("ID2", "ID2 custom");
- H.openColumnOptions("ID3");
- H.renameColumn("ID3", "ID3 custom");
- H.saveMetadataChanges();
-
- cy.log("Assert that the renamed columns appear in filter options");
- H.openNotebook();
- H.getNotebookStep("data").button("Filter").click();
- H.popover().within(() => {
- cy.findByText("ID").should("be.visible");
- cy.findByText("ID2 custom").should("be.visible");
- cy.findByText("ID3 custom").should("be.visible");
- });
- });
-});
-
describe("issue 34514", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/models/reproductions-2.cy.spec.ts b/e2e/test/scenarios/models/reproductions-2.cy.spec.ts
index 4862bfcc42b..4a5ff1c95ab 100644
--- a/e2e/test/scenarios/models/reproductions-2.cy.spec.ts
+++ b/e2e/test/scenarios/models/reproductions-2.cy.spec.ts
@@ -1,6 +1,5 @@
const { H } = cy;
-import { SAMPLE_DB_ID, USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import {
FIRST_COLLECTION_ID,
@@ -10,91 +9,8 @@ import type {
NativeQuestionDetails,
StructuredQuestionDetails,
} from "e2e/support/helpers";
-import { DataPermissionValue } from "metabase/admin/permissions/types";
-import type { GroupPermissions, NativePermissions } from "metabase-types/api";
-
-const {
- ORDERS,
- ORDERS_ID,
- PRODUCTS,
- PRODUCTS_ID,
- REVIEWS,
- REVIEWS_ID,
- PEOPLE,
-} = SAMPLE_DATABASE;
-
-describe("issue 47988", () => {
- const model1Details: StructuredQuestionDetails = {
- name: "M1",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- alias: "Products",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- fields: "all",
- },
- ],
- },
- };
-
- const model2Details: StructuredQuestionDetails = {
- name: "M2",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- alias: "Products",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- fields: "all",
- },
- {
- "source-table": REVIEWS_ID,
- alias: "Reviews",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", REVIEWS.PRODUCT_ID, { "join-alias": "Reviews" }],
- ],
- fields: "all",
- },
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be able to execute a query with joins to the same table in base queries (metabase#47988)", () => {
- H.createQuestion(model1Details);
- H.createQuestion(model2Details);
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("M1").click();
- });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("M2").click();
- });
- H.visualize();
- H.tableInteractive().should("be.visible");
- });
-});
+const { ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
describe("issue 46221", () => {
const modelDetails: NativeQuestionDetails = {
name: "46221",
@@ -436,43 +352,6 @@ describe("issue 56775", () => {
H.getNotebookStep("data").findByText("Products").should("be.visible");
});
});
-
-describe("issue 57359", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("PUT", "/api/card/*").as("updateCard");
- });
-
- it("should not break the model when editing metadata (metabase#57359)", () => {
- cy.log("create a question with two joins without running the query");
- H.openOrdersTable({ mode: "notebook" });
- cy.wrap([1, 2]).each(() => {
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Products").click();
- });
- });
- H.saveQuestion("Q1");
-
- cy.log("turn the question into a model");
- H.openQuestionActions("Turn into a model");
- H.modal().button("Turn this into a model").click();
- cy.wait("@updateCard");
-
- cy.log("edit query metadata");
- H.openQuestionActions("Edit metadata");
- H.waitForLoaderToBeRemoved();
- H.openColumnOptions("Product ID");
- H.renameColumn("Product ID", "Product ID2");
- H.saveMetadataChanges();
-
- cy.log("make sure the query is run successfully");
- H.tableInteractive().should("be.visible");
- });
-});
-
describe("issue 55486", () => {
const MODEL_NAME = "Model 55486";
@@ -554,78 +433,6 @@ describe("Issue 30712", () => {
cy.findByTestId("run-button").should("be.visible");
});
});
-
-describe("issue 60930", () => {
- const modelDetails: StructuredQuestionDetails = {
- name: "Model",
- type: "model",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- alias: "Products",
- strategy: "left-join",
- fields: "all",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, { "base-type": "type/Integer" }],
- [
- "field",
- PRODUCTS.ID,
- { "base-type": "type/BigInteger", "join-alias": "Products" },
- ],
- ],
- },
- {
- "source-table": REVIEWS_ID,
- alias: "Reviews",
- strategy: "left-join",
- fields: "all",
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, { "base-type": "type/Integer" }],
- [
- "field",
- REVIEWS.PRODUCT_ID,
- { "base-type": "type/Integer", "join-alias": "Reviews" },
- ],
- ],
- },
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should not apply model metadata overrides to incorrect columns after changes in the query (metabase#60930)", () => {
- cy.log("create a model");
- H.createQuestion(modelDetails).then(({ body: card }) =>
- H.visitModel(card.id),
- );
-
- cy.log("override the column name");
- H.openQuestionActions("Edit metadata");
- H.waitForLoaderToBeRemoved();
- H.openColumnOptions("Products → ID");
- H.renameColumn("Products → ID", "ID2");
- H.saveMetadataChanges();
- H.tableInteractive().findByText("ID2").should("exist");
-
- cy.log("remove the ID2 column from the query");
- H.openQuestionActions("Edit query definition");
- H.getNotebookStep("join", { index: 0 })
- .findByLabelText("Pick columns")
- .click();
- H.popover().findByLabelText("Select all").click();
- H.saveMetadataChanges();
- H.tableInteractive().findByText("ID2").should("not.exist");
- });
-});
-
describe("Issue 56913", () => {
beforeEach(() => {
H.restore();
@@ -671,41 +478,6 @@ describe("Issue 56913", () => {
.should("be.visible");
});
});
-
-describe("issue 45919", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow to query a model with a hidden column", () => {
- cy.log("create a new model with result_metadata");
- cy.visit("/model/new");
- cy.findByTestId("new-model-options")
- .findByText("Use the notebook editor")
- .click();
- H.popover().findByText("Sample Database").click();
- H.popover().findByText("People").click();
- H.runButtonOverlay().click();
- H.tableInteractive().should("be.visible");
- cy.findByTestId("dataset-edit-bar").button("Save").click();
- cy.findByTestId("save-question-modal").button("Save").click();
- H.queryBuilderHeader().should("be.visible");
- H.tableInteractiveHeader().findByText("Password").should("be.visible");
-
- cy.log("hide the Password field");
- cy.request("PUT", `/api/field/${PEOPLE.PASSWORD}`, {
- visibility_type: "sensitive",
- });
-
- cy.log("the query should succeed, and the Password field should be hidden");
- H.queryBuilderHeader().button("Refresh").click();
- H.tableInteractive().should("be.visible");
- H.tableInteractiveHeader().findByText("Password").should("not.exist");
- H.tableInteractiveHeader().findByText("Email").should("be.visible");
- });
-});
-
describe("issue 50915", () => {
beforeEach(() => {
H.restore();
@@ -801,97 +573,6 @@ describe("issue 38747", () => {
});
});
-describe("issue 67680", () => {
- function setTablePermissions(createQueriesPermission: NativePermissions) {
- const permissions: GroupPermissions = {
- [SAMPLE_DB_ID]: {
- "view-data": {
- public: {
- [ORDERS_ID]: DataPermissionValue.BLOCKED,
- [PRODUCTS_ID]: DataPermissionValue.UNRESTRICTED,
- },
- },
- "create-queries": createQueriesPermission,
- },
- };
- cy.updatePermissionsGraph({
- [USER_GROUPS.ALL_USERS_GROUP]: permissions,
- [USER_GROUPS.DATA_GROUP]: permissions,
- [USER_GROUPS.COLLECTION_GROUP]: permissions,
- });
- }
-
- function setTablePermissionsWithCreateQueries() {
- setTablePermissions(DataPermissionValue.QUERY_BUILDER);
- }
-
- function setTablePermissionsWithoutCreateQueries() {
- setTablePermissions(DataPermissionValue.NO);
- }
-
- function updateModelSourceTableWithResultMetadata() {
- H.visitModel(ORDERS_MODEL_ID);
- H.openQuestionActions("Edit query definition");
- H.getNotebookStep("data").findByText("Orders").click();
- H.popover().findByText("Products").click();
- H.runButtonInOverlay().click();
- H.tableInteractiveHeader().findByText("Category").should("be.visible");
- H.saveMetadataChanges();
- }
-
- function updateModelSourceTableWithoutResultMetadata() {
- H.visitModel(ORDERS_MODEL_ID);
- H.openQuestionActions("Edit query definition");
- H.getNotebookStep("data").findByText("Orders").click();
- H.popover().findByText("Products").click();
- H.saveMetadataChanges();
- }
-
- function verifyNormalUserCanAccessModel() {
- cy.signInAsNormalUser();
- H.visitModel(ORDERS_MODEL_ID);
- H.assertQueryBuilderRowCount(200);
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- });
-
- describe("when the user has create queries permission", () => {
- beforeEach(() => {
- setTablePermissionsWithCreateQueries();
- });
-
- it("should not override column ids for a mbql model when it is saved with result_metadata (metabase#67680)", () => {
- updateModelSourceTableWithResultMetadata();
- verifyNormalUserCanAccessModel();
- });
-
- it("should not override column ids for a mbql model when it is saved without result_metadata (metabase#67680)", () => {
- updateModelSourceTableWithoutResultMetadata();
- verifyNormalUserCanAccessModel();
- });
- });
-
- describe("when the user does not have create queries permission", () => {
- beforeEach(() => {
- setTablePermissionsWithoutCreateQueries();
- });
-
- it("should not override column ids for a mbql model when it is saved with result_metadata (metabase#67680)", () => {
- updateModelSourceTableWithResultMetadata();
- verifyNormalUserCanAccessModel();
- });
-
- it("should not override column ids for a mbql model when it is saved without result_metadata (metabase#67680)", () => {
- updateModelSourceTableWithoutResultMetadata();
- verifyNormalUserCanAccessModel();
- });
- });
-});
-
describe("issue 69722", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/models/reproductions-3.cy.spec.ts b/e2e/test/scenarios/models/reproductions-3.cy.spec.ts
index fa8fd0a7b73..0d0250b081e 100644
--- a/e2e/test/scenarios/models/reproductions-3.cy.spec.ts
+++ b/e2e/test/scenarios/models/reproductions-3.cy.spec.ts
@@ -142,54 +142,6 @@ describe("issue 20624", { tags: "@skip" }, () => {
});
});
-describe("issue 20963", () => {
- const snippetName = "string 'test'";
- const questionName = "Converting questions with snippets to models";
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow converting questions with static snippets to models (metabase#20963)", () => {
- cy.visit("/");
-
- H.startNewNativeQuestion();
-
- // Create a snippet
- cy.icon("snippet").click();
- cy.findByTestId("sidebar-content").findByText("Create snippet").click();
-
- H.modal().within(() => {
- cy.findByLabelText("Enter some SQL here so you can reuse it later").type(
- "'test'",
- );
- cy.findByLabelText("Give your snippet a name").type(snippetName);
- cy.findByText("Save").click();
- });
-
- H.NativeEditor.type("{moveToStart}select ");
-
- H.saveQuestion(
- questionName,
- { wrapId: true },
- {
- path: ["Our analytics"],
- },
- );
-
- // Convert into to a model
- H.openQuestionActions();
- H.popover().within(() => {
- cy.icon("model").click();
- });
-
- H.modal().within(() => {
- cy.findByText("Turn this into a model").click();
- });
- });
-});
-
describe("issue 22517", () => {
function renameColumn(column: string, newName: string) {
cy.findByDisplayValue(column).clear().type(newName).blur();
@@ -295,70 +247,6 @@ describe("issue 22518", () => {
});
});
-describe("filtering based on the remapped column name should result in a correct query (metabase#22715)", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.intercept("PUT", "/api/card/*").as("updateModel");
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion({
- native: {
- query:
- 'select 1 as "ID", current_timestamp::datetime as "ALIAS_CREATED_AT"',
- },
- }).then(({ body: { id } }) => {
- // Turn the question into a model
- cy.request("PUT", `/api/card/${id}`, { type: "model" });
-
- // Let's go straight to the model metadata editor
- cy.visit(`/model/${id}/columns`);
- cy.findByText("Database column this maps to").should("be.visible");
-
- // The first column `ID` is automatically selected
- H.mapColumnTo({ table: "Orders", column: "ID" });
- cy.findByText("ALIAS_CREATED_AT").click();
-
- H.mapColumnTo({ table: "Orders", column: "Created At" });
-
- // Make sure the column name updated before saving
- cy.findByDisplayValue("Created At");
-
- cy.button("Save changes").click();
- cy.wait("@updateModel");
-
- H.visitModel(id);
- });
- });
-
- it("when done through the column header action (metabase#22715-1)", () => {
- H.tableHeaderClick("Created At");
- H.popover().within(() => {
- cy.findByText("Filter by this column").click();
- cy.findByText("Today").click();
- });
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Today").should("not.exist");
- cy.get("[data-testid=cell-data]")
- .should("have.length", 4)
- .and("contain", "Created At");
- });
-
- it("when done through the filter trigger (metabase#22715-2)", () => {
- H.filter();
- H.popover().within(() => {
- cy.findByText("Created At").click();
- cy.findByText("Today").click();
- });
- cy.wait("@dataset");
- cy.get("[data-testid=cell-data]")
- .should("have.length", 4)
- .and("contain", "Created At");
- });
-});
-
describe("issue 26091", () => {
const modelDetails: StructuredQuestionDetails = {
name: "Old model",
@@ -487,151 +375,6 @@ describe("issue 28971", () => {
});
});
-describe("issue 53604 - nested native question with multiple breakouts on same column", () => {
- const questionDetails: NativeQuestionDetails = {
- name: "53604 base",
- type: "question",
- native: {
- query: "select ID, CREATED_AT from ORDERS",
- "template-tags": {},
- },
- };
-
- function createNestedQuestion({
- turnIntoModel: shouldTurnIntoModel = false,
- } = {}) {
- H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {
- if (shouldTurnIntoModel) {
- H.visitQuestion(id);
- turnIntoModel();
- }
- H.createQuestion(
- {
- type: "question",
- name: "53604",
- query: {
- "source-table": `card__${id}`,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- "CREATED_AT",
- { "temporal-unit": "month", "base-type": "type/DateTime" },
- ],
- [
- "field",
- "CREATED_AT",
- { "temporal-unit": "year", "base-type": "type/DateTime" },
- ],
- ],
- },
- display: "line",
- },
- {
- wrapId: true,
- idAlias: "nestedQuestionId",
- },
- );
- });
- }
-
- function testUnderlyingRecordsDrillThru() {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(25).click({ force: true });
- H.popover()
- .findByText(/^See these/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "CREATED_AT is May 1–31, 2027",
- );
-
- cy.findByTestId("qb-filters-panel").findByText(
- "CREATED_AT: Year is Jan 1 – Dec 31, 2027",
- );
-
- H.assertQueryBuilderRowCount(520);
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("Underlying records drill-through should work on nested native question (metabase#53604)", () => {
- createNestedQuestion();
- testUnderlyingRecordsDrillThru();
- });
-
- it("Underlying records drill-through should work on nested native model (metabase#53604)", () => {
- createNestedQuestion({ turnIntoModel: true });
- testUnderlyingRecordsDrillThru();
- });
-});
-
-describe("issue 54108 - nested question broken out by day", () => {
- const questionDetails: NativeQuestionDetails = {
- name: "54108 base",
- type: "question",
- native: {
- query: "select ID, CREATED_AT from ORDERS",
- "template-tags": {},
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {
- H.createQuestion(
- {
- type: "question",
- name: "54108",
- query: {
- "source-table": `card__${id}`,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- "CREATED_AT",
- { "temporal-unit": "day", "base-type": "type/Date" },
- ],
- ],
- },
- display: "line",
- },
- {
- wrapId: true,
- idAlias: "nestedQuestionId",
- },
- );
- });
- });
-
- it("drill-through should work (metabase#54108)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(500).click({ force: true });
- H.popover()
- .findByText(/^See these/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "CREATED_AT is Oct 11, 2026",
- );
-
- H.assertQueryBuilderRowCount(6);
- });
-});
-
describe("issue 29951", { requestTimeout: 10000, viewportWidth: 1600 }, () => {
const questionDetails: StructuredQuestionDetails = {
name: "29951",
@@ -933,56 +676,3 @@ describe("issue 37009", () => {
.should("not.be.null");
});
});
-
-describe("issue 45926", () => {
- const questionDetails: StructuredQuestionDetails = {
- name: "33330",
- type: "model",
- query: {
- "source-table": ORDERS_ID,
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should restore model correctly without refresh (metabase#45926)", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
- cy.wait("@dataset");
- H.openQuestionActions("Edit metadata");
- H.sidebar().within(() => {
- cy.findByDisplayValue("ID").type(" updated");
- });
-
- cy.button("Save changes").click();
- cy.wait("@dataset");
-
- cy.findByRole("columnheader", { name: "ID updated" }).should("be.visible");
- H.openQuestionActions("Edit query definition");
- cy.button("Sort").click();
- H.popover().findByText("ID").click();
- cy.button("Save changes").click();
- cy.wait("@dataset");
-
- H.questionInfoButton().click();
- H.sidesheet().within(() => {
- cy.findByRole("tab", { name: "History" }).click();
- cy.findByText(
- "changed the visualization settings and edited the metadata.",
- )
- .closest('[data-testid="revision-history-event"]')
- .findByTestId("question-revert-button")
- .click();
- });
-
- cy.wait("@dataset");
-
- H.sidesheet().button("Close").click();
-
- cy.findByRole("columnheader", { name: "ID updated" }).should("be.visible");
- });
-});
diff --git a/e2e/test/scenarios/models/reproductions.cy.spec.js b/e2e/test/scenarios/models/reproductions.cy.spec.js
index 2c14623b673..d7ded3e7d15 100644
--- a/e2e/test/scenarios/models/reproductions.cy.spec.js
+++ b/e2e/test/scenarios/models/reproductions.cy.spec.js
@@ -5,17 +5,10 @@ import {
ORDERS_DASHBOARD_ID,
ORDERS_QUESTION_ID,
} from "e2e/support/cypress_sample_instance_data";
-import {
- createMockActionParameter,
- createMockDashboardCard,
-} from "metabase-types/api/mocks";
-
-import { addWidgetStringFilter } from "../native-filters/helpers/e2e-field-filter-helpers";
import { turnIntoModel } from "./helpers/e2e-models-helpers";
-const { ORDERS_ID, ORDERS, REVIEWS, REVIEWS_ID, PRODUCTS, PEOPLE, PEOPLE_ID } =
- SAMPLE_DATABASE;
+const { ORDERS_ID, REVIEWS, REVIEWS_ID, PRODUCTS } = SAMPLE_DATABASE;
describe("issue 19737", () => {
const modelName = "Orders Model";
@@ -116,47 +109,6 @@ describe("issue 19737", () => {
});
});
-describe("issue 20517", () => {
- const modelDetails = {
- name: "20517",
- query: {
- "source-table": ORDERS_ID,
- limit: 5,
- },
- type: "model",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(modelDetails).then(({ body: { id } }) => {
- cy.intercept("POST", `/api/card/${id}/query`).as("modelQuery");
- cy.intercept("PUT", `/api/card/${id}`).as("updateModel");
- cy.visit(`/model/${id}/columns`);
- cy.wait("@modelQuery");
- });
- });
-
- it("should be able to save metadata changes with empty description (metabase#20517)", () => {
- cy.findByTestId("dataset-edit-bar")
- .button("Save changes")
- .should("be.disabled");
- cy.findByDisplayValue(/^This is a unique ID/).clear();
- cy.findByDisplayValue(/^This is a unique ID/).should("not.exist");
- cy.findByTestId("dataset-edit-bar")
- .button("Save changes")
- .should("not.be.disabled")
- .click();
- cy.wait("@updateModel").then(({ response: { body, statusCode } }) => {
- expect(statusCode).not.to.eq(400);
- expect(body.errors).not.to.exist;
- expect(body.description).to.be.null;
- });
- cy.button("Save failed").should("not.exist");
- });
-});
-
describe("issue 22519", { tags: "@skip" }, () => {
const questionDetails = {
query: {
@@ -528,7 +480,7 @@ describe("issue 29517 - nested question based on native model with remapped valu
H.createQuestionAndDashboard({
questionDetails: nestedQuestionDetails,
}).then(({ body: card }) => {
- const { card_id, dashboard_id } = card;
+ const { dashboard_id } = card;
H.editDashboardCard(card, {
visualization_settings: {
@@ -541,30 +493,11 @@ describe("issue 29517 - nested question based on native model with remapped valu
},
});
- cy.wrap(card_id).as("nestedQuestionId");
cy.wrap(dashboard_id).as("dashboardId");
});
});
});
- it("drill-through should work (metabase#29517-1)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(25).click({ force: true });
- H.popover()
- .findByText(/^See these/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Created At is May 1–31, 2027",
- );
-
- H.assertQueryBuilderRowCount(520);
- });
-
it("click behavior to custom destination should work (metabase#29517-2)", () => {
cy.intercept("/api/dashboard/*/dashcard/*/card/*/query").as(
"dashcardQuery",
@@ -650,70 +583,6 @@ describe("issue 53556 - nested question based on native model with remapped valu
});
});
- it("Underlying records drill-through should work (metabase#53556)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(25).click({ force: true });
- H.popover()
- .findByText(/^See these/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Created At is May 1–31, 2027",
- );
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Total is greater than or equal to 40",
- );
-
- cy.findByTestId("qb-filters-panel").findByText("Total is less than 60");
-
- H.assertQueryBuilderRowCount(110);
- });
-
- it("Zoom in binning drill-through should work (metabase#53556)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(25).click({ force: true });
- H.popover()
- .findByText(/^Zoom in/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Total: 8 bins is greater than or equal to 40",
- );
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Total: 8 bins is less than 60",
- );
-
- H.assertQueryBuilderRowCount(375);
- });
-
- it("Zoom in timeseries drill-through should work (metabase#53556)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.visitQuestion("@nestedQuestionId");
-
- // We can click on any circle; this index was chosen randomly
- H.cartesianChartCircle().eq(25).click({ force: true });
- H.popover()
- .findByText(/^See this month by week/)
- .click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").findByText(
- "Created At is May 1–31, 2027",
- );
-
- H.assertQueryBuilderRowCount(43);
- });
-
it("Sort drill-through should work (metabase#53556)", () => {
cy.intercept("POST", "/api/dataset").as("dataset");
H.visitQuestion("@nestedQuestionId");
@@ -782,278 +651,6 @@ describe("issue 53556 - nested question based on native model with remapped valu
});
});
});
-
-describe("issue 52465 - model with linked columns can still be aggregated", () => {
- const questionDetails = {
- name: "52465",
- type: "model",
- native: {
- query: `
-SELECT
- "ID" AS "id orders",
- "SOURCE" AS "source orders"
-FROM
- "PEOPLE"
-`,
- "template-tags": {},
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("Create model, set metadata, distinct", () => {
- H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {
- cy.intercept(
- "GET",
- `/api/database/${SAMPLE_DB_ID}/schema/PUBLIC?can-query=true`,
- ).as("schema");
- cy.visit(`/model/${id}/columns`);
- cy.wait("@schema");
-
- selectModelColumn("source orders");
- mapModelColumnToDatabase({ table: "People", field: "Source" });
-
- cy.intercept("PUT", "/api/card/*").as("updateModel");
- cy.button("Save changes").click();
- cy.wait("@updateModel");
-
- const nestedQuestionDetails = {
- query: {
- "source-table": `card__${id}`,
- },
- };
-
- H.createQuestion(nestedQuestionDetails, {
- wrapId: true,
- idAlias: "nestedQuestionId",
- });
-
- H.visitQuestion("@nestedQuestionId");
- cy.findByText("Source").click();
- cy.findByText("Distinct values").click();
-
- H.assertQueryBuilderRowCount(1);
- });
- });
-});
-
-describe("issue 31309", () => {
- const TEST_QUERY = {
- "order-by": [["asc", ["field", "sum", { "base-type": "type/Float" }]]],
- limit: 10,
- filter: ["<", ["field", "sum", { "base-type": "type/Float" }], 100],
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [["sum", ["field", ORDERS.TOTAL, null]]],
- breakout: [
- [
- "field",
- PEOPLE.NAME,
- { "base-type": "type/Text", "source-field": ORDERS.USER_ID },
- ],
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should duplicate a model with its original aggregation and breakout", () => {
- H.createQuestion(
- {
- name: "model",
- query: TEST_QUERY,
- database: SAMPLE_DB_ID,
- type: "model",
- },
- {
- visitQuestion: true,
- },
- );
-
- H.openQuestionActions();
- H.popover().findByText("Duplicate").click();
-
- H.modal().within(() => {
- cy.findByText("Duplicate").click();
- });
-
- H.openQuestionActions();
- H.popover().within(() => {
- cy.findByText("Edit query definition").click();
- });
-
- cy.findByTestId("data-step-cell").findByText("Orders").should("exist");
-
- cy.findByTestId("aggregate-step")
- .findByText("Sum of Total")
- .should("exist");
-
- cy.findByTestId("breakout-step").findByText("User → Name").should("exist");
-
- H.getNotebookStep("filter", { stage: 1, index: 0 })
- .findByText("Sum of Total is less than 100")
- .should("exist");
-
- H.getNotebookStep("sort", { stage: 1, index: 0 })
- .findByText("Sum of Total")
- .should("exist");
-
- H.getNotebookStep("limit", { stage: 1, index: 0 })
- .findByDisplayValue("10")
- .should("exist");
- });
-});
-
-describe("issue 32483", () => {
- const createTextFilterMapping = ({ card_id, fieldRef }) => {
- return {
- card_id,
- parameter_id: DASHBOARD_FILTER_TEXT.id,
- target: ["dimension", fieldRef],
- };
- };
- const DASHBOARD_FILTER_TEXT = createMockActionParameter({
- id: "1",
- name: "Text filter",
- slug: "filter-text",
- type: "string/=",
- sectionId: "string",
- });
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("dashboard filter should be applied to the saved model with source containing custom column (metabase#32483)", () => {
- const questionDetails = {
- query: {
- "source-table": PEOPLE_ID,
- expressions: {
- "source state": [
- "concat",
- [
- "field",
- PEOPLE.SOURCE,
- {
- "base-type": "type/Text",
- },
- ],
- " ",
- [
- "field",
- PEOPLE.STATE,
- {
- "base-type": "type/Text",
- },
- ],
- ],
- },
- },
- };
-
- H.createQuestion(questionDetails, { wrapId: true });
-
- cy.get("@questionId").then((questionId) => {
- const modelDetails = {
- type: "model",
- name: "Orders + People Question Model",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- alias: "People - User",
- condition: [
- "=",
- [
- "field",
- ORDERS.USER_ID,
- {
- "base-type": "type/Integer",
- },
- ],
- [
- "field",
- "ID",
- {
- "base-type": "type/BigInteger",
- "join-alias": "People - User",
- },
- ],
- ],
- "source-table": `card__${questionId}`,
- },
- ],
- },
- };
-
- H.createQuestion(modelDetails).then(({ body: { id: modelId } }) => {
- const dashboardDetails = {
- name: "32483 Dashboard",
- parameters: [DASHBOARD_FILTER_TEXT],
- dashcards: [
- createMockDashboardCard({
- id: 1,
- size_x: 8,
- size_y: 8,
- card_id: questionId,
- parameter_mappings: [
- createTextFilterMapping({
- card_id: questionId,
- fieldRef: [
- "expression",
- "source state",
- {
- "base-type": "type/Text",
- },
- ],
- }),
- ],
- }),
- createMockDashboardCard({
- id: 2,
- size_x: 8,
- size_y: 8,
- card_id: modelId,
- parameter_mappings: [
- createTextFilterMapping({
- card_id: modelId,
- fieldRef: [
- "field",
- "source state",
- {
- "base-type": "type/Text",
- "join-alias": "People - User",
- },
- ],
- }),
- ],
- }),
- ],
- };
-
- H.createDashboard(dashboardDetails).then(
- ({ body: { id: dashboardId } }) => {
- H.visitDashboard(dashboardId);
- },
- );
- });
- });
-
- H.filterWidget().click();
- addWidgetStringFilter("Facebook MN");
-
- H.getDashboardCard(1).should("contain", "Orders + People Question Model");
- });
-});
-
describe("issue 40252", () => {
const modelA = {
name: "Model A",
@@ -1193,52 +790,3 @@ describe("issue 42355", () => {
.should("be.visible");
});
});
-
-describe("cumulative count - issue 33330", () => {
- const questionDetails = {
- name: "33330",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["cum-count"]],
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(questionDetails, { visitQuestion: true });
- cy.findAllByTestId("header-cell")
- .should("contain", "Created At: Month")
- .and("contain", "Cumulative count");
- cy.findAllByTestId("cell-data").should("contain", "June 2025");
- });
-
- it("should still work after turning a question into model (metabase#33330-1)", () => {
- turnIntoModel();
- cy.findAllByTestId("header-cell")
- .should("contain", "Created At: Month")
- .and("contain", "Cumulative count");
- cy.findAllByTestId("cell-data").should("contain", "June 2025");
- });
-
- it("should still work after applying a post-aggregation filter (metabase#33330-2)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
- H.filter();
- H.popover().within(() => {
- cy.findByText("Created At").click();
- cy.findByText("Today").click();
- });
- cy.wait("@dataset");
-
- cy.findByTestId("filter-pill").should("have.text", "Created At is today");
- cy.findAllByTestId("header-cell")
- .should("contain", "Created At: Month")
- .and("contain", "Cumulative count");
- cy.findAllByTestId("cell-data")
- .should("have.length", "4")
- .and("not.be.empty");
- cy.findByTestId("question-row-count").should("have.text", "Showing 1 row");
- });
-});
diff --git a/e2e/test/scenarios/native-filters/native-filters-reproductions.cy.spec.js b/e2e/test/scenarios/native-filters/native-filters-reproductions.cy.spec.js
index 235c0f503ce..8089690fd13 100644
--- a/e2e/test/scenarios/native-filters/native-filters-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/native-filters/native-filters-reproductions.cy.spec.js
@@ -1,26 +1,14 @@
const { H } = cy;
-import {
- SAMPLE_DB_ID,
- USER_GROUPS,
- WRITABLE_DB_ID,
-} from "e2e/support/cypress_data";
+import { USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
-const { ORDERS, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
+const { ORDERS, PRODUCTS } = SAMPLE_DATABASE;
const { COLLECTION_GROUP } = USER_GROUPS;
-function runQuery() {
- cy.findByTestId("qb-header").within(() => {
- cy.icon("play").click();
- });
-
- cy.wait("@cardQuery");
-}
-
describe("issue 9357", () => {
beforeEach(() => {
H.restore();
@@ -123,40 +111,6 @@ describe("issue 11580", () => {
});
});
-describe("issue 12228", () => {
- const filter = {
- id: "6b8b10ef-0104-1047-1e1b-2492d5954322",
- name: "created_at",
- "display-name": "Created at",
- type: "dimension",
- dimension: ["field", ORDERS.CREATED_AT, null],
- "widget-type": "date/month-year",
- };
-
- const nativeQuery = {
- name: "12228",
- native: {
- query: "select count(*) from orders where {{created_at}}",
- "template-tags": {
- created_at: filter,
- },
- },
- display: "scalar",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("can load a question with a date filter (metabase#12228)", () => {
- H.createNativeQuestion(nativeQuery).then(({ body: { id } }) => {
- cy.visit(`/question/${id}?created_at=2029-01`);
- cy.contains("580");
- });
- });
-});
-
describe("issue 12581", () => {
const ORIGINAL_QUERY = "SELECT * FROM ORDERS WHERE {{filter}} LIMIT 2";
@@ -451,97 +405,6 @@ describe("issue 14302", () => {
});
});
-describe("issue 15444", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should run with the default field filter set (metabase#15444)", () => {
- H.startNewNativeQuestion();
- SQLFilter.enterParameterizedQuery(
- "select * from products where {{category}}",
- );
-
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
-
- FieldFilter.mapTo({
- table: "Products",
- field: "Category",
- });
-
- SQLFilter.toggleRequired();
-
- FieldFilter.openEntryForm({ isFilterRequired: true });
- // We could've used `FieldFilter.addDefaultStringFilter("Doohickey")` but that's been covered already in the filter test matrix.
- // This flow tests the ability to pick the filter from a dropdown when there are not too many results (easy to choose from).
- H.popover().within(() => {
- cy.findByText("Doohickey").click();
- cy.button("Update filter").click();
- });
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findAllByText("Doohickey");
- cy.findAllByText("Gizmo").should("not.exist");
- });
- });
-});
-
-describe("issue 15460", () => {
- const filter = {
- id: "d98c3875-e0f1-9270-d36a-5b729eef938e",
- name: "category",
- "display-name": "Category",
- type: "dimension",
- dimension: ["field", PRODUCTS.CATEGORY, null],
- "widget-type": "category",
- default: null,
- };
-
- const questionQuery = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- native: {
- query:
- "select p.created_at, products.category\nfrom products\nleft join products p on p.id=products.id\nwhere {{category}}\n",
- "template-tags": {
- category: filter,
- },
- },
- type: "native",
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.visitQuestionAdhoc(questionQuery);
- });
-
- it("should be possible to use field filter on a query with joins where tables have similar columns (metabase#15460)", () => {
- // Set the filter value by picking the value from the dropdown
- H.filterWidget().contains(filter["display-name"]).click();
-
- H.popover().within(() => {
- cy.findByText("Doohickey").click();
- cy.button("Add filter").click();
- });
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findAllByText("Doohickey");
- cy.findAllByText("Gizmo").should("not.exist");
- });
- });
-});
-
describe("issue 15700", () => {
const widgetType = "String is not";
@@ -710,54 +573,6 @@ describe("issue 16756", () => {
});
});
-describe("issue 17019", () => {
- const question = {
- name: "17019",
- native: {
- query: "select {{foo}}",
- "template-tags": {
- foo: {
- id: "08edf340-3d89-cfb1-b7f0-073b9eca6a32",
- name: "foo",
- "display-name": "Filter",
- type: "text",
- },
- },
- },
- display: "scalar",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion(question).then(({ body: { id } }) => {
- // Enable sharing
- cy.request("POST", `/api/card/${id}/public_link`);
-
- H.visitQuestion(id);
- });
- });
-
- it("question filters should work for embedding/public sharing scenario (metabase#17019)", () => {
- H.openSharingMenu(/public link/i);
-
- cy.findByTestId("public-link-popover-content")
- .findByTestId("public-link-input")
- .invoke("val")
- .then((publicLink) => {
- cy.visit(publicLink);
- });
-
- cy.findByPlaceholderText("Filter").type("456{enter}");
-
- // We should see the result as a scalar
- cy.findByTestId("scalar-value").contains("456");
- // But let's also check that the filter widget has that same value still displayed
- cy.findByDisplayValue("456");
- });
-});
-
describe("issue 17490", () => {
function mockDatabaseTables() {
cy.intercept("GET", "/api/database?include=tables", (req) => {
@@ -786,134 +601,6 @@ describe("issue 17490", () => {
});
});
-describe("issue 21160", () => {
- const filterName = "Number comma";
-
- const questionDetails = {
- native: {
- query: "select count(*) from orders where user_id in ({{number_comma}})",
- "template-tags": {
- number_comma: {
- id: "d8870111-7b0f-26f2-81ce-6ec911e54048",
- name: "number_comma",
- "display-name": filterName,
- type: "number",
- },
- },
- },
- display: "scalar",
- };
-
- function resultAssertion(res) {
- cy.findByTestId("scalar-value").invoke("text").should("eq", res);
- }
-
- function getInput() {
- return cy.findByPlaceholderText(filterName);
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion(questionDetails, { visitQuestion: true });
- });
-
- it("number filter should work with values separated by comma (metabase#21160)", () => {
- getInput().type("1,2,3{enter}", { delay: 0 });
-
- runQuery();
- resultAssertion("21");
-
- getInput().clear().type("123,456,789,321{enter}");
-
- runQuery();
- resultAssertion("18");
- });
-});
-
-describe("issue 21246", () => {
- const questionDetails = {
- query: { "source-table": PRODUCTS_ID },
- };
- function resultAssertion(res) {
- cy.findByTestId("scalar-value").invoke("text").should("eq", res);
- }
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(questionDetails).then(({ body: { id } }) => {
- const cardTagName = "#" + id;
-
- const nativeQuestionDetails = {
- native: {
- query: `with exclude_products as {{${cardTagName}}}\nselect count(*) from orders where true [[and {{filter}}]] [[and orders.created_at::date={{datevariable}}]]`,
- "template-tags": {
- filter: {
- id: "e1c37b07-7a85-1df9-a5e4-a0bf748e6dcf",
- name: "filter",
- "display-name": "Field Filter",
- type: "dimension",
- dimension: ["field", ORDERS.CREATED_AT, null],
- "widget-type": "date/month-year",
- default: null,
- },
- datevariable: {
- id: "d4a5fc2d-b223-a5ec-9436-bf6ea5e6b8bf",
- name: "datevariable",
- "display-name": "Date Variable",
- type: "date",
- default: null,
- },
- [cardTagName]: {
- id: "3a0be5e9-e46f-f34f-8e1b-f91567ca4317",
- name: cardTagName,
- "display-name": cardTagName,
- type: "card",
- "card-id": id,
- },
- },
- },
- display: "scalar",
- };
-
- H.createNativeQuestion(nativeQuestionDetails, {
- wrapId: true,
- });
-
- cy.get("@questionId").then((id) => {
- cy.visit(`/question/${id}`);
- cy.wait("@dataset");
-
- cy.findByTestId("scalar-value").invoke("text").should("eq", "18,760");
- });
- });
- });
-
- it("should be able to use sub-query referencing a GUI question and date based filters (metabase#21246)", () => {
- const fieldFilterValue = "filter=2027-02";
- const dateFilterValue = "datevariable=2027-02-19";
-
- cy.get("@questionId").then((id) => {
- // Let's set filter values directly through URL, rather than through the UI
- // for the sake of speed and reliability
- cy.visit(`/question/${id}?${fieldFilterValue}`);
- cy.wait("@dataset");
-
- resultAssertion("404");
-
- cy.visit(`/question/${id}?${fieldFilterValue}&${dateFilterValue}`);
- cy.wait("@dataset");
-
- resultAssertion("12");
- });
- });
-});
-
describe("issue 27257", () => {
beforeEach(() => {
cy.intercept("POST", "/api/dataset").as("dataset");
@@ -950,47 +637,6 @@ describe("issue 27257", () => {
});
});
-describe("issue 29786", { tags: "@external" }, () => {
- const SQL_QUERY = "SELECT * FROM PRODUCTS WHERE {{f1}} AND {{f2}}";
-
- beforeEach(() => {
- H.restore("mysql-8");
- cy.intercept("POST", "/api/dataset").as("dataset");
- cy.signInAsAdmin();
- });
-
- it("should allow using field filters with null schema (metabase#29786)", () => {
- H.startNewNativeQuestion({
- display: "table",
- collection_id: COLLECTION_GROUP,
- query: SQL_QUERY,
- });
-
- cy.findByTestId("native-query-top-bar").icon("variable").click();
-
- cy.findByTestId("tag-editor-variable-f1")
- .findByTestId("variable-type-select")
- .click();
- SQLFilter.chooseType("Field Filter");
- FieldFilter.mapTo({ table: "Products", field: "Category" });
-
- cy.findByTestId("tag-editor-variable-f2")
- .findByTestId("variable-type-select")
- .click();
- SQLFilter.chooseType("Field Filter");
- FieldFilter.mapTo({ table: "Products", field: "Vendor" });
-
- H.filterWidget().should("have.length", 2).first().click();
- FieldFilter.selectFilterValueFromList("Widget");
- H.filterWidget().should("have.length", 2).last().click();
- FieldFilter.addWidgetStringFilter("Von-Gulgowski");
-
- SQLFilter.runQuery();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("1087115303928").should("be.visible");
- });
-});
-
describe("issue 31606", { tags: "@external" }, () => {
const SQL_QUERY = "SELECT * FROM PRODUCTS WHERE CATEGORY = {{test}}";
@@ -1250,70 +896,6 @@ describe("issue 49577", () => {
});
});
-describe("issue 58061", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
- });
-
- it("should allow to pass a field filter value for a date column in the URL when the column has a broken semantic type (metabase#58061)", () => {
- cy.request("PUT", `/api/field/${PRODUCTS.CREATED_AT}`, {
- semantic_type: "type/Category",
- });
-
- H.createNativeQuestion({
- native: {
- query: "SELECT * FROM PRODUCTS WHERE {{filter}}",
- "template-tags": {
- filter: {
- id: "4b77cc1f-ea70-4ef6-84db-58432fce6928",
- name: "filter",
- type: "dimension",
- "display-name": "date",
- dimension: ["field", PRODUCTS.CREATED_AT, null],
- "widget-type": "date/all-options",
- },
- },
- },
- }).then(({ body: card }) => {
- cy.visit({
- url: `/question/${card.id}`,
- qs: { filter: "2027-09-08" },
- });
- cy.wait("@cardQuery");
- H.assertQueryBuilderRowCount(1);
- });
- });
-});
-
-describe("issue 63537", () => {
- beforeEach(() => {
- H.restore("postgres-writable");
- H.resetTestTable({ type: "postgres", table: "many_data_types" });
- cy.signInAsAdmin();
- H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: "many_data_types" });
- });
-
- it("should allow to use postgres enums in field filters (metabase#63537)", () => {
- H.startNewNativeQuestion({ database: WRITABLE_DB_ID });
- H.NativeEditor.type("SELECT * FROM many_data_types WHERE {{f}}");
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
- FieldFilter.mapTo({
- table: "Many Data Types",
- field: "Enum",
- });
- H.filterWidget().click();
- H.popover().within(() => {
- cy.findByText("beta").click();
- cy.button("Add filter").click();
- });
- H.runNativeQuery();
- H.assertQueryBuilderRowCount(2);
- });
-});
-
describe("issue 70311", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/native-filters/sql-field-filter-types.cy.spec.js b/e2e/test/scenarios/native-filters/sql-field-filter-types.cy.spec.js
index e6c85abfd89..84514f1d90c 100644
--- a/e2e/test/scenarios/native-filters/sql-field-filter-types.cy.spec.js
+++ b/e2e/test/scenarios/native-filters/sql-field-filter-types.cy.spec.js
@@ -2,264 +2,9 @@ const { H } = cy;
import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
-import * as DateFilter from "./helpers/e2e-date-filter-helpers";
-import {
- DATE_FILTER_SUBTYPES,
- NUMBER_FILTER_SUBTYPES,
- STRING_FILTER_SUBTYPES,
-} from "./helpers/e2e-field-filter-data-objects";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
-const dateFilters = Object.entries(DATE_FILTER_SUBTYPES);
-
-describe("scenarios > filters > sql filters > field filter > Date", () => {
- function openDateFilterPicker(isFilterRequired) {
- const selector = isFilterRequired
- ? cy.findByText("Select a default value…")
- : H.filterWidget();
-
- return selector.click();
- }
-
- function dateFilterSelector({
- filterType,
- filterValue,
- isFilterRequired = false,
- buttonLabel = "Add filter",
- } = {}) {
- openDateFilterPicker(isFilterRequired);
-
- switch (filterType) {
- case "Month and Year":
- DateFilter.setMonthAndYear(filterValue);
- break;
-
- case "Quarter and Year":
- DateFilter.setQuarterAndYear(filterValue);
- break;
-
- case "Single Date":
- DateFilter.setSingleDate(filterValue);
- cy.findByText(buttonLabel).click();
- break;
-
- case "Date Range":
- DateFilter.setDateRange(filterValue);
- cy.findByText(buttonLabel).click();
- break;
-
- case "Relative Date":
- DateFilter.setRelativeDate(filterValue);
- break;
-
- case "All Options":
- DateFilter.setAdHocFilter(filterValue, buttonLabel);
- break;
-
- default:
- throw new Error("Wrong filter type!");
- }
- }
-
- beforeEach(() => {
- H.restore();
- cy.intercept("POST", "api/dataset").as("dataset");
-
- cy.signInAsAdmin();
-
- H.startNewNativeQuestion();
-
- SQLFilter.enterParameterizedQuery("SELECT * FROM products WHERE {{f}}");
-
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
-
- FieldFilter.mapTo({
- table: "Products",
- field: "Created At",
- });
- });
-
- it("when set through the filter widget", () => {
- dateFilters.forEach(([subType, { value, representativeResult }]) => {
- cy.log(`Make sure it works for ${subType.toUpperCase()}`);
-
- FieldFilter.setWidgetType(subType);
- dateFilterSelector({
- filterType: subType,
- filterValue: value,
- });
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- // Scroll to ensure target element is rendered due to table virtualization
- H.tableInteractiveScrollContainer().scrollTo(0, 300);
- cy.findByText(representativeResult);
- });
- });
- });
-
- it("when set as the default value for a required filter", () => {
- SQLFilter.toggleRequired();
-
- dateFilters.forEach(([subType, { value, representativeResult }], index) => {
- cy.log(`Make sure it works for ${subType.toUpperCase()}`);
-
- FieldFilter.setWidgetType(subType);
-
- dateFilterSelector({
- filterType: subType,
- filterValue: value,
- isFilterRequired: true,
- buttonLabel: "Add filter",
- });
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- // Scroll to ensure target element is rendered due to table virtualization
- H.tableInteractiveScrollContainer().scrollTo(0, 300);
- cy.findByText(representativeResult);
- });
- });
- });
-});
-
-describe("scenarios > filters > sql filters > field filter > Number", () => {
- const numericFilters = Object.entries(NUMBER_FILTER_SUBTYPES);
-
- beforeEach(() => {
- H.restore();
- cy.intercept("POST", "api/dataset").as("dataset");
-
- cy.signInAsAdmin();
-
- H.startNewNativeQuestion();
- SQLFilter.enterParameterizedQuery("SELECT * FROM products WHERE {{f}}");
-
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
-
- FieldFilter.mapTo({
- table: "Products",
- field: "Rating",
- });
- });
-
- it("when set through the filter widget", () => {
- numericFilters.forEach(([subType, { value, representativeResult }]) => {
- cy.log(`Make sure it works for ${subType.toUpperCase()}`);
-
- FieldFilter.setWidgetType(subType);
-
- FieldFilter.openEntryForm();
- FieldFilter.addWidgetNumberFilter(value);
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText(representativeResult);
- });
- });
- });
-
- it("when set as the default value for a required filter", () => {
- SQLFilter.toggleRequired();
-
- numericFilters.forEach(
- ([subType, { value, representativeResult }], index) => {
- cy.log(`Make sure it works for ${subType.toUpperCase()}`);
-
- FieldFilter.setWidgetType(subType);
-
- FieldFilter.addDefaultNumberFilter(value, "Update filter");
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText(representativeResult);
- });
- },
- );
- });
-});
-
-describe("scenarios > filters > sql filters > field filter > String", () => {
- const stringFilters = Object.entries(STRING_FILTER_SUBTYPES);
-
- beforeEach(() => {
- H.restore();
- cy.intercept("POST", "api/dataset").as("dataset");
-
- cy.signInAsAdmin();
-
- H.startNewNativeQuestion({ display: "table" });
- SQLFilter.enterParameterizedQuery("SELECT * FROM products WHERE {{f}}");
-
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
-
- FieldFilter.mapTo({
- table: "Products",
- field: "Title",
- });
- });
-
- it("when set through the filter widget", () => {
- stringFilters.forEach(
- ([subType, { value, representativeResult, isList }]) => {
- cy.log(`Make sure it works for ${subType.toUpperCase()}`);
-
- FieldFilter.setWidgetType(subType);
-
- FieldFilter.openEntryForm();
-
- if (isList) {
- FieldFilter.setWidgetStringFilter(value);
- FieldFilter.selectFilterValueFromList(value);
- } else {
- FieldFilter.addWidgetStringFilter(value);
- }
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText(representativeResult);
- cy.findByText("Toucan").should("not.exist");
- });
- },
- );
- });
-
- it("when set as the default value for a required filter", () => {
- // Use a bigger viewport to avoid elements being obscured by falling out of the screen.
- cy.viewport(1280, 1400);
-
- SQLFilter.toggleRequired();
-
- stringFilters.forEach(
- ([subType, { searchTerm, value, representativeResult }], index) => {
- FieldFilter.setWidgetType(subType);
-
- if (searchTerm) {
- FieldFilter.pickDefaultValue(searchTerm, value, "Update filter");
- } else {
- FieldFilter.addDefaultStringFilter(value);
- }
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText(representativeResult);
- cy.findByText("Toucan").should("not.exist");
- });
- },
- );
- });
-});
-
describe(
"scenarios > filters > sql filters > field filter > Boolean",
{ tags: "@external" },
diff --git a/e2e/test/scenarios/native-filters/sql-field-filter.cy.spec.js b/e2e/test/scenarios/native-filters/sql-field-filter.cy.spec.js
index 42990d85d9d..017c00b4c43 100644
--- a/e2e/test/scenarios/native-filters/sql-field-filter.cy.spec.js
+++ b/e2e/test/scenarios/native-filters/sql-field-filter.cy.spec.js
@@ -85,45 +85,6 @@ describe("scenarios > filters > sql filters > field filter", () => {
H.filterWidget().should("contain.text", "8");
});
});
-
- context("ID filter", () => {
- beforeEach(() => {
- H.startNewNativeQuestion({ display: "table" });
- SQLFilter.enterParameterizedQuery(
- "SELECT * FROM products WHERE {{filter}}",
- );
-
- SQLFilter.openTypePickerFromDefaultFilterType();
- SQLFilter.chooseType("Field Filter");
-
- FieldFilter.mapTo({
- table: "Products",
- field: "ID",
- });
-
- cy.findByTestId("filter-widget-type-select")
- .should("have.value", "ID")
- .should("be.disabled");
- });
-
- it("should work when set initially as default value and then through the filter widget", () => {
- cy.log("the default value should apply");
- FieldFilter.addDefaultStringFilter("2", "Add filter");
- SQLFilter.runQuery();
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText("Small Marble Shoes");
- });
-
- cy.log("the default value should not apply when the value is cleared");
- H.clearFilterWidget();
- SQLFilter.runQuery();
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText("Small Marble Shoes");
- cy.findByText("Rustic Paper Wallet");
- });
- });
- });
-
// Deprecated field filter types
context("Category", () => {
const questionDetails = {
diff --git a/e2e/test/scenarios/native-filters/sql-filters-source.cy.spec.js b/e2e/test/scenarios/native-filters/sql-filters-source.cy.spec.js
index fd57a0c05f2..9a9916dae19 100644
--- a/e2e/test/scenarios/native-filters/sql-filters-source.cy.spec.js
+++ b/e2e/test/scenarios/native-filters/sql-filters-source.cy.spec.js
@@ -1,13 +1,10 @@
const { H } = cy;
-import { SAMPLE_DB_ID, USER_GROUPS } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import * as FieldFilter from "./helpers/e2e-field-filter-helpers";
import * as SQLFilter from "./helpers/e2e-sql-filter-helpers";
const { PRODUCTS_ID, PRODUCTS } = SAMPLE_DATABASE;
-const { COLLECTION_GROUP } = USER_GROUPS;
-
const structuredSourceQuestion = {
name: "MBQL source",
query: {
@@ -151,70 +148,6 @@ describe("scenarios > filters > sql filters > values source", () => {
cy.wait("@cardParameterValues");
checkFilterValueInList("Gizmo");
});
-
- it("should be able to use a structured question source when embedded", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getStructuredDimensionTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("Doohickey");
- FieldFilter.selectFilterValueFromList("Gizmo");
- });
-
- it("should be able to use a structured question source when embedded with a text tag", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getStructuredTextTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("Doohickey");
- FieldFilter.selectFilterValueFromList("Gizmo");
- });
-
- it("should be able to use a structured question source when public", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getStructuredDimensionTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("Doohickey");
- FieldFilter.selectFilterValueFromList("Gizmo");
- });
-
- it("should be able to use a structured question source when public with a text tag", () => {
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getStructuredTextTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("Doohickey");
- FieldFilter.selectFilterValueFromList("Gizmo");
- });
});
describe("native question source", () => {
@@ -237,70 +170,6 @@ describe("scenarios > filters > sql filters > values source", () => {
FieldFilter.selectFilterValueFromList("1018947080336");
SQLFilter.runQuery("cardQuery");
});
-
- it("should be able to use a native question source when embedded", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getNativeDimensionTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- });
-
- it("should be able to use a native question source when embedded with a text tag", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getNativeTextTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- });
-
- it("should be able to use a native question source when public", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getNativeDimensionTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- });
-
- it("should be able to use a native question source when public with a text tag", () => {
- H.createNativeQuestion(nativeSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getNativeTextTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
- },
- );
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- });
});
describe("static list source (dropdown)", () => {
@@ -322,36 +191,6 @@ describe("scenarios > filters > sql filters > values source", () => {
cy.findByLabelText("Tag").should("contain.text", "1018947080336");
SQLFilter.runQuery("cardQuery");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values: ["1018947080336", "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- cy.findByLabelText("Tag").should("contain.text", "1018947080336");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values: ["1018947080336", "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- FieldFilter.selectFilterValueFromList("1018947080336");
- cy.findByLabelText("Tag").should("contain.text", "1018947080336");
- });
});
describe("static list source with custom labels (dropdown)", () => {
@@ -376,38 +215,6 @@ describe("scenarios > filters > sql filters > values source", () => {
cy.findByLabelText("Tag").should("contain.text", "Custom Label");
SQLFilter.runQuery("cardQuery");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values: [["1018947080336", "Custom Label"], "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- checkFilterValueNotInList("1018947080336");
- FieldFilter.selectFilterValueFromList("Custom Label");
- cy.findByLabelText("Tag").should("contain.text", "Custom Label");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values: [["1018947080336", "Custom Label"], "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("0001664425970");
- checkFilterValueNotInList("1018947080336");
- FieldFilter.selectFilterValueFromList("Custom Label");
- cy.findByLabelText("Tag").should("contain.text", "Custom Label");
- });
});
describe("static list source (search box)", () => {
@@ -439,50 +246,6 @@ describe("scenarios > filters > sql filters > values source", () => {
cy.findByLabelText("Tag").should("contain.text", "1018947080336");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values_query_type: "search",
- values: ["1018947080336", "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
-
- H.fieldValuesCombobox().type("101");
- H.popover().findByText("1018947080336").click();
- H.fieldValuesValue(0)
- .should("be.visible")
- .should("contain", "1018947080336");
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "1018947080336");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values_query_type: "search",
- values: ["1018947080336", "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
-
- H.fieldValuesCombobox().type("101");
- H.popover().findByText("1018947080336").click();
- H.fieldValuesValue(0)
- .should("be.visible")
- .should("contain", "1018947080336");
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "1018947080336");
- });
});
describe("static list source with custom labels (search box)", () => {
@@ -516,109 +279,8 @@ describe("scenarios > filters > sql filters > values source", () => {
cy.findByLabelText("Tag").should("contain.text", "Custom Label");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values_query_type: "search",
- values: [["1018947080336", "Custom Label"], "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
-
- H.fieldValuesCombobox().type("Custom Label");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("1018947080336").should("not.exist");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Custom Label").click();
- H.fieldValuesValue(0)
- .should("be.visible")
- .should("contain", "Custom Label");
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "Custom Label");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getListDimensionTargetQuestion({
- values_query_type: "search",
- values: [["1018947080336", "Custom Label"], "7663515285824"],
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
-
- H.fieldValuesCombobox().type("Custom Label");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("1018947080336").should("not.exist");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Custom Label").click();
- H.fieldValuesValue(0)
- .should("be.visible")
- .should("contain", "Custom Label");
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "Custom Label");
- });
});
});
-
-describe("scenarios > filters > sql filters > values source", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- H.activateToken("pro-self-hosted");
- H.blockUserGroupPermissions(USER_GROUPS.ALL_USERS_GROUP);
- cy.intercept("POST", "/api/dataset/parameter/values").as("parameterValues");
- cy.intercept("GET", "/api/card/*/params/*/values").as(
- "cardParameterValues",
- );
- });
-
- it("should sandbox parameter values in questions", () => {
- cy.updatePermissionsGraph({
- [COLLECTION_GROUP]: {
- [SAMPLE_DB_ID]: {
- "view-data": "unrestricted",
- "create-queries": "query-builder",
- },
- },
- });
-
- cy.sandboxTable({
- table_id: PRODUCTS_ID,
- attribute_remappings: {
- attr_cat: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- },
- });
-
- H.createQuestion(structuredSourceQuestion).then(
- ({ body: { id: sourceQuestionId } }) => {
- H.createNativeQuestion(
- getStructuredDimensionTargetQuestion(sourceQuestionId),
- ).then(({ body: { id: targetQuestionId } }) => {
- cy.signOut();
- cy.signInAsSandboxedUser();
- H.visitQuestion(targetQuestionId);
- });
- },
- );
-
- FieldFilter.openEntryForm();
- cy.wait("@cardParameterValues");
- checkFilterValueNotInList("Gadget");
- checkFilterValueNotInList("Gizmo");
- checkFilterValueNotInList("Doohickey");
- FieldFilter.selectFilterValueFromList("Widget");
- });
-});
-
describe("scenarios > filters > sql filters > values source > number parameter", () => {
beforeEach(() => {
H.restore();
@@ -655,48 +317,6 @@ describe("scenarios > filters > sql filters > values source > number parameter",
cy.findByLabelText("X").should("contain.text", "Twenty");
SQLFilter.runQuery("cardQuery");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getNumberTargetQuestion({
- parameter: {
- values_query_type: "list",
- values_source_type: "static-list",
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- },
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("10");
- FieldFilter.selectFilterValueFromList("Twenty");
- cy.findByLabelText("Tag").should("contain.text", "Twenty");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getNumberTargetQuestion({
- parameter: {
- values_query_type: "list",
- values_source_type: "static-list",
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- },
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
- checkFilterValueNotInList("10");
- FieldFilter.selectFilterValueFromList("Twenty");
- cy.findByLabelText("Tag").should("contain.text", "Twenty");
- });
});
describe("static list source with custom labels (dropdown)", () => {
@@ -727,60 +347,6 @@ describe("scenarios > filters > sql filters > values source > number parameter",
cy.findByLabelText("Tag").should("contain.text", "Twenty");
SQLFilter.runQuery("cardQuery");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getNumberTargetQuestion({
- parameter: {
- values_query_type: "search",
- values_source_type: "static-list",
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- },
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
- H.multiAutocompleteInput().type("Tw");
- checkFilterValueNotInList("10");
- checkFilterValueNotInList("20");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Twenty").click();
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "Twenty");
- });
-
- it("should be able to use a static list source when public", () => {
- H.createNativeQuestion(
- getNumberTargetQuestion({
- parameter: {
- values_query_type: "search",
- values_source_type: "static-list",
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- },
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitPublicQuestion(targetQuestionId);
- });
-
- FieldFilter.openEntryForm();
- H.multiAutocompleteInput().type("Tw");
- checkFilterValueNotInList("10");
- checkFilterValueNotInList("20");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Twenty").click();
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "Twenty");
- });
});
describe("static list source (search box)", () => {
@@ -813,34 +379,6 @@ describe("scenarios > filters > sql filters > values source > number parameter",
cy.findByLabelText("Tag").should("contain.text", "Twenty");
});
-
- it("should be able to use a static list source when embedded", () => {
- H.createNativeQuestion(
- getNumberTargetQuestion({
- parameter: {
- values_query_type: "search",
- values_source_type: "static-list",
- values_source_config: {
- values: [["10", "Ten"], ["20", "Twenty"], "30"],
- },
- },
- }),
- ).then(({ body: { id: targetQuestionId } }) => {
- H.visitEmbeddedPage(getQuestionResource(targetQuestionId));
- });
-
- FieldFilter.openEntryForm();
-
- H.multiAutocompleteInput().type("Tw");
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.popover().last().findByText("Twenty").click();
- H.multiAutocompleteValue(0)
- .should("be.visible")
- .should("contain", "Twenty");
- H.popover().button("Add filter").click();
-
- cy.findByLabelText("Tag").should("contain.text", "Twenty");
- });
});
it("should show the values when picking the default value", () => {
@@ -903,160 +441,6 @@ describe("scenarios > filters > sql filters > values source > number parameter",
});
});
-const getQuestionResource = (questionId) => ({
- resource: { question: questionId },
- params: {},
-});
-
-const getTargetQuestion = ({ query, tag, parameter }) => ({
- name: "Embedded",
- native: {
- query,
- "template-tags": {
- tag: {
- id: "93961154-c3d5-7c93-7b59-f4e494fda499",
- name: "tag",
- "display-name": "Tag",
- ...tag,
- },
- },
- },
- parameters: [
- {
- id: "93961154-c3d5-7c93-7b59-f4e494fda499",
- name: "Tag",
- slug: "tag",
- type: "string/=",
- ...parameter,
- },
- ],
- enable_embedding: true,
- embedding_params: {
- tag: "enabled",
- },
-});
-
-const getTextTargetQuestion = ({ query, tag, parameter }) => {
- return getTargetQuestion({
- query,
- tag: {
- type: "text",
- ...tag,
- },
- parameter: {
- target: ["variable", ["template-tag", "tag"]],
- values_query_type: "list",
- ...parameter,
- },
- });
-};
-
-const getStructuredTextTargetQuestion = (questionId) => {
- return getTextTargetQuestion({
- query: "SELECT * FROM PRODUCTS WHERE CATEGORY = {{tag}}",
- parameter: {
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", PRODUCTS.CATEGORY, null],
- },
- },
- });
-};
-
-const getNativeTextTargetQuestion = (questionId) => {
- return getTextTargetQuestion({
- query: "SELECT * FROM PRODUCTS WHERE EAN = {{tag}}",
- parameter: {
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", "EAN", { "base-type": "type/Text" }],
- },
- },
- });
-};
-
-const getNumberTargetQuestion = ({ tag, parameter }) => {
- return getTargetQuestion({
- query: "SELECT {{tag}}",
- tag: {
- type: "number",
- ...tag,
- },
- parameter: {
- type: "number/=",
- target: ["variable", ["template-tag", "tag"]],
- ...parameter,
- },
- });
-};
-
-const getDimensionTargetQuestion = ({ tag, parameter }) => {
- return getTargetQuestion({
- query: "SELECT * FROM PRODUCTS WHERE {{tag}}",
- tag: {
- type: "dimension",
- "widget-type": "string/=",
- dimension: ["field", PRODUCTS.CATEGORY, null],
- ...tag,
- },
- parameter: {
- target: ["dimension", ["template-tag", "tag"]],
- ...parameter,
- },
- });
-};
-
-const getStructuredDimensionTargetQuestion = (questionId) => {
- return getDimensionTargetQuestion({
- tag: {
- dimension: ["field", PRODUCTS.CATEGORY, null],
- },
- parameter: {
- target: ["dimension", ["template-tag", "tag"]],
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", PRODUCTS.CATEGORY, null],
- },
- },
- });
-};
-
-const getNativeDimensionTargetQuestion = (questionId) => {
- return getDimensionTargetQuestion({
- tag: {
- dimension: ["field", PRODUCTS.EAN, null],
- },
- parameter: {
- values_source_type: "card",
- values_source_config: {
- card_id: questionId,
- value_field: ["field", "EAN", { "base-type": "type/Text" }],
- },
- },
- });
-};
-
-const getListDimensionTargetQuestion = ({
- values_query_type = "list",
- values,
-}) => {
- return getDimensionTargetQuestion({
- tag: {
- dimension: ["field", PRODUCTS.EAN, null],
- },
- parameter: {
- values_query_type,
- values_source_type: "static-list",
- values_source_config: {
- values,
- },
- },
- });
-};
-
const updateQuestion = () => {
cy.findByText("Save").click();
cy.findByTestId("save-question-modal").within((modal) => {
diff --git a/e2e/test/scenarios/native-filters/sql-filters.cy.spec.js b/e2e/test/scenarios/native-filters/sql-filters.cy.spec.js
index 2988f206a40..2fe97cf1b96 100644
--- a/e2e/test/scenarios/native-filters/sql-filters.cy.spec.js
+++ b/e2e/test/scenarios/native-filters/sql-filters.cy.spec.js
@@ -31,18 +31,6 @@ describe("scenarios > filters > sql filters > basic filter types", () => {
});
});
- it("when set as the default value for a required filter", () => {
- SQLFilter.toggleRequired();
- SQLFilter.setDefaultValue("Gizmo");
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText("Rustic Paper Wallet");
- cy.findAllByText("Doohickey").should("not.exist");
- });
- });
-
describe("required tag", () => {
it("does not need a default value to run and save the query", () => {
SQLFilter.toggleRequired();
@@ -101,18 +89,6 @@ describe("scenarios > filters > sql filters > basic filter types", () => {
});
});
- it("when set as the default value for a required filter (metabase#16811)", () => {
- SQLFilter.toggleRequired();
- SQLFilter.setDefaultValue("4.3");
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText("Aerodynamic Linen Coat");
- cy.findAllByText("4.3");
- });
- });
-
describe("required tag", () => {
it("does not need a default value to run and save the query", () => {
SQLFilter.toggleRequired();
@@ -177,24 +153,6 @@ describe("scenarios > filters > sql filters > basic filter types", () => {
});
});
- it("when set as the default value for a required filter", () => {
- SQLFilter.toggleRequired();
-
- cy.findByTestId("sidebar-content")
- .findByText("Select a default value…")
- .click();
- H.popover().within(() => {
- cy.findByText("15").click();
- cy.findByText("Add filter").click();
- });
-
- SQLFilter.runQuery();
-
- cy.findByTestId("query-visualization-root").within(() => {
- cy.findByText("No results");
- });
- });
-
function setDefaultDate(year = "2024", month = "01", day = "22") {
cy.findByTestId("sidebar-content")
.findByText("Select a default value…")
diff --git a/e2e/test/scenarios/native/native-reproductions.cy.spec.js b/e2e/test/scenarios/native/native-reproductions.cy.spec.js
index 3df3449af8a..2458c63e9d7 100644
--- a/e2e/test/scenarios/native/native-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/native/native-reproductions.cy.spec.js
@@ -59,23 +59,6 @@ describe("issue 12439", () => {
H.sidebar().contains("Y-axis");
});
});
-
-describe("issue 15029", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should allow dots in the variable reference (metabase#15029)", () => {
- H.startNewNativeQuestion();
- H.NativeEditor.type(
- "select * from products where RATING = {{number.of.stars}}",
- );
-
- cy.findAllByText("Variable name").parent().findByText("number.of.stars");
- });
-});
-
describe("issue 16886", () => {
const ORIGINAL_QUERY = "select 1 from orders";
const SELECTED_TEXT = "select 1";
diff --git a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts b/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
index 02656ddeff4..64e1fd9be86 100644
--- a/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/native/native-reproductions.cy.spec.ts
@@ -2,10 +2,7 @@ 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 {
- NativeQuestionDetails,
- StructuredQuestionDetails,
-} from "e2e/support/helpers";
+import type { NativeQuestionDetails } from "e2e/support/helpers";
import type {
Database,
IconName,
@@ -721,50 +718,6 @@ describe("issue 59110", () => {
});
});
});
-
-describe("issue 60719", () => {
- const question1Details: NativeQuestionDetails = {
- name: "Q1",
- native: {
- query: "select 1 as num",
- "template-tags": {},
- },
- };
-
- function getQuestion2Details(card1Id: number): StructuredQuestionDetails {
- return {
- name: "Q2",
- query: {
- "source-table": `card__${card1Id}`,
- },
- };
- }
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("PUT", "/api/card/*").as("updateCard");
- });
-
- it("should prevent saving a native query with a circular reference (metabase#60719)", () => {
- H.createNativeQuestion(question1Details).then(({ body: card1 }) => {
- H.createQuestion(getQuestion2Details(card1.id)).then(
- ({ body: card2 }) => {
- H.visitQuestion(card1.id);
- cy.findByTestId("visibility-toggler").click();
- H.NativeEditor.clear().type(`select * from {{#${card2.id}-q2}}`);
- },
- );
- });
- H.queryBuilderHeader().button("Save").click();
- H.modal().within(() => {
- cy.button("Save").click();
- cy.wait("@updateCard");
- cy.findByText("Cannot save card with cycles.").should("be.visible");
- });
- });
-});
-
describe("issue 59356", () => {
function typeRunShortcut() {
cy.realPress([H.metaKey, "Enter"]);
diff --git a/e2e/test/scenarios/native/native.cy.spec.js b/e2e/test/scenarios/native/native.cy.spec.js
index 956d8ee3854..2eb8fd33787 100644
--- a/e2e/test/scenarios/native/native.cy.spec.js
+++ b/e2e/test/scenarios/native/native.cy.spec.js
@@ -7,7 +7,7 @@ import {
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { THIRD_COLLECTION_ID } from "e2e/support/cypress_sample_instance_data";
-const { ORDERS_ID, ORDERS, PEOPLE } = SAMPLE_DATABASE;
+const { ORDERS_ID, ORDERS } = SAMPLE_DATABASE;
const ORDERS_SCALAR_METRIC = {
name: "Count of orders",
@@ -232,88 +232,6 @@ describe("scenarios > question > native", () => {
);
});
- it("should run saved question with time grouping", () => {
- const questionWithDefaultValue = {
- name: "Saved question with time grouping",
- native: {
- query:
- "SELECT count(*), {{unit}} as unit FROM ORDERS GROUP BY unit",
- "template-tags": {
- unit: {
- type: "temporal-unit",
- name: "unit",
- id: "eb345703-001c-4b2a-b7d5-71cb3efe4beb",
- "display-name": "Unit",
- dimension: ["field", ORDERS.CREATED_AT, null],
- required: true,
- default: "year",
- },
- },
- },
- };
- const questionWithoutDefaultValue = {
- name: "Saved question with time grouping",
- native: {
- query:
- "SELECT count(*), {{unit}} as unit FROM ORDERS GROUP BY unit",
- "template-tags": {
- unit: {
- type: "temporal-unit",
- name: "unit",
- id: "eb345703-001c-4b2a-b7d5-71cb3efe4beb",
- "display-name": "Unit",
- dimension: ["field", ORDERS.CREATED_AT, null],
- required: true,
- },
- },
- },
- };
-
- H.createNativeQuestion(questionWithDefaultValue, {
- wrapId: true,
- idAlias: "q1",
- }).then(() => {
- return H.createNativeQuestion(questionWithoutDefaultValue, {
- wrapId: true,
- idAlias: "q2",
- });
- });
-
- cy.get("@q1").then((questionId) => {
- H.visitQuestion(questionId);
- });
-
- cy.log(
- "verify that saved query with time grouping can run and return correct results",
- );
- cy.findByTestId("visualization-root").should(
- "contain",
- "January 1, 2025",
- );
-
- cy.get("@q2").then((questionId) => {
- H.visitQuestion(questionId);
- });
-
- cy.log(
- "verify that saved query without time grouping can run and return correct results",
- );
- cy.findByTestId("query-visualization-root").should(
- "contain",
- "You'll need to pick a value for 'Unit' before this query can run.",
- );
-
- H.filterWidget().click();
- H.popover().findByText("Year").click();
-
- cy.findAllByTestId("run-button").first().click();
-
- cy.findByTestId("visualization-root").should(
- "contain",
- "January 1, 2025",
- );
- });
-
it("should reset default value when time grouping options are changed", () => {
const questionWithDefaultValue = {
name: "Saved question with time grouping",
@@ -359,79 +277,6 @@ describe("scenarios > question > native", () => {
H.rightSidebar().should("contain", "Enter a default value…");
});
- it("should handle time grouping in optional clause", () => {
- const questionWithDefaultValue = {
- name: "Saved question with time grouping",
- native: {
- query: `
- SELECT
- ID [[,{{unit}} as unit]]
- FROM
- PEOPLE
- ORDER BY
- ID
- LIMIT
- 10
- `,
- "template-tags": {
- unit: {
- type: "temporal-unit",
- name: "unit",
- id: "eb345703-001c-4b2a-b7d5-71cb3efe4beb",
- "display-name": "Unit",
- dimension: ["field", PEOPLE.CREATED_AT, null],
- default: "year",
- },
- },
- },
- };
-
- H.createNativeQuestion(questionWithDefaultValue, {
- visitQuestion: true,
- });
-
- cy.findByTestId("visualization-root")
- .should("contain", "January 1, 2025")
- .should("contain", "January 1, 2026");
- });
-
- it("should handle time grouping in optional clause without default value", () => {
- const questionWithDefaultValue = {
- name: "Saved question with time grouping",
- native: {
- query: `
- SELECT
- ID [[,{{unit}} as unit]]
- FROM
- PEOPLE
- WHERE
- 1 = 1 [[AND ID = {{x}}]]
- ORDER BY
- ID
- LIMIT
- 10
- `,
- "template-tags": {
- unit: {
- type: "temporal-unit",
- name: "unit",
- id: "eb345703-001c-4b2a-b7d5-71cb3efe4beb",
- dimension: ["field", PEOPLE.CREATED_AT, null],
- "display-name": "Unit",
- },
- },
- },
- };
-
- H.createNativeQuestion(questionWithDefaultValue, {
- visitQuestion: true,
- });
-
- cy.findByTestId("query-visualization-root")
- .should("not.contain", "October 7, 2026, 1:34 AM")
- .should("not.contain", "UNIT");
- });
-
it("should show validation error when query is invalid", () => {
H.startNewNativeQuestion();
H.NativeEditor.type(
@@ -464,68 +309,6 @@ describe("scenarios > question > native", () => {
cy.location("pathname").should("match", /\/question\/\d+/);
});
- it("shouldn't remove rows containing NULL when using 'Is not' or 'Does not contain' filter (metabase#13332, metabase#37100)", () => {
- const FILTERS = ["Is not", "Does not contain"];
-
- const questionDetails = {
- name: "13332",
- native: {
- query:
- 'SELECT null AS "V", 1 as "N" UNION ALL SELECT \'This has a value\' AS "V", 2 as "N"',
- "template-tags": {},
- },
- };
-
- H.createNativeQuestion(questionDetails).then(({ body: { id } }) => {
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": `card__${id}`,
- },
- type: "query",
- },
- });
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("This has a value");
-
- FILTERS.forEach((operator) => {
- cy.log("Apply a filter");
- H.filter();
- H.popover().findByText("V").click();
- H.selectFilterOperator(operator);
- H.popover().within(() => {
- cy.findByLabelText("Filter value").type("This has a value");
- cy.button("Apply filter").click();
- });
-
- cy.log(
- `**Mid-point assertion for "${operator}" filter| FAILING in v0.36.6**`,
- );
- cy.findByText(`V ${operator.toLowerCase()} This has a value`);
- cy.findByText("No results").should("not.exist");
-
- cy.log(
- "**Final assertion: Count of rows with 'null' value should be 1**",
- );
- // "Count" is pre-selected option for "Summarize"
- H.summarize();
- cy.findByText("Done").click();
- cy.findByTestId("scalar-value").contains("1");
-
- cy.findByTestId("qb-filters-panel").within(() => {
- cy.icon("close").click();
- });
- H.summarize();
- H.rightSidebar().within(() => {
- cy.icon("close").click();
- });
- cy.findByText("Done").click();
- });
- });
-
it("should be able to add new columns after hiding some (metabase#15393)", () => {
H.startNewNativeQuestion({ display: "table" });
H.NativeEditor.type("select 1 as visible, 2 as hidden");
diff --git a/e2e/test/scenarios/native/native_subquery.cy.spec.js b/e2e/test/scenarios/native/native_subquery.cy.spec.js
index 9a9403ebc93..853c36b35c2 100644
--- a/e2e/test/scenarios/native/native_subquery.cy.spec.js
+++ b/e2e/test/scenarios/native/native_subquery.cy.spec.js
@@ -1,8 +1,5 @@
const { H } = cy;
-import {
- ADMIN_PERSONAL_COLLECTION_ID,
- ORDERS_QUESTION_ID,
-} from "e2e/support/cypress_sample_instance_data";
+import { ADMIN_PERSONAL_COLLECTION_ID } from "e2e/support/cypress_sample_instance_data";
describe("scenarios > question > native subquery", () => {
beforeEach(() => {
@@ -212,103 +209,4 @@ describe("scenarios > question > native subquery", () => {
});
});
});
-
- it("should allow a user with no data access to execute a native subquery", () => {
- // Create the initial SQL question and followup nested question
- H.createNativeQuestion({
- name: "People in WA",
- native: {
- query: "select * from PEOPLE where STATE = 'WA'",
- },
- })
- .then((response) => {
- cy.wrap(response.body.id).as("nestedQuestionId");
- const tagID = `#${response.body.id}`;
-
- H.createNativeQuestion({
- name: "Count of People in WA",
- native: {
- query: `select COUNT(*) from {{#${response.body.id}}}`,
- "template-tags": {
- [tagID]: {
- id: "10422a0f-292d-10a3-fd90-407cc9e3e20e",
- name: tagID,
- "display-name": tagID,
- type: "card",
- "card-id": response.body.id,
- },
- },
- },
- });
- })
- .then((response) => {
- cy.wrap(response.body.id).as("toplevelQuestionId");
-
- cy.visit(`/question/${response.body.id}`);
- cy.contains("41");
- });
-
- // Now sign in as a user w/no data access
- cy.signIn("nodata");
-
- // They should be able to access both questions
- H.visitQuestion("@nestedQuestionId");
- cy.findByTestId("question-row-count").should(
- "have.text",
- "Showing 41 rows",
- );
-
- H.visitQuestion("@toplevelQuestionId");
- H.tableInteractiveBody()
- .findAllByTestId("cell-data")
- .eq(0)
- .should("have.text", "41");
- });
-
- it("should be able to reference a nested question (metabase#25988)", () => {
- const questionDetails = {
- name: "Nested GUI question",
- query: {
- "source-table": `card__${ORDERS_QUESTION_ID}`,
- limit: 2,
- },
- };
-
- H.createQuestion(questionDetails).then(
- ({ body: { id: nestedQuestionId } }) => {
- const tagID = `#${nestedQuestionId}`;
- cy.intercept("GET", `/api/card/${nestedQuestionId}`).as("loadQuestion");
-
- H.startNewNativeQuestion();
- H.NativeEditor.type(`SELECT * FROM {{${tagID}`);
- cy.wait("@loadQuestion");
- cy.findByTestId("sidebar-header-title").should(
- "have.text",
- questionDetails.name,
- );
-
- H.runNativeQuery();
- cy.findAllByTestId("cell-data").should("contain", "37.65");
- },
- );
- });
-
- it("should be able to reference a saved native question that ends with a semicolon `;` (metabase#28218)", () => {
- const questionDetails = {
- name: "28218",
- native: { query: "select 1;" }, // semicolon is important here
- };
-
- H.createNativeQuestion(questionDetails).then(
- ({ body: { id: baseQuestionId } }) => {
- const tagID = `#${baseQuestionId}`;
-
- H.startNewNativeQuestion({ display: "table" });
- H.NativeEditor.type(`SELECT * FROM {{${tagID}`);
-
- H.runNativeQuery();
- cy.findAllByTestId("cell-data").should("contain", "1");
- },
- );
- });
});
diff --git a/e2e/test/scenarios/native/snippet-tags.cy.spec.ts b/e2e/test/scenarios/native/snippet-tags.cy.spec.ts
index e0faa7e6e90..8a59d35ed6c 100644
--- a/e2e/test/scenarios/native/snippet-tags.cy.spec.ts
+++ b/e2e/test/scenarios/native/snippet-tags.cy.spec.ts
@@ -96,45 +96,6 @@ describe("scenarios > native > snippet tags", () => {
H.tableInteractive().should("be.visible");
});
- it("should be able to create a tag with the same name as the inner snippet tag", () => {
- createQuestionAndSnippet().then(({ card }) => {
- H.visitQuestion(card.id);
- });
-
- cy.log("add a local tag with the same name");
- getEditorVisibilityToggler().click();
- H.NativeEditor.type(" and category = {{filter}}");
-
- cy.log("verify that the query can be run");
- getEditorTopBar().findByPlaceholderText("Filter").type("Widget");
- H.runNativeQuery();
- H.assertQueryBuilderRowCount(54);
- });
-
- it("should be able to use snippets where tags overlap", () => {
- cy.log("create snippets with overlapping tags");
- H.createSnippet({
- name: "snippet1",
- content: "category = {{category1}} or category = {{category2}}",
- });
- H.createSnippet({
- name: "snippet2",
- content: "category = {{category2}}",
- });
-
- cy.log("use both snippets in a query");
- H.startNewNativeQuestion();
- H.NativeEditor.type(
- "select id from products where {{snippet: snippet1}} or {{snippet: snippet2}}",
- );
-
- cy.log("verify that the query can be run");
- getEditorTopBar().findByPlaceholderText("Category1").type("Widget");
- getEditorTopBar().findByPlaceholderText("Category2").type("Gadget");
- H.runNativeQuery();
- H.assertQueryBuilderRowCount(107);
- });
-
it("should be able to update a snippet and change tags", () => {
createQuestionAndSnippet().then(({ card }) => {
H.visitQuestion(card.id);
@@ -209,159 +170,6 @@ describe("scenarios > native > snippet tags", () => {
H.runNativeQuery();
H.assertQueryBuilderRowCount(53);
});
-
- it("should be able to open a question with an old snippet name", () => {
- createQuestionAndSnippet().then(({ card, snippet }) => {
- cy.request("PUT", `/api/native-query-snippet/${snippet.id}`, {
- name: "category-snippet",
- });
- cy.visit(`/question/${card.id}`);
- });
-
- cy.log("verify that the parameter can be used");
- getEditorTopBar().findByPlaceholderText("Filter").type("Widget");
- H.queryBuilderHeader().icon("play").click();
- H.assertQueryBuilderRowCount(54);
- });
-
- it("should not be able to create card cycles via snippets", () => {
- cy.log("create a card and a snippet referencing this card");
- H.createNativeQuestion({
- native: {
- query: "select 1",
- },
- }).then(({ body: card }) => {
- H.createSnippet({
- name: "cycle-snippet",
- content: `{{#${card.id}}}`,
- });
- H.visitQuestion(card.id);
- });
-
- cy.log("create a cycle and try to save the card");
- getEditorVisibilityToggler().click();
- H.NativeEditor.clear();
- H.NativeEditor.type("select * from {{snippet: cycle-snippet}}");
- H.queryBuilderHeader().button("Save").click();
- H.modal().within(() => {
- cy.button("Save").click();
- cy.findByText("Cannot save card with cycles.").should("be.visible");
- });
- });
-
- it("should not be able to create snippet cycles via snippets", () => {
- cy.log("create two snippets, one using another");
- H.createSnippet({
- name: "snippet1",
- content: "1",
- });
- H.createSnippet({
- name: "snippet2",
- content: "{{snippet: snippet1}}",
- });
-
- cy.log("open the modal for the first snippet");
- H.startNewNativeQuestion();
- getEditorTopBar().icon("snippet").click();
- getEditorSidebar().within(() => {
- cy.icon("chevrondown")
- .should("have.length", 2)
- .first()
- .click({ force: true });
- cy.button(/Edit/).click();
- });
-
- cy.log("create a cycle and save the first snippet");
- H.modal().within(() => {
- getSnippetContentInput()
- .clear()
- .type("{{snippet: snippet2}}", { parseSpecialCharSequences: false })
- .click();
- cy.button("Save").click();
- });
-
- cy.log("run the query and verify that we detect a cycle");
- H.NativeEditor.type("select {{snippet: snippet1}}");
- H.runNativeQuery();
- H.queryBuilderMain()
- .findByText(
- 'This query has circular referencing sub-queries. The snippet "snippet2" and the snippet "snippet1" seem to be part of the problem.',
- )
- .should("be.visible");
-
- cy.log(
- "try to save a question with a snippet cycle and verify we detect it",
- );
- H.queryBuilderHeader().findByText("Save").click();
- H.modal().within(() => {
- cy.findByLabelText("Name").type("SQL");
- cy.button("Save").click();
- cy.findByText("Cannot save card with cycles.").should("be.visible");
- cy.button("Cancel").click();
- });
-
- cy.log(
- "remove a cycle, save the card, add a cycle again and verify that we detect it on update",
- );
- H.NativeEditor.clear().type("select 1");
- H.saveQuestion("SQL", undefined, {
- path: ["Our analytics"],
- });
- H.NativeEditor.clear().type("select {{snippet: snippet1}}");
- H.queryBuilderHeader().button("Save").click();
- H.modal().within(() => {
- cy.button("Save").click();
- cy.findByText("Cannot save card with cycles.").should("be.visible");
- });
- });
-
- it("should work for a public or embedded question", () => {
- createQuestionAndSnippet().then(({ card }) => {
- cy.log("public question - no parameter value");
- H.visitPublicQuestion(card.id);
- H.assertTableRowsCount(200);
-
- cy.log("public question - with parameter value");
- H.filterWidget().findByLabelText("Filter").type("Gadget{enter}");
- H.assertTableRowsCount(53);
-
- cy.log("embedded question - no parameter value");
- H.visitEmbeddedPage({
- resource: { question: card.id },
- params: {},
- });
- H.assertTableRowsCount(200);
-
- cy.log("embedded question - with parameter value");
- H.filterWidget().findByLabelText("Filter").type("Gadget{enter}");
- H.assertTableRowsCount(53);
- });
- });
-
- it("should handle snippet tags with trailing spaces correctly", () => {
- cy.log("create a snippet");
- H.createSnippet({
- name: "category filter",
- content: "category = {{category}}",
- });
-
- H.startNewNativeQuestion();
-
- cy.log("type a query with snippet tags containing trailing spaces");
- H.NativeEditor.type(
- "select id from products where {{snippet: category filter }}",
- );
-
- cy.log("verify snippet reference is recognized");
- getEditorTopBar().within(() => {
- cy.findByPlaceholderText("Category").should("be.visible");
- });
-
- cy.log("verify the query can be run with the parameter");
- getEditorTopBar().findByPlaceholderText("Category").type("Widget");
- H.runNativeQuery();
- H.assertQueryBuilderRowCount(54);
- });
});
function getEditorSidebar() {
diff --git a/e2e/test/scenarios/native/table-tags.cy.spec.ts b/e2e/test/scenarios/native/table-tags.cy.spec.ts
index af80fdf7d60..b81f86718c4 100644
--- a/e2e/test/scenarios/native/table-tags.cy.spec.ts
+++ b/e2e/test/scenarios/native/table-tags.cy.spec.ts
@@ -15,29 +15,4 @@ describe("scenarios > native > table tags", () => {
H.runNativeQuery();
H.assertQueryBuilderRowCount(200);
});
-
- it("should run the query with a table tag inside a snippet", () => {
- H.startNewNativeQuestion();
-
- cy.log("create a snippet containing a table tag");
- cy.findByTestId("native-query-top-bar").icon("snippet").click();
- cy.findByTestId("sidebar-right").findByText("Create snippet").click();
- H.modal().within(() => {
- cy.findByLabelText("Enter some SQL here so you can reuse it later").type(
- "select * from {{table}}",
- { parseSpecialCharSequences: false },
- );
- cy.findByLabelText("Give your snippet a name").type("TableSnippet");
- cy.button("Save").click();
- });
-
- cy.log("map the table variable to the Products table");
- cy.findByTestId("variable-type-select").click();
- H.popover().findByText("Table").click();
- H.popover().findByText("Products").click();
-
- cy.log("run the query and verify results");
- H.runNativeQuery();
- H.assertQueryBuilderRowCount(200);
- });
});
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js b/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js
index 3f8612ed2ae..f518cfc3523 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/question-reproductions/reproductions-1.cy.spec.js
@@ -1,68 +1,13 @@
const { H } = cy;
-import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
+import { WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
import { setAdHocFilter } from "../native-filters/helpers/e2e-date-filter-helpers";
-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, REVIEWS, REVIEWS_ID } =
- SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
const QUESTION_NAME = "Foo";
-const MONGO_DB_ID = 2;
-
-describe("issue 4482", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.openTable({
- table: PRODUCTS_ID,
- mode: "notebook",
- });
-
- cy.findByRole("button", { name: "Summarize" }).click();
- });
-
- it("should be possible to summarize min of a temporal column (metabase#4482-1)", () => {
- pickMetric("Minimum of");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Created At").click();
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("April 1, 2025, 12:00 AM");
- });
-
- it("should be possible to summarize max of a temporal column (metabase#4482-2)", () => {
- pickMetric("Maximum of");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Created At").click();
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("April 1, 2028, 12:00 AM");
- });
-
- it("should be not possible to average a temporal column (metabase#4482-3)", () => {
- pickMetric("Average of");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Created At").should("not.exist");
- });
-});
-
-function pickMetric(metric) {
- cy.contains("Pick a function or metric").click();
-
- cy.contains(metric).click();
- cy.findByText("Price");
- cy.findByText("Rating");
-}
describe("issue 6239", () => {
beforeEach(() => {
@@ -188,87 +133,6 @@ function openEllipsisMenuFor(item) {
.click({ force: true });
}
-describe("issue 13097", { tags: "@mongo" }, () => {
- beforeEach(() => {
- H.restore("mongo-5");
- cy.signInAsAdmin();
-
- H.withDatabase(MONGO_DB_ID, ({ PEOPLE_ID }) => {
- const questionDetails = {
- dataset_query: {
- type: "query",
- query: { "source-table": PEOPLE_ID, limit: 5 },
- database: MONGO_DB_ID,
- },
- };
-
- const hash = H.adhocQuestionHash(questionDetails);
-
- cy.visit(`/question/notebook#${hash}`);
- });
- });
-
- it("should correctly apply distinct count on multiple columns (metabase#13097)", () => {
- H.summarize({ mode: "notebook" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Number of distinct values of ...").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("City").click();
-
- cy.findAllByTestId("notebook-cell-item").find(".Icon-add").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Number of distinct values of ...").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("State").click();
-
- H.visualize();
-
- // cy.log("Reported failing on stats ~v0.36.3");
- cy.get("[data-testid=cell-data]")
- .should("have.length", 4)
- .and("contain", "Distinct values of City")
- .and("contain", "1,966")
- .and("contain", "Distinct values of State")
- .and("contain", "49");
- });
-});
-
-describe("postgres > user > query", { tags: "@external" }, () => {
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- cy.request(`/api/database/${WRITABLE_DB_ID}/schema/public`).then(
- ({ body }) => {
- const tableId = body.find((table) => table.name === "orders").id;
- H.openTable({
- database: WRITABLE_DB_ID,
- table: tableId,
- });
- },
- );
- });
-
- it("should show row details when clicked on its entity key (metabase#13263)", () => {
- // We're clicking on ID: 1 (the first order) => do not change!
- // It is tightly coupled to the assertion ("37.65"), which is "Subtotal" value for that order.
- cy.get(".test-Table-ID").eq(0).click();
-
- // Wait until "doing science" spinner disappears (DOM is ready for assertions)
- // TODO: if this proves to be reliable, extract it as a helper function for waiting on DOM to render
- cy.findByTestId("loading-indicator").should("not.exist");
-
- // Assertions
- cy.log("Fails in v0.36.6");
- // This could be omitted because real test is searching for "37.65" on the page
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("There was a problem with your question").should("not.exist");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("37.65");
- });
-});
-
describe("issue 14957", { tags: "@external" }, () => {
const PG_DB_NAME = "QA Postgres12";
@@ -391,62 +255,6 @@ describe("issue 15876", { tags: "@external" }, () => {
});
});
-describe("issue 17512", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("custom expression should work with `case` in nested queries (metabase#17512)", () => {
- H.openOrdersTable({ mode: "notebook" });
-
- addSummarizeCustomExpression(
- "Distinct(case([Discount] > 0, [Subtotal], [Total]))",
- "CE",
- );
-
- cy.findByTestId("aggregate-step").contains("CE").should("exist");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Created At").click();
-
- addCustomColumn("1 + 1", "CC");
-
- H.visualize(({ body }) => {
- expect(body.error).to.not.exist;
- });
-
- cy.findAllByTestId("header-cell").contains("CE").should("exist");
- cy.findAllByTestId("header-cell").contains("CC").should("exist");
- });
-});
-
-function addSummarizeCustomExpression(formula, name) {
- H.summarize({ mode: "notebook" });
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({
- formula,
- name,
- format: true,
- });
- H.expressionEditorWidget().button("Done").click();
-}
-
-function addCustomColumn(formula, name) {
- cy.findByText("Custom column").click();
- H.enterCustomColumnDetails({
- formula,
- name,
- format: true,
- });
- H.expressionEditorWidget().button("Done").click();
-}
-
describe("issue 17514", () => {
const questionDetails = {
name: "17514",
@@ -683,147 +491,6 @@ describe("issue 17910", () => {
});
});
-describe("issue 17963", { tags: "@mongo" }, () => {
- beforeEach(() => {
- H.restore("mongo-5");
- cy.signInAsAdmin();
-
- cy.request(`/api/database/${WRITABLE_DB_ID}/schema/`).then(({ body }) => {
- const tableId = body.find((table) => table.name === "orders").id;
- H.openTable({
- database: WRITABLE_DB_ID,
- table: tableId,
- mode: "notebook",
- });
- });
- });
-
- it("should be able to compare two fields using filter expression (metabase#17963)", () => {
- cy.findByRole("button", { name: "Filter" }).click();
-
- H.popover().contains("Custom Expression").click();
-
- typeAndSelect([
- { string: "dis", field: "Discount" },
- { string: "> quan", field: "Quantity" },
- ]);
-
- H.CustomExpressionEditor.blur();
- cy.button("Done").click();
-
- H.getNotebookStep("filter").findByText("Discount is greater than Quantity");
-
- cy.findByRole("button", { name: /Summarize/ }).click();
- H.popover().findByText("Count of rows").click();
-
- H.visualize();
-
- cy.findByTestId("scalar-value").contains("1,337");
- });
-});
-
-function typeAndSelect(arr) {
- arr.forEach(({ string, field }) => {
- H.CustomExpressionEditor.type(string);
-
- H.CustomExpressionEditor.selectCompletion(field);
- });
-}
-
-describe("issue 18207", () => {
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- H.restore();
- cy.signInAsAdmin();
-
- H.openProductsTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- });
-
- it("should be possible to use MIN on a string column (metabase#18207, metabase#22155)", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Minimum of").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Price");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Rating");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Ean").should("be.visible");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Category").click();
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Doohickey");
- });
-
- it("should be possible to use MAX on a string column (metabase#18207, metabase#22155)", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Maximum of").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Price");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Rating");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Ean").should("be.visible");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Category").click();
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Widget");
- });
-
- it("should be not possible to use AVERAGE on a string column (metabase#18207, metabase#22155)", () => {
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Average of").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Price");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Rating");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Ean").should("not.exist");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Category").should("not.exist");
- });
-
- it("should be possible to group by a string expression (metabase#18207)", () => {
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({
- formula: "Max([Vendor])",
- name: "LastVendor",
- });
-
- H.expressionEditorWidget().button("Done").click();
-
- cy.findByTestId("aggregate-step").contains("LastVendor").should("exist");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Pick a column to group by").click();
- H.popover().contains("Category").click();
-
- H.visualize();
-
- // Why is it not a table?
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Visualization").click();
- H.leftSidebar().within(() => {
- cy.icon("table2").click();
- cy.findByTestId("Table-button").realHover();
- cy.icon("gear").click();
- });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Done").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Zemlak-Wiegand");
- });
-});
-
describe("issues 11914, 18978, 18977, 23857", () => {
beforeEach(() => {
H.restore();
@@ -1164,130 +831,3 @@ const assertQ1PlusQ2Joins = () => {
});
});
};
-
-const foreignKeyColumnName = "Surprisingly long and awesome Product ID";
-const newTableName = "Products with a very long name";
-
-describe("issue 20627", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- renameColumn(ORDERS.PRODUCT_ID, foreignKeyColumnName);
- renameTable(PRODUCTS_ID, newTableName);
- });
-
- it("nested queries should handle long column and/or table names (metabase#20627)", () => {
- H.openOrdersTable({ mode: "notebook" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Join data").click();
-
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText(newTableName).click();
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Summarize").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Count of rows").click();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Pick a column to group by").click();
- H.popover().within(() => {
- cy.findByText(newTableName).click();
-
- cy.findByText("Category").click();
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom column").click();
- H.enterCustomColumnDetails({ formula: "1 + 1", name: "Math" });
- cy.button("Done").click();
-
- H.visualize();
-
- cy.get("[data-testid=cell-data]")
- .should("contain", "Math")
- .and("contain", "Doohickey")
- .and("contain", "3,976");
- });
-});
-
-function renameColumn(columnId, name) {
- cy.request("PUT", `/api/field/${columnId}`, { display_name: name });
-}
-
-function renameTable(tableId, name) {
- cy.request("PUT", `/api/table/${tableId}`, { display_name: name });
-}
-
-describe("issue 20809", () => {
- const questionDetails = {
- name: "20809",
- query: {
- "source-table": REVIEWS_ID,
- filter: [
- "=",
- ["field", PRODUCTS.CATEGORY, { "source-field": REVIEWS.PRODUCT_ID }],
- "Doohickey",
- ],
- aggregation: [["count"]],
- breakout: [["field", REVIEWS.PRODUCT_ID, null]],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(questionDetails).then(({ body: { id } }) => {
- const nestedQuestion = {
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- "source-table": `card__${id}`,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- [
- "field",
- REVIEWS.PRODUCT_ID,
- { "join-alias": `Question ${id}` },
- ],
- ],
- alias: `Question ${id}`,
- },
- ],
- },
- type: "query",
- },
- };
-
- H.visitQuestionAdhoc(nestedQuestion, { mode: "notebook" });
- });
- });
-
- it("nesting should work on a saved question with a filter to implicit/explicit table (metabase#20809)", () => {
- cy.findByTextEnsureVisible("Custom column").click();
-
- H.enterCustomColumnDetails({
- formula: "1 + 1",
- name: "Two",
- });
-
- cy.button("Done").click();
-
- H.visualize((response) => {
- expect(response.body.error).to.not.exist;
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("37.65");
- });
-});
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js b/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js
index f1d71e35ea4..6043958eb56 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js
+++ b/e2e/test/scenarios/question-reproductions/reproductions-2.cy.spec.js
@@ -1,7 +1,6 @@
const { H } = cy;
import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE } = SAMPLE_DATABASE;
@@ -51,108 +50,6 @@ describe("issue 23023", () => {
cy.findAllByTestId("header-cell").contains("Tax").should("not.exist");
});
});
-
-describe("issue 24839: should be able to summarize a nested question based on the source question with aggregations (metabase#24839)", () => {
- const questionDetails = {
- name: "24839",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- ["sum", ["field", ORDERS.QUANTITY, null]],
- ["avg", ["field", ORDERS.TOTAL, null]],
- ],
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
- },
- display: "line",
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(questionDetails).then(({ body: { id } }) => {
- // Start ad-hoc nested question based on the saved one
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: { "source-table": `card__${id}` },
- type: "query",
- },
- });
- });
- });
-
- it("from the notebook GUI (metabase#24839-1)", () => {
- H.openNotebook();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Summarize").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Sum of ...").click();
- H.popover()
- .should("contain", "Sum of Quantity")
- .and("contain", "Average of Total");
- });
-
- it("from a table header cell (metabase#24839-2)", () => {
- H.tableHeaderClick("Average of Total");
-
- H.popover().contains("Distinct values").click();
-
- cy.findByTestId("scalar-value").invoke("text").should("eq", "49");
-
- cy.findByTestId("aggregation-item")
- .invoke("text")
- .should("eq", "Distinct values of Average of Total");
- });
-});
-
-describe("issue 25016", () => {
- const questionDetails = {
- display: "table",
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: {
- "source-query": {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PRODUCTS.CREATED_AT, { "temporal-unit": "month" }],
- ["field", PRODUCTS.CATEGORY, null],
- ],
- },
- aggregation: [["count"]],
- breakout: [["field", "CATEGORY", { "base-type": "type/Text" }]],
- },
- },
- visualization_settings: {
- "table.pivot_column": "CATEGORY",
- "table.cell_column": "count",
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should be possible to filter by a column in a multi-stage query (metabase#25016)", () => {
- H.visitQuestionAdhoc(questionDetails);
- H.tableHeaderClick("Category");
-
- H.popover().within(() => {
- cy.findByText("Filter by this column").click();
- cy.findByText("Gadget").click();
- cy.button("Add filter").click();
- });
-
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 1 row").should("be.visible");
- });
-});
-
describe("issue 27104", () => {
const questionDetails = {
dataset_query: {
@@ -359,58 +256,6 @@ describe("issue 28874", () => {
cy.findByText("Product ID").should("not.exist");
});
});
-
-describe("issue 29082", () => {
- const questionDetails = {
- name: "22788",
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- filter: ["=", ["field", ORDERS.USER_ID, null], 1],
- },
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should handle nulls in quick filters (metabase#29082)", () => {
- H.visitQuestionAdhoc(questionDetails);
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 11 rows").should("exist");
-
- cy.get(".test-TableInteractive-emptyCell").first().click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- H.popover().within(() => cy.findByText("=").click());
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 8 rows").should("exist");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Discount is empty").should("exist");
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Discount is empty").icon("close").click();
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 11 rows").should("exist");
-
- cy.get(".test-TableInteractive-emptyCell").first().click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- H.popover().within(() => cy.findByText("≠").click());
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 3 rows").should("exist");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Discount is not empty").should("exist");
- });
-});
-
describe("issue 30165", () => {
beforeEach(() => {
H.restore();
@@ -448,31 +293,6 @@ describe("issue 30165", () => {
});
});
-describe("issue 30610", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should remove stale metadata when saving a new question (metabase#30610)", () => {
- H.openOrdersTable();
- H.openNotebook();
- removeSourceColumns();
- H.saveQuestionToCollection("New orders");
- createAdHocQuestion("New orders");
- visualizeAndAssertColumns();
- });
-
- it("should remove stale metadata when updating an existing question (metabase#30610)", () => {
- H.visitQuestion(ORDERS_QUESTION_ID);
- H.openNotebook();
- removeSourceColumns();
- updateQuestion();
- createAdHocQuestion("Orders");
- visualizeAndAssertColumns();
- });
-});
-
describe("issue 35290", () => {
beforeEach(() => {
H.restore();
@@ -578,40 +398,6 @@ describe("issue 43216", () => {
});
});
-function updateQuestion() {
- H.queryBuilderHeader().findByText("Save").click();
- cy.findByTestId("save-question-modal").within((modal) => {
- cy.findByText("Save").click();
- });
-}
-
-function removeSourceColumns() {
- cy.findByTestId("fields-picker").click();
- H.popover().findByText("Select all").click();
-}
-
-function createAdHocQuestion(questionName) {
- H.startNewQuestion();
- H.miniPickerBrowseAll().click();
- H.entityPickerModal().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(questionName).click();
- });
- cy.findByTestId("fields-picker").click();
- H.popover().within(() => {
- cy.findByText("ID").should("be.visible");
- cy.findByText("Total").should("not.exist");
- });
-}
-
-function visualizeAndAssertColumns() {
- H.visualize();
- H.tableInteractive().within(() => {
- cy.findByText("ID").should("exist");
- cy.findByText("Total").should("not.exist");
- });
-}
-
const EXPRESSION_NAME = "TEST_EXPRESSION";
describe("Custom columns visualization settings", () => {
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js b/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
index 16fcf9df122..7b75446d4bb 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
+++ b/e2e/test/scenarios/question-reproductions/reproductions-3.cy.spec.js
@@ -5,60 +5,6 @@ import { NO_COLLECTION_PERSONAL_COLLECTION_ID } from "e2e/support/cypress_sample
const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, PEOPLE, PEOPLE_ID } =
SAMPLE_DATABASE;
-
-describe("issue 32625, issue 31635", () => {
- const CC_NAME = "Is Promotion";
-
- const QUESTION = {
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- "distinct",
- ["field", ORDERS.PRODUCT_ID, { "base-type": "type/Integer" }],
- ],
- breakout: ["expression", CC_NAME],
- expressions: {
- [CC_NAME]: [
- "case",
- [[[">", ["field", ORDERS.DISCOUNT, null], 0], 1]],
- { default: 0 },
- ],
- },
- },
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should remove dependent clauses when a clause is removed (metabase#32625, metabase#31635)", () => {
- H.visitQuestionAdhoc(QUESTION, { mode: "notebook" });
-
- H.getNotebookStep("expression")
- .findAllByTestId("notebook-cell-item")
- .first()
- .icon("close")
- .click();
-
- H.getNotebookStep("expression").should("not.exist");
- H.getNotebookStep("summarize").findByText(CC_NAME).should("not.exist");
-
- H.visualize();
-
- cy.findByTestId("query-builder-main").within(() => {
- cy.findByTestId("scalar-value").should("have.text", "200");
- cy.findByText("There was a problem with your question").should(
- "not.exist",
- );
- });
- });
-});
-
describe("issue 32964", () => {
const LONG_NAME = "A very long column name that will cause text overflow";
@@ -786,93 +732,6 @@ describe("issue 10493", { tags: "@skip" }, () => {
});
});
});
-
-describe("issue 32020", () => {
- const question1Details = {
- name: "Q1",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- ["sum", ["field", ORDERS.TOTAL, { "base-type": "type/Float" }]],
- ],
- breakout: [
- ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],
- [
- "field",
- ORDERS.CREATED_AT,
- { "base-type": "type/DateTime", "temporal-unit": "month" },
- ],
- ],
- },
- };
-
- const question2Details = {
- name: "Q2",
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [
- ["max", ["field", PEOPLE.LONGITUDE, { "base-type": "type/Float" }]],
- ],
- breakout: [
- ["field", PEOPLE.ID, { "base-type": "type/BigInteger" }],
- [
- "field",
- PEOPLE.CREATED_AT,
- { "base-type": "type/DateTime", "temporal-unit": "month" },
- ],
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- H.createQuestion(question1Details);
- H.createQuestion(question2Details);
- });
-
- it("should be possible to use aggregation columns from source and joined questions in aggregation (metabase#32020)", () => {
- H.startNewQuestion();
-
- cy.log("create joined question manually");
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(question1Details.name).click();
- });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(question2Details.name).click();
- });
- H.popover().findByText("ID").click();
- H.popover().findByText("ID").click();
-
- cy.log("aggregation column from the source question");
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
- H.popover().within(() => {
- cy.findByText("Sum of ...").click();
- cy.findByText("Sum of Total").click();
- });
-
- cy.log("aggregation column from the joined question");
- H.getNotebookStep("summarize").icon("add").click();
- H.popover().within(() => {
- cy.findByText("Sum of ...").click();
- cy.findByText(question2Details.name).click();
- cy.findByText("Q2 → Max of Longitude").click();
- });
-
- cy.log("visualize and check results");
- H.visualize();
- H.tableInteractive().within(() => {
- cy.findByText("Sum of Sum of Total").should("be.visible");
- cy.findByText("Sum of Q2 → Max of Longitude").should("be.visible");
- });
- });
-});
-
describe("issue 44071", () => {
const questionDetails = {
name: "Test",
diff --git a/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js b/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js
index 36028040f3b..8f7b1c7fb5b 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js
+++ b/e2e/test/scenarios/question-reproductions/reproductions-4.cy.spec.js
@@ -1,10 +1,5 @@
const { H } = cy;
-import {
- SAMPLE_DB_ID,
- SAMPLE_DB_SCHEMA_ID,
- USER_GROUPS,
- WRITABLE_DB_ID,
-} from "e2e/support/cypress_data";
+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 } =
@@ -1167,67 +1162,6 @@ describe("issue 32499", () => {
}
});
});
-
-describe("issue 23449", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- const checkTable = () => {
- H.assertTableData({
- columns: ["ID", "Product ID", "Reviewer", "Rating", "Created At"],
- firstRows: [[1, 1, "christ", "E", "May 15, 2027, 8:25 PM"]],
- });
- };
-
- it("Remapped fields should work in a model (metabase#23449)", () => {
- cy.log("set the metadata for review");
- H.DataModel.visit({
- databaseId: SAMPLE_DB_ID,
- schemaId: SAMPLE_DB_SCHEMA_ID,
- tableId: SAMPLE_DATABASE.REVIEWS_ID,
- fieldId: SAMPLE_DATABASE.REVIEWS.RATING,
- });
-
- H.DataModel.FieldSection.getDisplayValuesInput().click();
- H.popover().findByText("Custom mapping").click();
-
- cy.findByDisplayValue("1").clear().type("A");
- cy.findByDisplayValue("2").clear().type("B");
- cy.findByDisplayValue("3").clear().type("C");
- cy.findByDisplayValue("4").clear().type("D");
- cy.findByDisplayValue("5").clear().type("E");
-
- cy.button("Save").click();
-
- cy.log("make a model on Reviews");
- H.goToMainApp();
- H.navigationSidebar().findByLabelText("Browse models").click();
- cy.findByLabelText("Create a new model").click();
- cy.findByRole("link", { name: /Use the notebook editor/ }).click();
- H.miniPicker().findByText("Sample Database").click();
- H.miniPicker().findByText("Reviews").click();
-
- cy.log("Remove Body column");
- cy.findByLabelText("Pick columns").click();
- H.popover().findByText("Body").click();
-
- cy.log("save model");
- cy.findByTestId("dataset-edit-bar").button("Save").click();
-
- cy.log("confirm save in a modal");
- H.modal().button("Save").click();
-
- cy.log("check that the data renders");
- checkTable();
-
- cy.log("reload to flush cached results and check again");
- cy.findByTestId("qb-header").button("Refresh").click();
- checkTable();
- });
-});
-
describe("issue 12679", () => {
beforeEach(() => {
H.restore();
@@ -1285,499 +1219,3 @@ describe("issue 12679", () => {
.should("exist");
});
});
-
-describe("issue 51856", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- const q1Details = {
- name: "Issue 51856 Q1",
- type: "question",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- strategy: "left-join",
- alias: "Products",
- condition: [
- "=",
- [
- "field",
- ORDERS.PRODUCT_ID,
- {
- "base-type": "type/Integer",
- },
- ],
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products",
- },
- ],
- ],
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- };
-
- const q2Details = {
- name: "Issue 51856 Q2",
- query: {
- "source-table": SAMPLE_DATABASE.REVIEWS_ID,
- joins: [
- {
- fields: "all",
- strategy: "left-join",
- alias: "Products",
- condition: [
- "=",
- [
- "field",
- SAMPLE_DATABASE.REVIEWS.PRODUCT_ID,
- {
- "base-type": "type/Integer",
- },
- ],
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products",
- },
- ],
- ],
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- };
-
- it("join alias deduplication should not break queries with multiple nesting levels with joins (metabase#51856)", () => {
- H.createQuestion(q1Details, { wrapId: true, idAlias: "q1id" });
- cy.get("@q1id").then((_q1id) => {
- H.createQuestion(q2Details, { wrapId: true, idAlias: "q2id" });
- cy.get("@q2id").then((_q2id) => {
- H.startNewQuestion();
-
- H.selectSavedQuestionsToJoin(q1Details.name, q2Details.name);
- cy.findByTestId("join-condition-0").findByText(q1Details.name).click();
- H.popover().findByText("Products → Category").click();
- cy.findByTestId("join-condition-0").findByText(q2Details.name).click();
- H.popover().findByText("Issue 51856 Q2 → Category").click();
-
- H.visualize();
-
- H.tableInteractiveScrollContainer().scrollTo("right");
- cy.findByTestId("table-header").within(() => {
- cy.findByText("Products → Category").should("exist");
- cy.findByText(
- "Issue 51856 Q2 - Products → Category → Category",
- ).should("exist");
- });
- cy.findByTestId("question-row-count")
- .findByText("Showing first 2,000 rows")
- .should("exist");
- });
- });
- });
-});
-
-describe("issue 33972", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- const queryDetails = {
- name: "Issue 33972",
- type: "question",
- query: {
- "source-table": ORDERS_ID,
- fields: [
- ["field", ORDERS.ID, { "base-type": "type/BigInteger" }],
- ["field", ORDERS.PRODUCT_ID, { "base-type": "type/Integer" }],
- ],
- joins: [
- {
- fields: [
- [
- "field",
- PRODUCTS.CATEGORY,
- { "base-type": "type/Text", "join-alias": "Products" },
- ],
- ],
- strategy: "left-join",
- alias: "Products",
- condition: [
- "=",
- [
- "field",
- ORDERS.PRODUCT_ID,
- {
- "base-type": "type/Integer",
- },
- ],
- [
- "field",
- PRODUCTS.ID,
- {
- "base-type": "type/BigInteger",
- "join-alias": "Products",
- },
- ],
- ],
- "source-table": PRODUCTS_ID,
- },
- ],
- },
- };
-
- it("should be able to distinguish explicitly and implicitly joined fields (metabase#33972)", () => {
- H.createQuestion(queryDetails, { wrapId: true });
- cy.get("@questionId").then((questionId) => {
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": "card__" + questionId,
- },
- type: "query",
- },
- });
- cy.findByTestId("viz-settings-button").click();
- cy.findByTestId("chartsettings-list-container")
- .findByText("Add or remove columns")
- .click();
- cy.findByTestId("product-table-columns").findByText("Category").click();
- cy.findByTestId("product-table-columns").findByText("Ean").click();
- cy.findByTestId("table-header").within(() => {
- cy.findByText("ID").should("exist");
- cy.findByText("Product ID").should("exist");
- cy.findByText("Products → Category").should("exist");
- cy.findByText("Product → Category").should("exist");
- cy.findByText("Product → Ean").should("exist");
- });
- cy.findByTestId("question-row-count")
- .findByText("Showing first 2,000 rows")
- .should("exist");
- });
- });
-});
-
-describe("Issue 33835", { tags: "@external" }, () => {
- beforeEach(() => {
- H.restore("postgres-writable");
- cy.signInAsAdmin();
-
- H.queryWritableDB("DROP TABLE IF EXISTS orders");
- H.queryWritableDB(
- "CREATE TABLE IF NOT EXISTS orders (id INT PRIMARY KEY, total real, discount real)",
- );
- H.queryWritableDB(
- "INSERT INTO orders (id, total, discount) VALUES (1, 100, 20)",
- );
-
- H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: "orders" });
-
- H.startNewQuestion();
- H.miniPicker().findByText("Writable Postgres12").click();
- H.miniPicker().findByText("Orders").click();
-
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
- H.popover().within(() => {
- cy.findByText(/Average of/).click();
- cy.findByText("Total").click();
- });
-
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByText("Discount").click();
-
- H.saveQuestion("Test Question", {
- wrapId: true,
- questionId: "questionId",
- addToDashboard: false,
- });
- });
-
- it("should be possible to remove an aggregation on a non-existent column (metabase#33835)", () => {
- H.queryWritableDB("ALTER TABLE orders DROP COLUMN total");
- H.resyncDatabase({ dbId: WRITABLE_DB_ID });
-
- H.visitQuestion("@questionId");
- H.openNotebook();
-
- H.getNotebookStep("summarize")
- .findByText("Average of Unknown Field")
- .should("be.visible")
- .icon("close")
- .click();
-
- H.visualize();
- cy.get("main")
- .findByText("There was a problem with your question")
- .should("not.exist");
- });
-
- it("should be possible to remove a breakout on a non-existent column (metabase#33835)", () => {
- H.queryWritableDB("ALTER TABLE orders DROP COLUMN discount");
- H.resyncDatabase({ dbId: WRITABLE_DB_ID });
-
- H.visitQuestion("@questionId");
- H.openNotebook();
-
- H.getNotebookStep("summarize")
- .findByText("Unknown Field: Auto binned")
- .should("be.visible")
- .icon("close")
- .click();
-
- H.visualize();
- cy.get("main")
- .findByText("There was a problem with your question")
- .should("not.exist");
- });
-});
-
-describe("Issue 42942", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.visitQuestionAdhoc({
- display: "bar",
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- ORDERS.TOTAL,
- {
- "base-type": "type/Float",
- binning: { strategy: "num-bins", "num-bins": 100 },
- },
- ],
- ],
- },
- },
- });
- });
-
- it("should adapt the filter widths when changing the filter value (metabase#42942)", () => {
- H.openNotebook();
-
- H.getNotebookStep("data").findByLabelText("Filter").click();
-
- H.popover().within(() => {
- cy.findByText("Total").click();
- cy.findByPlaceholderText("Min").type("90");
- cy.button("Add filter").click();
- });
- H.visualize();
-
- H.chartPathWithFillColor("#509EE3").first().click();
- H.popover().findByText("See these Orders").click();
-
- cy.log(
- "Filters should be applied correctly with the bin width from the chart",
- );
- H.queryBuilderFiltersPanel().findByText(
- "Total is greater than or equal to 90",
- );
- H.queryBuilderFiltersPanel().findByText("Total is less than 90.75");
- });
-});
-
-describe("Issue 48771", () => {
- const MODEL_NAME = "M1";
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createNativeQuestion({
- name: MODEL_NAME,
- type: "model",
- native: {
- database: SAMPLE_DB_ID,
- query: "SELECT 1 AS ID",
- },
- }).then(({ body: model }) => {
- H.createQuestion(
- {
- type: "question",
- query: {
- filter: [
- ">=",
- [
- "field",
- "count",
- {
- "base-type": "type/Integer",
- },
- ],
- 0.5,
- ],
- "source-query": {
- database: SAMPLE_DB_ID,
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": `card__${model.id}`,
- fields: "all",
- alias: MODEL_NAME,
- strategy: "left-join",
- condition: [
- "=",
- ["field", ORDERS.ID, { "base-type": "type/Integer" }],
- [
- "field",
- "ID",
- { "join-alias": MODEL_NAME, "base-type": "type/Integer" },
- ],
- ],
- },
- ],
- aggregation: [["count"]],
- breakout: [["field", ORDERS.CREATED_AT, null]],
- },
- },
- },
- { visitQuestion: true, wrapId: true },
- );
- });
-
- cy.log("give nosql user access to root collection");
- cy.updateCollectionGraph({
- [USER_GROUPS.NOSQL_GROUP]: { root: "write" },
- });
-
- cy.signOut();
- cy.signIn("nosql");
- });
-
- it("should allow to add a filter after summary stage (metabase#48771)", () => {
- H.visitQuestion("@questionId");
- H.openNotebook();
-
- H.getNotebookStep("filter", { stage: 1 })
- .findByText("Count is greater than or equal to 0.5")
- .click();
-
- H.popover().within(() => {
- cy.findByPlaceholderText("Enter a number").clear().type("0.7");
- cy.button("Update filter").click();
- });
- H.visualize();
- });
-});
-
-describe("Issue 42817", () => {
- const NATIVE_QUESTION_NAME = "NativeOrders";
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- H.createNativeQuestion({
- name: NATIVE_QUESTION_NAME,
- database: SAMPLE_DB_ID,
- native: {
- query: "SELECT ID, CREATED_AT FROM orders",
- },
- }).then(({ body: question }) => {
- H.visitQuestionAdhoc({
- display: "line",
- dataset_query: {
- type: "query",
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: "all",
- alias: NATIVE_QUESTION_NAME,
- "source-table": `card__${question.id}`,
- strategy: "left-join",
- condition: [
- "=",
- [
- "field",
- ORDERS.ID,
- {
- "base-type": "type/BigInteger",
- },
- ],
- [
- "field",
- "ID",
- {
- "base-type": "type/BigInteger",
- "join-alias": NATIVE_QUESTION_NAME,
- },
- ],
- ],
- },
- ],
- aggregation: [["count"]],
- breakout: [
- [
- "field",
- "CREATED_AT",
-
- {
- "base-type": "type/DateTime",
- "temporal-unit": "day",
- "join-alias": "NativeOrders",
- },
- ],
- ],
- filter: [
- "between",
- [
- "field",
- "CREATED_AT",
- {
- "base-type": "type/Date",
- "inherited-temporal-unit": "day",
- "temporal-unit": "day",
- "join-alias": "NativeOrders",
- },
- ],
- "2026-06-23T00:00Z",
- "2026-07-03T00:00Z",
- ],
- },
- },
- });
- });
- });
-
- it("should be possible to drill down into a question with datetime buckets and a native join (metabase#42817)", () => {
- H.echartsContainer()
- .get("path[fill='hsla(0, 0%, 100%, 1.00)']")
- .first()
- .click();
-
- H.popover().findByText("See this day by hour").click();
-
- cy.findByTestId("query-visualization-root")
- .findByText("There was a problem with your question")
- .should("not.exist");
-
- H.echartsContainer().should("be.visible");
- });
-});
diff --git a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
index 0200970ce86..bb0fb27284d 100644
--- a/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
+++ b/e2e/test/scenarios/question-reproductions/reproductions.cy.spec.ts
@@ -10,53 +10,7 @@ import type {
import type { Filter, LocalFieldReference } from "metabase-types/api";
import { createMockParameter } from "metabase-types/api/mocks";
-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID, REVIEWS, REVIEWS_ID } =
- SAMPLE_DATABASE;
-
-describe("issue 48754", () => {
- const questionDetails: StructuredQuestionDetails = {
- name: "Q1",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PRODUCTS.CATEGORY, { "source-field": ORDERS.PRODUCT_ID }],
- ],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should (metabase#48754)", () => {
- H.createQuestion(questionDetails);
- H.openReviewsTable({ mode: "notebook" });
- H.getNotebookStep("data").button("Summarize").click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().within(() => {
- cy.findByText("Product").click();
- cy.findByText("Category").click();
- });
- H.getNotebookStep("summarize").button("Join data").click();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("Q1").click();
- });
- H.popover()
- .findByText(/Category/)
- .click();
- H.popover()
- .findByText(/Category/)
- .click();
- H.visualize();
- H.assertQueryBuilderRowCount(4);
- });
-});
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
describe("issue 39487", () => {
const CREATED_AT_FIELD: LocalFieldReference = [
@@ -351,74 +305,6 @@ describe("issue 14124", () => {
cy.findAllByRole("gridcell", { name: "3:00 AM" }).should("be.visible");
});
});
-
-describe("issue 15563", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should not display multiple 'Created At' fields when they are remapped to PK/FK (metabase#15563)", () => {
- // Remap fields
- cy.request("PUT", `/api/field/${ORDERS.CREATED_AT}`, {
- semantic_type: "type/PK",
- });
- cy.request("PUT", `/api/field/${REVIEWS.CREATED_AT}`, {
- semantic_type: "type/FK",
- fk_target_field_id: ORDERS.CREATED_AT,
- });
-
- H.openReviewsTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- cy.get("[data-element-id=list-section-header]")
- .contains("Created At")
- .click();
- cy.get("[data-element-id=list-section] [data-element-id=list-item-title]")
- .contains("Created At")
- .should("have.length", 1);
- });
-});
-
-describe("issue 36122", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should display breakouts group for all FKs (metabase#36122)", () => {
- cy.request("PUT", `/api/field/${REVIEWS.RATING}`, {
- semantic_type: "type/FK",
- fk_target_field_id: PRODUCTS.ID,
- });
-
- H.openReviewsTable({ mode: "notebook" });
- H.summarize({ mode: "notebook" });
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
-
- H.popover().within(() => {
- cy.findAllByTestId("dimension-list-item")
- .eq(3)
- .should("have.text", "Rating");
- cy.get("[data-element-id=list-section-header]").should("have.length", 3);
- cy.get("[data-element-id=list-section-header]")
- .eq(0)
- .should("have.text", "Reviews");
- cy.get("[data-element-id=list-section-header]")
- .eq(1)
- .should("have.text", "Product");
- cy.get("[data-element-id=list-section-header]")
- .eq(2)
- .should("have.text", "Rating");
- });
- });
-});
-
const MONGO_DB_ID = 2;
describe("issue 47793", () => {
@@ -480,58 +366,6 @@ describe("issue 47793", () => {
},
);
});
-
-describe("issue 48752", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should reference the correct aggregation after one of the aggregations with the same operator is removed (metabase#48752)", () => {
- H.openOrdersTable({ mode: "notebook" });
-
- cy.log("first stage - aggregations and a breakout");
- H.summarize({ mode: "notebook" });
- H.popover().within(() => {
- cy.findByText(/Sum of/).click();
- cy.findByText("Total").click();
- });
- H.getNotebookStep("summarize").icon("add").click();
- H.popover().within(() => {
- cy.findByText(/Sum of/).click();
- cy.findByText("Subtotal").click();
- });
- H.getNotebookStep("summarize").icon("add").click();
- H.popover().within(() => {
- cy.findByText(/Sum of/).click();
- cy.findByText("Tax").click();
- });
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findByText("User ID").click();
-
- cy.log("second stage - a filter");
- H.getNotebookStep("summarize").button("Filter").click();
- H.popover().within(() => {
- cy.findByText("Sum of Subtotal").click();
- cy.findByPlaceholderText("Min").type("10");
- cy.findByText("Add filter").click();
- });
-
- cy.log('remove the first "sum" aggregation from the first stage');
- H.getNotebookStep("summarize")
- .findByText("Sum of Total")
- .icon("close")
- .click();
-
- cy.log("assert that the filter references the correct column");
- H.getNotebookStep("filter", { stage: 1 })
- .findByText("Sum of Subtotal is greater than or equal to 10")
- .should("be.visible");
- });
-});
-
describe("issue 49270", () => {
beforeEach(() => {
H.restore();
@@ -662,41 +496,6 @@ describe("issue 46845", () => {
cy.signInAsNormalUser();
});
- it("should be able to run a query with an implicit join via a join (metabase#46845)", () => {
- H.openOrdersTable({ mode: "notebook" });
-
- cy.log("add a self-join");
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- H.popover().findByText("Product ID").click();
- H.popover().findByText("User ID").click();
-
- cy.log("add a filter for an implicit column from the source table");
- H.filter({ mode: "notebook" });
- H.popover().within(() => {
- cy.findAllByText("Product").should("have.length", 2).first().click();
- cy.findByText("Vendor").click();
- cy.findByText("Alfreda Konopelski II Group").click();
- cy.button("Add filter").click();
- });
-
- cy.log("add a filter for the column but from the joined table");
- H.getNotebookStep("filter").icon("add").click();
- H.popover().within(() => {
- cy.findAllByText("Product").should("have.length", 2).last().click();
- cy.findByText("Vendor").click();
- cy.findByText("Aufderhar-Boehm").click();
- cy.button("Add filter").click();
- });
-
- cy.log("assert query results");
- H.visualize();
- H.assertQueryBuilderRowCount(91);
- });
-
it("should be able to run a query with multiple implicit joins for a native model (metabase#46845)", () => {
cy.log("create a native model with 2 FKs to the same table");
H.createNativeQuestion(
@@ -746,64 +545,6 @@ describe("issue 46845", () => {
H.assertQueryBuilderRowCount(1);
});
});
-
-describe("issue 44567", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should allow to name the aggregation expression the same as the column it is aggregating (metabase#44567)", () => {
- H.openOrdersTable({ mode: "notebook" });
- H.getNotebookStep("data").button("Summarize").click();
- H.popover().findByText("Custom Expression").click();
- H.enterCustomColumnDetails({ formula: "Sum([Total])", name: "Total" });
- H.popover().button("Done").click();
- H.getNotebookStep("summarize").findByText("Total").click();
- H.enterCustomColumnDetails({ formula: "Sum([Total]) + 1" });
- H.popover().button("Update").should("be.enabled");
- });
-});
-
-describe("issue 58829", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be able to use join native models when SQL column names do not match the names of the mapped fields (metabase#58829)", () => {
- cy.log("create a native model mapped columns");
- H.createNativeQuestion(
- {
- name: "M1",
- type: "model",
- native: {
- query: "SELECT 1 AS ID, 2 AS _USER_ID",
- },
- },
- { visitQuestion: true },
- );
- H.openQuestionActions("Edit metadata");
- H.openColumnOptions("ID");
- H.mapColumnTo({ table: "Orders", column: "ID" });
- H.openColumnOptions("_USER_ID");
- H.mapColumnTo({ table: "Orders", column: "User ID" });
- H.saveMetadataChanges();
-
- cy.log("verify it can be joined");
- H.openProductsTable({ mode: "notebook" });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("M1").click();
- });
- H.popover().findByText("ID").click();
- H.popover().findByText("ID").click();
- H.visualize();
- H.assertQueryBuilderRowCount(200);
- });
-});
-
describe("54205", () => {
beforeEach(() => {
H.restore("postgres-writable");
@@ -864,93 +605,6 @@ describe("54205", () => {
});
});
});
-
-describe("issue 54920", () => {
- const initialQuestionDetails: StructuredQuestionDetails = {
- name: "Base question",
- query: {
- "source-table": ORDERS_ID,
- fields: [["field", ORDERS.CREATED_AT, null]],
- joins: [
- {
- "source-table": PRODUCTS_ID,
- alias: "Products",
- fields: [
- ["field", PRODUCTS.CREATED_AT, { "join-alias": "Products" }],
- ],
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- },
- {
- "source-table": REVIEWS_ID,
- alias: "Reviews",
- fields: [["field", REVIEWS.CREATED_AT, { "join-alias": "Reviews" }]],
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", REVIEWS.PRODUCT_ID, { "join-alias": "Reviews" }],
- ],
- },
- ],
- },
- };
-
- const expectedRowCount = 407;
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("PUT", "/api/card/*").as("updateCard");
- });
-
- it("should not break downstream queries when an unused field with the same name as a used field is removed from a base question (metabase#54920)", () => {
- cy.log("create a base question");
- H.createQuestion(initialQuestionDetails, {
- wrapId: true,
- idAlias: "baseQuestionId",
- });
-
- cy.log("create a derived question and verify that it can be run");
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText("Base question").click();
- });
- H.getNotebookStep("filter")
- .findByText("Add filters to narrow your answer")
- .click();
- H.popover().within(() => {
- cy.findByText("Reviews → Created At").click();
- cy.findByText("Fixed date range…").click();
- cy.findByLabelText("Start date").clear().type("10/12/2027");
- cy.findByLabelText("End date").clear().type("10/15/2027");
- cy.button("Add filter").click();
- });
- H.visualize();
- H.assertQueryBuilderRowCount(expectedRowCount);
- H.saveQuestion("Derived question", {
- wrapId: true,
- idAlias: "derivedQuestionId",
- });
-
- cy.log("remove a column from the base question");
- H.visitQuestion("@baseQuestionId");
- H.openNotebook();
- H.getNotebookStep("join", { index: 0 }).button("Pick columns").click();
- H.popover().findByText("Created At").click();
- H.queryBuilderHeader().findByText("Save").click();
- H.modal().findByText("Save").click();
- cy.wait("@updateCard");
-
- cy.log("verify that the derived question still works");
- H.visitQuestion("@derivedQuestionId");
- H.assertQueryBuilderRowCount(expectedRowCount);
- });
-});
-
describe("issue 55631", () => {
beforeEach(() => {
H.restore();
@@ -985,152 +639,6 @@ describe("issue 55631", () => {
});
});
});
-
-describe("issue 39033", () => {
- const question1Name = "Q1";
- const question1Details: NativeQuestionDetails = {
- name: question1Name,
- native: {
- query: "select id, product_id, total from orders",
- "template-tags": {},
- },
- };
-
- const question2Name = "Q2";
- const question2Details: NativeQuestionDetails = {
- name: question2Name,
- native: {
- query: "select * from products",
- "template-tags": {},
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- function getJoinedColumn() {
- return cy
- .findByTestId(`${question2Name.toLowerCase()}-table-columns`)
- .findByLabelText(`${question2Name} - PRODUCT_ID → ID`);
- }
-
- it("should correctly mark columns as selected when joining a native query (metabase#39033)", () => {
- cy.log("create a question");
- H.createNativeQuestion(question1Details);
- H.createNativeQuestion(question2Details);
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(question1Name).click();
- });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(question2Name).click();
- });
- H.popover().findByText("PRODUCT_ID").click();
- H.popover().findByText("ID").click();
-
- cy.log("run the query");
- H.visualize();
- cy.wait("@dataset");
-
- cy.log("assert that columns are marked as selected correctly");
- H.openVizSettingsSidebar();
- cy.findByTestId("chartsettings-sidebar").within(() => {
- cy.button("Add or remove columns").click();
-
- getJoinedColumn().should("be.checked").click();
- getJoinedColumn().should("not.be.checked");
- cy.wait("@dataset");
-
- getJoinedColumn().should("not.be.checked").click();
- getJoinedColumn().should("be.checked");
- cy.wait("@dataset");
- });
- });
-});
-
-describe("issue 56416", () => {
- // name should be longer than the default 60-character limit; this has 71
- const joinedQuestionName =
- "Orders + Products, Count, Grouped by Products → Category and Product ID";
-
- beforeEach(() => {
- H.restore();
- cy.signInAsNormalUser();
- });
-
- it("should be able to use a column from a joined question with a long name (metabase#56416)", () => {
- cy.log("create the joined question");
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Products").click();
- });
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().within(() => {
- cy.findByText("Products").click();
- cy.findByText("Category").click();
- });
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .icon("add")
- .click();
- H.popover().findByText("Product ID").click();
- H.saveQuestion(joinedQuestionName);
-
- cy.log("create the main question");
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- H.join();
- H.miniPicker().within(() => {
- cy.findByText("Our analytics").click();
- cy.findByText(joinedQuestionName).click();
- });
- H.popover().findByText("Product ID").click();
- H.popover().findByText("Product ID").click();
- H.getNotebookStep("summarize")
- .findByText("Pick a function or metric")
- .click();
- H.popover().findByText("Count of rows").click();
- H.getNotebookStep("summarize")
- .findByText("Pick a column to group by")
- .click();
- H.popover().within(() => {
- cy.findByText(joinedQuestionName).click();
- cy.findByText(/→ Category$/).click();
- });
- H.getNotebookStep("summarize").icon("filter").click();
- H.popover().within(() => {
- cy.findByText(/→ Category$/).click();
- cy.findByText("Gadget").click();
- cy.button("Add filter").click();
- });
-
- cy.log("assert that the query can be run");
- H.visualize();
- H.assertQueryBuilderRowCount(1);
- });
-});
-
describe("issue 42723", () => {
const questionDetails: StructuredQuestionDetails = {
display: "line",
@@ -1208,86 +716,6 @@ describe("issue 52872", () => {
});
});
});
-
-describe("issue 35561", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should display a functional fk drill for both null and non-null values", () => {
- H.createNativeQuestion(
- {
- name: "Model",
- native: {
- query: `SELECT 1 AS ID, CAST(NULL AS INT) AS USER_ID
-UNION ALL
-SELECT 2 AS ID, 3 AS USER_ID
-`,
- },
- type: "model",
- },
- {},
- ).then(async ({ body: model }) => {
- await cy.request("POST", `/api/card/${model.id}/query`);
- await H.setModelMetadata(model.id, (field) => {
- if (field.name === "USER_ID") {
- return {
- ...field,
- display_name: "User ID",
- semantic_type: "type/FK",
- fk_target_field_id: ORDERS.ID,
- };
- }
- return field;
- });
- H.createQuestion(
- {
- name: "Question",
- query: {
- "source-table": `card__${model.id}`,
- },
- display: "table",
- },
- { wrapId: true, visitQuestion: true },
- );
- });
- const findDataRows = () => {
- return H.tableInteractiveBody()
- .findByTestId("center-center-quadrant")
- .findAllByRole("row");
- };
- const findUserIdCell = (rowIndex: number) => {
- return findDataRows()
- .should("have.length.gt", 0)
- .eq(rowIndex)
- .find("[data-column-id='USER_ID']")
- .first();
- };
-
- findUserIdCell(0).click();
-
- H.popover().within(() => {
- cy.findByText("View Models with no User").should("be.visible").click();
- });
-
- findDataRows().should("have.length", 1);
-
- findUserIdCell(0).find("[data-testid=cell-data]").should("not.exist");
-
- H.visitQuestion("@questionId");
-
- findUserIdCell(1).click();
-
- H.popover().within(() => {
- cy.findByText("View this User's Models").should("be.visible").click();
- });
-
- findDataRows().should("have.length", 1);
- findUserIdCell(0).should("have.text", "3");
- });
-});
-
describe("issue 64293", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts b/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
index e270e32d832..1a2c9c5d819 100644
--- a/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
+++ b/e2e/test/scenarios/question/multiple-column-breakouts.cy.spec.ts
@@ -1194,179 +1194,6 @@ describe("scenarios > question > multiple column breakouts", () => {
});
});
});
-
- describe("filter picker", () => {
- it("should be able to add post-aggregation filters for each breakout in the filter picker", () => {
- function addDateBetweenFilter({
- columnName,
- columnMinValue,
- columnMaxValue,
- }: {
- columnName: string;
- columnMinValue: string;
- columnMaxValue: string;
- }) {
- H.filter();
- H.popover().within(() => {
- cy.findByText("Summaries").click();
- cy.findByText(columnName).click();
- cy.findByText("Fixed date range…").click();
- cy.findByText("Between").click();
- cy.findByLabelText("Start date").clear().type(columnMinValue);
- cy.findByLabelText("End date").clear().type(columnMaxValue);
- cy.button("Apply filter").click();
- });
- }
-
- function testDatePostAggregationFilter({
- questionDetails,
- column1Name,
- column1MinValue,
- column1MaxValue,
- column2Name,
- column2MinValue,
- column2MaxValue,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column1MinValue: string;
- column1MaxValue: string;
- column2Name: string;
- column2MinValue: string;
- column2MaxValue: string;
- }) {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- cy.log("add a filter for the first column");
- addDateBetweenFilter({
- columnName: column1Name,
- columnMinValue: column1MinValue,
- columnMaxValue: column1MaxValue,
- });
-
- cy.log("add a filter for the second column");
- addDateBetweenFilter({
- columnName: column2Name,
- columnMinValue: column2MinValue,
- columnMaxValue: column2MaxValue,
- });
-
- cy.log("assert query results");
- cy.wait("@dataset");
- }
-
- function addNumericBetweenFilter({
- columnName,
- columnMinValue,
- columnMaxValue,
- }: {
- columnName: string;
- columnMinValue: number;
- columnMaxValue: number;
- }) {
- H.filter();
- H.popover().within(() => {
- cy.findByText("Summaries").click();
- cy.findByText(columnName).click();
- cy.findByPlaceholderText("Min")
- .clear()
- .type(String(columnMinValue));
- cy.findByPlaceholderText("Max")
- .clear()
- .type(String(columnMaxValue));
- cy.button("Apply filter").click();
- });
- }
-
- function testNumericPostAggregationFilter({
- questionDetails,
- column1Name,
- column1MinValue,
- column1MaxValue,
- column2Name,
- column2MinValue,
- column2MaxValue,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column1MinValue: number;
- column1MaxValue: number;
- column2Name: string;
- column2MinValue: number;
- column2MaxValue: number;
- }) {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- cy.log("add a filter for the first column");
- addNumericBetweenFilter({
- columnName: column1Name,
- columnMinValue: column1MinValue,
- columnMaxValue: column1MaxValue,
- });
-
- cy.log("add a filter for the second column");
- addNumericBetweenFilter({
- columnName: column2Name,
- columnMinValue: column2MinValue,
- columnMaxValue: column2MaxValue,
- });
-
- cy.log("assert query results");
- cy.wait("@dataset");
- }
-
- cy.log("temporal buckets");
- testDatePostAggregationFilter({
- questionDetails: questionWith2TemporalBreakoutsDetails,
- column1Name: "Created At: Year",
- column1MinValue: "January 1, 2029",
- column1MaxValue: "December 31, 2029",
- column2Name: "Created At: Month",
- column2MinValue: "March 1, 2029",
- column2MaxValue: "May 31, 2029",
- });
- assertTableDataForFilteredTemporalBreakouts();
-
- cy.log("'num-bins' breakouts");
- testNumericPostAggregationFilter({
- questionDetails: questionWith2NumBinsBreakoutsDetails,
- column1Name: "Total: 10 bins",
- column1MinValue: 10,
- column1MaxValue: 50,
- column2Name: "Total: 50 bins",
- column2MinValue: 10,
- column2MaxValue: 50,
- });
- H.assertTableData({
- columns: ["Total: 10 bins", "Total: 50 bins", "Count"],
- firstRows: [
- ["20 – 40", "20 – 25", "214"],
- ["20 – 40", "25 – 30", "396"],
- ],
- });
- H.assertQueryBuilderRowCount(7);
-
- cy.log("'bin-width' breakouts");
- testNumericPostAggregationFilter({
- questionDetails: questionWith2BinWidthBreakoutsDetails,
- column1Name: "Latitude: 20°",
- column1MinValue: 10,
- column1MaxValue: 50,
- column2Name: "Latitude: 10°",
- column2MinValue: 10,
- column2MaxValue: 50,
- });
- H.assertTableData({
- columns: ["Latitude: 20°", "Latitude: 10°", "Count"],
- firstRows: [
- ["20° N – 40° N", "20° N – 30° N", "87"],
- ["20° N – 40° N", "30° N – 40° N", "1,176"],
- ],
- });
- H.assertQueryBuilderRowCount(4);
- });
- });
-
describe("viz settings", () => {
it("should be able to toggle the fields that correspond to breakout columns in the previous stage", () => {
function toggleColumn(columnName: string, isVisible: boolean) {
@@ -1451,340 +1278,6 @@ describe("scenarios > question > multiple column breakouts", () => {
});
describe("data source", () => {
- describe("notebook", () => {
- it("should be able to add filters for each source column", () => {
- function addDateBetweenFilter({
- columnName,
- columnMinValue,
- columnMaxValue,
- }: {
- columnName: string;
- columnMinValue: string;
- columnMaxValue: string;
- }) {
- H.popover().within(() => {
- cy.findAllByText(columnName).click();
- cy.findByText("Fixed date range…").click();
- cy.findByText("Between").click();
- cy.findByLabelText("Start date").clear().type(columnMinValue);
- cy.findByLabelText("End date").clear().type(columnMaxValue);
- cy.button("Add filter").click();
- });
- }
-
- function testDatePostAggregationFilter({
- questionDetails,
- column1Name,
- column1MinValue,
- column1MaxValue,
- column2Name,
- column2MinValue,
- column2MaxValue,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column1MinValue: string;
- column1MaxValue: string;
- column2Name: string;
- column2MinValue: string;
- column2MaxValue: string;
- }) {
- H.createQuestion(questionDetails).then(({ body: card }) => {
- H.createQuestion(getNestedQuestionDetails(card.id), {
- visitQuestion: true,
- });
- });
- H.openNotebook();
-
- cy.log("add a filter for the first column");
- H.getNotebookStep("data").button("Filter").click();
- addDateBetweenFilter({
- columnName: column1Name,
- columnMinValue: column1MinValue,
- columnMaxValue: column1MaxValue,
- });
-
- cy.log("add a filter for the second column");
- H.getNotebookStep("filter").icon("add").click();
- addDateBetweenFilter({
- columnName: column2Name,
- columnMinValue: column2MinValue,
- columnMaxValue: column2MaxValue,
- });
-
- cy.log("assert query results");
- H.visualize();
- cy.wait("@dataset");
- }
-
- function addNumericBetweenFilter({
- columnName,
- columnMinValue,
- columnMaxValue,
- }: {
- columnName: string;
- columnMinValue: number;
- columnMaxValue: number;
- }) {
- H.popover().within(() => {
- cy.findAllByText(columnName).click();
- cy.findByPlaceholderText("Min")
- .clear()
- .type(String(columnMinValue));
- cy.findByPlaceholderText("Max")
- .clear()
- .type(String(columnMaxValue));
- cy.button("Add filter").click();
- });
- }
-
- function testNumericPostAggregationFilter({
- questionDetails,
- column1Name,
- column1MinValue,
- column1MaxValue,
- column2Name,
- column2MinValue,
- column2MaxValue,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column1MinValue: number;
- column1MaxValue: number;
- column2Name: string;
- column2MinValue: number;
- column2MaxValue: number;
- }) {
- H.createQuestion(questionDetails).then(({ body: card }) => {
- H.createQuestion(getNestedQuestionDetails(card.id), {
- visitQuestion: true,
- });
- });
- H.openNotebook();
-
- cy.log("add a filter for the first column");
- H.getNotebookStep("data").button("Filter").click();
- addNumericBetweenFilter({
- columnName: column1Name,
- columnMinValue: column1MinValue,
- columnMaxValue: column1MaxValue,
- });
-
- cy.log("add a filter for the second column");
- H.getNotebookStep("filter").icon("add").click();
- addNumericBetweenFilter({
- columnName: column2Name,
- columnMinValue: column2MinValue,
- columnMaxValue: column2MaxValue,
- });
-
- cy.log("assert query results");
- H.visualize();
- cy.wait("@dataset");
- }
-
- cy.log("temporal buckets");
- testDatePostAggregationFilter({
- questionDetails: questionWith2TemporalBreakoutsDetails,
- column1Name: "Created At: Year",
- column1MinValue: "January 1, 2029",
- column1MaxValue: "December 31, 2029",
- column2Name: "Created At: Month",
- column2MinValue: "March 1, 2029",
- column2MaxValue: "May 31, 2029",
- });
- assertTableDataForFilteredTemporalBreakouts();
-
- cy.log("'num-bins' breakouts");
- testNumericPostAggregationFilter({
- questionDetails: questionWith2NumBinsBreakoutsDetails,
- column1Name: "Total: 10 bins",
- column1MinValue: 10,
- column1MaxValue: 50,
- column2Name: "Total: 50 bins",
- column2MinValue: 10,
- column2MaxValue: 50,
- });
- H.assertTableData({
- columns: ["Total: 10 bins", "Total: 50 bins", "Count"],
- firstRows: [
- ["20 – 40", "20 – 25", "214"],
- ["20 – 40", "25 – 30", "396"],
- ],
- });
- H.assertQueryBuilderRowCount(7);
-
- cy.log("'bin-width' breakouts");
- testNumericPostAggregationFilter({
- questionDetails: questionWith2BinWidthBreakoutsDetails,
- column1Name: "Latitude: 20°",
- column1MinValue: 10,
- column1MaxValue: 50,
- column2Name: "Latitude: 10°",
- column2MinValue: 10,
- column2MaxValue: 50,
- });
- H.assertTableData({
- columns: ["Latitude: 20°", "Latitude: 10°", "Count"],
- firstRows: [
- ["20° N – 40° N", "20° N – 30° N", "87"],
- ["20° N – 40° N", "30° N – 40° N", "1,176"],
- ],
- });
- H.assertQueryBuilderRowCount(4);
- });
-
- it("should be able to add aggregations for each source column", () => {
- function testSourceAggregation({
- questionDetails,
- column1Name,
- column2Name,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column2Name: string;
- }) {
- H.createQuestion(questionDetails).then(({ body: card }) => {
- H.createQuestion(getNestedQuestionDetails(card.id), {
- visitQuestion: true,
- });
- });
- H.openNotebook();
-
- cy.log("add an aggregation for the first column");
- H.getNotebookStep("data").button("Summarize").click();
- H.popover().within(() => {
- cy.findByText("Minimum of ...").click();
- cy.findAllByText(column1Name).click();
- });
-
- cy.log("add an aggregation for the second column");
- H.getNotebookStep("summarize").icon("add").click();
- H.popover().within(() => {
- cy.findByText("Maximum of ...").click();
- cy.findAllByText(column2Name).click();
- });
-
- cy.log("assert query results");
- H.visualize();
- cy.wait("@dataset");
- }
-
- cy.log("temporal breakouts");
- testSourceAggregation({
- questionDetails: questionWith2TemporalBreakoutsDetails,
- column1Name: "Created At: Year",
- column2Name: "Created At: Month",
- });
- H.assertTableData({
- columns: ["Min of Created At: Year", "Max of Created At: Month"],
- firstRows: [["January 1, 2025, 12:00 AM", "April 1, 2029, 12:00 AM"]],
- });
-
- cy.log("'num-bins' breakouts");
- testSourceAggregation({
- questionDetails: questionWith2NumBinsBreakoutsDetails,
- column1Name: "Total: 10 bins",
- column2Name: "Total: 50 bins",
- });
- H.assertTableData({
- columns: ["Min of Total: 10 bins", "Max of Total: 50 bins"],
- firstRows: [["-60", "155"]],
- });
-
- cy.log("'max-bins' breakouts");
- testSourceAggregation({
- questionDetails: questionWith2BinWidthBreakoutsDetails,
- column1Name: "Latitude: 20°",
- column2Name: "Latitude: 10°",
- });
- H.assertTableData({
- columns: ["Min of Latitude: 20°", "Max of Latitude: 10°"],
- firstRows: [["20.00000000° N", "70.00000000° N"]],
- });
- });
-
- it("should be able to add breakouts for each source column", () => {
- function testSourceBreakout({
- questionDetails,
- column1Name,
- column2Name,
- }: {
- questionDetails: StructuredQuestionDetails;
- column1Name: string;
- column2Name: string;
- }) {
- H.createQuestion(questionDetails).then(({ body: card }) => {
- H.createQuestion(getNestedQuestionDetails(card.id), {
- visitQuestion: true,
- });
- });
- H.openNotebook();
-
- cy.log("add an aggregation");
- H.getNotebookStep("data").button("Summarize").click();
- H.popover().findByText("Count of rows").click();
-
- cy.log("add a breakout for the first source column");
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .findByText("Pick a column to group by")
- .click();
- H.popover().findAllByText(column1Name).click();
-
- cy.log("add a breakout for the second source column");
- H.getNotebookStep("summarize")
- .findByTestId("breakout-step")
- .icon("add")
- .click();
- H.popover().findAllByText(column2Name).click();
-
- cy.log("assert query results");
- H.visualize();
- cy.wait("@dataset");
- }
-
- cy.log("temporal breakouts");
- testSourceBreakout({
- questionDetails: questionWith2TemporalBreakoutsDetails,
- column1Name: "Created At: Year",
- column2Name: "Created At: Month",
- });
- H.assertTableData({
- columns: ["Created At: Year", "Created At: Month", "Count"],
- firstRows: [["2025", "April 2025", "1"]],
- });
-
- cy.log("'num-bins' breakouts");
- testSourceBreakout({
- questionDetails: questionWith2NumBinsBreakoutsDetails,
- column1Name: "Total: 10 bins",
- column2Name: "Total: 50 bins",
- });
- H.assertTableData({
- columns: ["Total: 10 bins", "Total: 50 bins", "Count"],
- firstRows: [
- ["-60 – -40", "-50 – -45", "1"],
- ["0 – 20", "5 – 10", "1"],
- ],
- });
-
- cy.log("'max-bins' breakouts");
- testSourceBreakout({
- questionDetails: questionWith2BinWidthBreakoutsDetails,
- column1Name: "Latitude: 20°",
- column2Name: "Latitude: 10°",
- });
- H.assertTableData({
- columns: ["Latitude: 20°", "Latitude: 10°", "Count"],
- firstRows: [
- ["20° N – 40° N", "20° N – 30° N", "1"],
- ["20° N – 40° N", "30° N – 40° N", "1"],
- ],
- });
- });
- });
-
describe("viz settings", () => {
it("should be able to toggle the fields that correspond to breakout columns in the source card", () => {
function toggleColumn(columnName: string, isVisible: boolean) {
diff --git a/e2e/test/scenarios/question/nested.cy.spec.js b/e2e/test/scenarios/question/nested.cy.spec.js
index fe6c1f2a3e8..245d0a22120 100644
--- a/e2e/test/scenarios/question/nested.cy.spec.js
+++ b/e2e/test/scenarios/question/nested.cy.spec.js
@@ -1,8 +1,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, PRODUCTS, PRODUCTS_ID, PEOPLE } = SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
const ordersJoinProductsQuery = {
"source-table": ORDERS_ID,
@@ -26,210 +25,6 @@ describe("scenarios > question > nested", () => {
cy.signInAsAdmin();
});
- it("should allow 'Distribution' and 'Sum over time' on nested questions (metabase#12568)", () => {
- cy.intercept("POST", "/api/dataset").as("dataset");
-
- // Make sure it works for a GUI question
- const guiQuestionDetails = {
- name: "GH_12568: Simple",
- query: {
- "source-table": ORDERS_ID,
- },
- display: "line",
- };
-
- createNestedQuestion(
- {
- baseQuestionDetails: guiQuestionDetails,
- nestedQuestionDetails: { name: "Nested GUI" },
- },
- { loadBaseQuestionMetadata: true },
- );
-
- H.tableHeaderClick("Total");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Distribution").click();
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Count by Total: Auto binned");
- H.chartPathWithFillColor("#509EE3").should("have.length.of.at.least", 8);
-
- // Go back to the nested question and make sure Sum over time works
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Nested GUI").click();
-
- H.tableHeaderClick("Total");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Sum over time").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Sum of Total by Created At: Month");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("52.76");
-
- // Make sure it works for a SQL question
- const sqlQuestionDetails = {
- name: "GH_12568: SQL",
- native: {
- query:
- "SELECT date_trunc('year', CREATED_AT) as date, COUNT(*) as count FROM ORDERS GROUP BY date_trunc('year', CREATED_AT)",
- },
- display: "scalar",
- };
-
- createNestedQuestion(
- {
- baseQuestionDetails: sqlQuestionDetails,
- nestedQuestionDetails: { name: "Nested SQL" },
- },
- { loadBaseQuestionMetadata: true },
- );
-
- H.tableHeaderClick("COUNT");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Distribution").click();
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Count by COUNT: Auto binned");
- H.chartPathWithFillColor("#509EE3").should("have.length.of.at.least", 5);
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Nested SQL").click();
-
- H.tableHeaderClick("COUNT");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Sum over time").click();
- cy.wait("@dataset");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Sum of COUNT");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("744");
- });
-
- it("should handle duplicate column names in nested queries (metabase#10511)", () => {
- H.createQuestion(
- {
- name: "10511",
- query: {
- filter: [">", ["field", "count", { "base-type": "type/Integer" }], 5],
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
- [
- "field",
- PRODUCTS.CREATED_AT,
- { "temporal-unit": "month", "source-field": ORDERS.PRODUCT_ID },
- ],
- ],
- },
- },
- },
- { visitQuestion: true },
- );
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("10511");
- cy.findAllByText("June 2025");
- cy.findAllByText("13");
- });
-
- it("should apply metrics including filter to the nested question (metabase#12507)", () => {
- const metric = {
- name: "Sum of discounts",
- description: "Discounted orders.",
- type: "metric",
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- filter: ["!=", ["field", ORDERS.DISCOUNT, null], 0],
- },
- };
-
- cy.log("Create a metric with a filter");
- H.createQuestion(metric, {
- wrapId: true,
- idAlias: "metricId",
- });
-
- cy.get("@metricId").then((metricId) => {
- // "capture" the original query because we will need to re-use it later in a nested question as "source-query"
- const baseQuestionDetails = {
- name: "12507",
- query: {
- "source-table": `card__${metricId}`,
- aggregation: [["metric", metricId]],
- breakout: [
- ["field", ORDERS.TOTAL, { binning: { strategy: "default" } }],
- ],
- },
- };
-
- const nestedQuestionDetails = {
- query: {
- filter: [">", ["field", ORDERS.TOTAL, null], 50],
- },
- };
-
- // Create new question which uses previously defined metric
- createNestedQuestion({ baseQuestionDetails, nestedQuestionDetails });
-
- cy.log("Reported failing since v0.35.2");
- H.assertQueryBuilderRowCount(5);
- });
- });
-
- it("should handle remapped display values in a base QB question (metabase#10474)", () => {
- cy.log(
- "Related issue [#14629](https://github.com/metabase/metabase/issues/14629)",
- );
-
- cy.log("Remap Product ID's display value to `title`");
- H.remapDisplayValueToFK({
- display_value: ORDERS.PRODUCT_ID,
- name: "Product ID",
- fk: PRODUCTS.TITLE,
- });
-
- const baseQuestionDetails = {
- name: "Orders (remapped)",
- query: { "source-table": ORDERS_ID, limit: 5 },
- };
-
- createNestedQuestion({ baseQuestionDetails });
-
- cy.findAllByText("Awesome Concrete Shoes");
- });
-
- it("nested questions based on a saved question with joins should work (metabase#14724)", () => {
- const baseQuestionDetails = {
- name: "14724",
- query: ordersJoinProductsQuery,
- };
-
- ["default", "remapped"].forEach((scenario) => {
- if (scenario === "remapped") {
- cy.log("Remap Product ID's display value to `title`");
- H.remapDisplayValueToFK({
- display_value: ORDERS.PRODUCT_ID,
- name: "Product ID",
- fk: PRODUCTS.TITLE,
- });
- }
-
- // should hangle single-level nesting
- createNestedQuestion({ baseQuestionDetails });
-
- cy.contains("37.65");
-
- // should handle multi-level nesting
- cy.get("@nestedQuestionId").then((id) => {
- visitNestedQueryAdHoc(id);
- cy.contains("37.65");
- });
- });
- });
-
it("'distribution' should work on a joined table from a saved question (metabase#14787)", () => {
// Set the display really wide and really tall to avoid any scrolling
cy.viewport(1600, 1200);
@@ -282,90 +77,6 @@ describe("scenarios > question > nested", () => {
}
});
- it("should be able to use aggregation functions on saved native question (metabase#15397)", () => {
- H.createNativeQuestion({
- name: "15397",
- native: {
- query:
- "select count(*), orders.product_id from orders group by orders.product_id;",
- },
- }).then(({ body: { id } }) => {
- H.visitQuestion(id);
-
- visitNestedQueryAdHoc(id);
-
- // Count
- H.summarize();
-
- cy.findByText("Group by").parent().findByText("COUNT(*)").click();
- cy.wait("@dataset");
-
- H.chartPathWithFillColor("#509EE3").should("have.length.of.at.least", 5);
-
- // Replace "Count" with the "Average"
- cy.findByTestId("aggregation-item").contains("Count").click();
- cy.findByText("Average of ...").click();
- H.popover().findByText("COUNT(*)").click();
- cy.wait("@dataset");
-
- H.chartPathWithFillColor("#A989C5").should("have.length.of.at.least", 5);
- });
- });
-
- describe("should use the same query for date filter in both base and nested questions (metabase#15352)", () => {
- it("should work with 'between' date filter (metabase#15352-1)", () => {
- assertOnFilter({
- name: "15352-1",
- filter: [
- "between",
- ["field-id", ORDERS.CREATED_AT],
- "2029-02-01",
- "2029-02-29",
- ],
- value: "543",
- });
- });
-
- it("should work with 'after/before' date filter (metabase#15352-2)", () => {
- assertOnFilter({
- name: "15352-2",
- filter: [
- "and",
- [">", ["field-id", ORDERS.CREATED_AT], "2029-01-31"],
- ["<", ["field-id", ORDERS.CREATED_AT], "2029-03-01"],
- ],
- value: "543",
- });
- });
-
- it("should work with 'on' date filter (metabase#15352-3)", () => {
- assertOnFilter({
- name: "15352-3",
- filter: ["=", ["field-id", ORDERS.CREATED_AT], "2029-02-01"],
- value: "17",
- });
- });
-
- function assertOnFilter({ name, filter, value } = {}) {
- H.createQuestion({
- name,
- query: {
- "source-table": ORDERS_ID,
- filter,
- aggregation: [["count"]],
- },
- type: "query",
- display: "scalar",
- }).then(({ body: { id } }) => {
- H.visitQuestion(id);
- cy.findByTestId("scalar-value").findByText(value);
-
- visitNestedQueryAdHoc(id);
- cy.findByTestId("scalar-value").findByText(value);
- });
- }
- });
-
describe("should not remove user defined metric when summarizing based on saved question (metabase#15725)", () => {
beforeEach(() => {
cy.intercept("POST", "/api/dataset").as("dataset");
@@ -501,49 +212,6 @@ describe("scenarios > question > nested", () => {
cy.button("Failed").should("not.exist");
}
});
-
- it("should create a nested question with post-aggregation filter (metabase#11561)", () => {
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [["field", PEOPLE.ID, { "source-field": ORDERS.USER_ID }]],
- },
- type: "query",
- },
- });
-
- H.filter();
- H.popover().within(() => {
- cy.findByText("Summaries").click();
- cy.findByText("Count").click();
- });
- H.selectFilterOperator("Equal to");
- H.popover().within(() => {
- cy.findByLabelText("Filter value").type("5");
- cy.button("Apply filter").click();
- });
- cy.wait("@dataset");
-
- H.queryBuilderFiltersPanel().findByText("Count is equal to 5");
- H.assertQueryBuilderRowCount(100);
-
- H.saveQuestionToCollection();
-
- reloadQuestion();
- H.assertQueryBuilderRowCount(100);
-
- H.openNotebook();
- cy.findAllByTestId("notebook-cell-item").contains(/Users? → ID/);
-
- function reloadQuestion() {
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
- cy.reload();
- cy.wait("@cardQuery");
- }
- });
});
function createNestedQuestion(
@@ -583,13 +251,3 @@ function createNestedQuestion(
: H.createQuestion(query);
}
}
-
-function visitNestedQueryAdHoc(id) {
- return H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- type: "query",
- query: { "source-table": `card__${id}` },
- },
- });
-}
diff --git a/e2e/test/scenarios/question/notebook.cy.spec.js b/e2e/test/scenarios/question/notebook.cy.spec.js
index fe7cd9863f1..f5ca6f57747 100644
--- a/e2e/test/scenarios/question/notebook.cy.spec.js
+++ b/e2e/test/scenarios/question/notebook.cy.spec.js
@@ -300,97 +300,6 @@ describe("scenarios > question > notebook", { tags: "@slow" }, () => {
});
});
- describe("arithmetic (metabase#13175, metabase#18094)", () => {
- beforeEach(() => {
- // This is required because TableInteractive won't render columns
- // that don't fit into the viewport
- cy.viewport(1400, 1000);
- H.openOrdersTable({ mode: "notebook" });
- });
-
- it("should work on custom column with `case`", () => {
- cy.findByLabelText("Custom column").click();
-
- H.enterCustomColumnDetails({
- formula: "case([Subtotal] + Tax > 100, 'Big', 'Small')",
- });
-
- H.CustomExpressionEditor.nameInput()
- .focus()
- .type("Example", { delay: 100 });
-
- cy.button("Done").should("not.be.disabled").click();
-
- H.getNotebookStep("expression").contains("Example").should("exist");
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Example");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Big");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Small");
- });
-
- it("should work on custom filter", () => {
- H.filter({ mode: "notebook" });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Custom Expression").click();
-
- H.enterCustomColumnDetails({ formula: "[Subtotal] - Tax > 140" });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains(/^redundant input/i).should("not.exist");
-
- cy.button("Done").should("not.be.disabled").click();
-
- H.visualize();
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("Showing 97 rows");
- });
-
- const CASES = {
- CountIf: ["CountIf(([Subtotal] + [Tax]) > 10)", "18,760"],
- SumIf: ["SumIf([Subtotal], ([Subtotal] + [Tax] > 20))", "1,447,850.28"],
- SumIf2: [
- 'SumIf([Total], [Created At] > "2016-01-01") + SumIf([Subtotal], [Created At] > "2016-01-01")',
- "2,958,809.85",
- ],
- CountIf2: [
- 'CountIf([Created At] > "2016-01-01") + CountIf([Created At] > "2016-01-01")',
- "37,520",
- ],
- };
-
- Object.entries(CASES).forEach(([filter, formula]) => {
- const [expression, result] = formula;
-
- it(`should work on custom aggregation with ${filter}`, () => {
- H.summarize({ mode: "notebook" });
- H.popover().contains("Custom Expression").click();
-
- H.enterCustomColumnDetails({ formula: expression });
-
- H.CustomExpressionEditor.nameInput().click().type(filter);
-
- H.popover().within(() => {
- cy.contains(/^expected closing parenthesis/i).should("not.exist");
- cy.contains(/^redundant input/i).should("not.exist");
- });
- cy.button("Done").should("not.be.disabled").click();
-
- cy.findByTestId("aggregate-step").contains(filter).should("exist");
-
- H.visualize();
-
- cy.findByTestId("qb-header").contains(filter);
- cy.findByTestId("query-builder-main").contains(result);
- });
- });
- });
-
// intentional simplification of "Select none" to quickly
// fix users' pain caused by the inability to unselect all columns
it("select no columns select the first one", () => {
diff --git a/e2e/test/scenarios/question/offset.cy.spec.ts b/e2e/test/scenarios/question/offset.cy.spec.ts
index 5308db71dcb..6b6dbd4d5c2 100644
--- a/e2e/test/scenarios/question/offset.cy.spec.ts
+++ b/e2e/test/scenarios/question/offset.cy.spec.ts
@@ -9,7 +9,7 @@ import type {
StructuredQuery,
} from "metabase-types/api";
-const { ORDERS, ORDERS_ID, PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
+const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
const ORDERS_ID_FIELD_REF: FieldReference = [
"field",
@@ -29,12 +29,6 @@ const ORDERS_CREATED_AT_BREAKOUT: Breakout = [
{ "base-type": "type/DateTime", "temporal-unit": "month" },
];
-const PRODUCTS_CATEGORY_BREAKOUT: Breakout = [
- "field",
- PRODUCTS.CATEGORY,
- { "base-type": "type/Text", "source-field": ORDERS.PRODUCT_ID },
-];
-
const SUM_TOTAL_AGGREGATION: Aggregation = ["sum", ORDERS_TOTAL_FIELD_REF];
const OFFSET_SUM_TOTAL_AGGREGATION_NAME = "Offsetted sum of total";
@@ -277,32 +271,6 @@ describe("scenarios > question > offset", () => {
});
});
- it(
- "does not preview sql without a breakout (metabase#47819)",
- { tags: "@skip" },
- () => {
- cy.intercept("POST", "/api/dataset/native").as("sqlPreview");
-
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- aggregation: [OFFSET_SUM_TOTAL_AGGREGATION],
- limit: 5,
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- H.openNotebook();
-
- cy.findByLabelText("View SQL").click();
- cy.wait("@sqlPreview");
-
- cy.findByTestId("native-query-preview-sidebar").should(
- "not.contain",
- "Error generating the query.",
- );
- },
- );
-
it("works with a single breakout", () => {
const query: StructuredQuery = {
"source-table": ORDERS_ID,
@@ -323,93 +291,6 @@ describe("scenarios > question > offset", () => {
H.getNotebookStep("summarize").icon("play").should("be.visible");
});
- it("works with a single breakout and sorting by breakout", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- aggregation: [OFFSET_SUM_TOTAL_AGGREGATION],
- breakout: [ORDERS_CREATED_AT_BREAKOUT],
- limit: 5,
- "order-by": [["desc", ORDERS_CREATED_AT_BREAKOUT]],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- verifyNoQuestionError();
- verifyTableContent([
- ["April 2029", ""],
- ["March 2029", "30,759.47"],
- ]);
- });
-
- it("works with a single breakout and sorting by aggregation (metabase#42554)", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- aggregation: [OFFSET_SUM_TOTAL_AGGREGATION],
- breakout: [ORDERS_CREATED_AT_BREAKOUT],
- limit: 5,
- "order-by": [["desc", ["aggregation", 0]]],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- verifyNoQuestionError();
- verifyTableContent([
- [
- "February 2029",
- "52,249.59",
- "February 2028",
- "51,634.16",
- "April 2028",
- "51,347.1",
- "September 2028",
- "50,597.16",
- "January 2029",
- "48,260.76",
- ],
- ]);
- });
-
- it("works with multiple breakouts", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- aggregation: [OFFSET_SUM_TOTAL_AGGREGATION],
- breakout: [ORDERS_CREATED_AT_BREAKOUT, PRODUCTS_CATEGORY_BREAKOUT],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- verifyNoQuestionError();
- verifyTableContent([
- ["April 2025", "", "", "", ""],
- ["May 2025", "", "52.76", "", ""],
- ["June 2025", "339.14", "203.57", "493.51", "229.5"],
- ]);
- });
-
- it("works with multiple aggregations and breakouts", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- aggregation: [SUM_TOTAL_AGGREGATION, OFFSET_SUM_TOTAL_AGGREGATION],
- breakout: [ORDERS_CREATED_AT_BREAKOUT, PRODUCTS_CATEGORY_BREAKOUT],
- limit: 9,
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- verifyNoQuestionError();
- verifyTableContent([
- ["May 2025", "Doohickey", "339.14", ""],
- ["June 2025", "Doohickey", "482.56", "339.14"],
- ["July 2025", "Doohickey", "1,160.83", "482.56"],
- ["August 2025", "Doohickey", "751.29", "1,160.83"],
- ["September 2025", "Doohickey", "802.49", "751.29"],
- ["October 2025", "Doohickey", "1,553.37", "802.49"],
- ["November 2025", "Doohickey", "1,728.4", "1,553.37"],
- ["December 2025", "Doohickey", "2,213.47", "1,728.4"],
- ["January 2026", "Doohickey", "1,939.99", "2,213.47"],
- ]);
- });
-
it("works after saving a question (metabase#42323)", () => {
const breakoutName = "Created At";
@@ -442,69 +323,6 @@ describe("scenarios > question > offset", () => {
});
});
- it("works in a complex real-life scenario", () => {
- const breakoutName = "Created At";
- const totalSalesName = "Total sales (this month)";
- const totalSalesLastMonthName = "Total sales (last month)";
- const percentSalesGrowthName = "Percent sales growth over last month";
- const rollingTotalName = "Rolling total of sales last 3 months";
- const rollingAverageName = "Rolling average of sales last 3 months";
- const legendItems = [
- totalSalesName,
- totalSalesLastMonthName,
- percentSalesGrowthName,
- rollingTotalName,
- rollingAverageName,
- ];
-
- H.startNewQuestion();
- H.miniPicker().within(() => {
- cy.findByText("Sample Database").click();
- cy.findByText("Orders").click();
- });
- addCustomAggregation({
- formula: "Sum([Total])",
- name: totalSalesName,
- isFirst: true,
- });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: totalSalesLastMonthName,
- });
- addCustomAggregation({
- formula: "Sum([Total]) / Offset(Sum([Total]), -1) - 1",
- name: percentSalesGrowthName,
- });
- addCustomAggregation({
- formula:
- "Sum([Total]) + Offset(Sum([Total]), -1) + Offset(Sum([Total]), -2)",
- name: rollingTotalName,
- });
- addCustomAggregation({
- formula:
- "(Sum([Total]) + Offset(Sum([Total]), -1) + Offset(Sum([Total]), -2)) / 3",
- name: rollingAverageName,
- });
- addBreakout(breakoutName);
-
- H.visualize();
- verifyNoQuestionError();
- verifyLineChart({
- xAxis: breakoutName + ": Month",
- legendItems,
- });
-
- // checking data after saveQuestion is not necessary as it's covered by "works after saving a question (metabase#42323)"
- saveQuestion().then(({ response }) => {
- H.visitQuestion(response?.body.id);
- verifyNoQuestionError();
- verifyLineChart({
- xAxis: breakoutName + ": Month",
- legendItems,
- });
- });
- });
-
it("should allow using OFFSET as a CASE argument (metabase#42377)", () => {
const formula = "Sum(case([Total] > 0, Offset([Total], -1)))";
const name = "Aggregation";
@@ -579,657 +397,6 @@ describe("scenarios > question > offset", () => {
});
});
- describe("explicit joins", () => {
- it("offset expression not in the first place in aggregation", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: [
- ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }],
- ],
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
- H.openNotebook();
-
- H.summarize({ mode: "notebook" });
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({
- table: "Products",
- field: "Category",
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
-
- addSorting({ field: "Created At" });
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["Doohickey", "2025", "9,031.56", ""],
- ["Gadget", "2025", "10,672.63", ""],
- ["Gizmo", "2025", "9,929.32", ""],
- ["Widget", "2025", "12,523.37", ""],
- ["Doohickey", "2026", "43,069.14", "9,031.56"],
- ["Gadget", "2026", "54,960.62", "10,672.63"],
- ["Gizmo", "2026", "48,130.71", "9,929.32"],
- ["Widget", "2026", "59,095.56", "12,523.37"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("offset expression is in the first place in aggregation", () => {
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: [
- ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }],
- ],
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
- H.openNotebook();
-
- H.summarize({ mode: "notebook" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- isOpened: true,
- });
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
-
- H.addSummaryGroupingField({
- table: "Products",
- field: "Category",
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
-
- H.startSort();
- H.popover().contains("Created At").click();
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["Doohickey", "2025", "", "9,031.56"],
- ["Gadget", "2025", "", "10,672.63"],
- ["Gizmo", "2025", "", "9,929.32"],
- ["Widget", "2025", "", "12,523.37"],
- ["Doohickey", "2026", "9,031.56", "43,069.14"],
- ["Gadget", "2026", "10,672.63", "54,960.62"],
- ["Gizmo", "2026", "9,929.32", "48,130.71"],
- ["Widget", "2026", "12,523.37", "59,095.56"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("offset and avg function applied to custom column", () => {
- const customColumnName = "CC Product Rating";
-
- const query: StructuredQuery = {
- "source-table": ORDERS_ID,
- joins: [
- {
- fields: [
- ["field", PRODUCTS.CATEGORY, { "join-alias": "Products" }],
- ],
- "source-table": PRODUCTS_ID,
- condition: [
- "=",
- ["field", ORDERS.PRODUCT_ID, null],
- ["field", PRODUCTS.ID, { "join-alias": "Products" }],
- ],
- alias: "Products",
- },
- ],
- };
-
- H.createQuestion({ query }, { visitQuestion: true });
-
- H.openNotebook();
- addCustomColumn({
- name: customColumnName,
- formula: "[Products → Rating]",
- });
-
- H.summarize({ mode: "notebook" });
- H.addSummaryField({ metric: "Average of ...", field: customColumnName });
-
- addCustomAggregation({
- formula: `Offset(Average([${customColumnName}]), -1)`,
- name: "offsetted avg product rating",
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
-
- H.startSort();
- H.popover().contains(customColumnName).click();
- H.getNotebookStep("sort").findByText(customColumnName).click();
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2025", "5", "5", ""],
- ["2026", "5", "5", "5"],
- ["2027", "5", "5", "5"],
- ]);
- });
- });
-
- describe("implicit joins", () => {
- describe("when custom column is in the first place of breakout", () => {
- it("works with custom column that contains a function", () => {
- const customColumnName = "CC Product Category";
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- addCustomColumn({
- formula: 'concat([Product → Category], " from products")',
- name: customColumnName,
- actionButtonsGroup: "first",
- });
-
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
-
- addSorting({ field: "Created At" });
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["Doohickey from products", "2025", "9,031.56", ""],
- ["Gadget from products", "2025", "10,672.63", ""],
- ["Gizmo from products", "2025", "9,929.32", ""],
- ["Widget from products", "2025", "12,523.37", ""],
- ["Doohickey from products", "2026", "43,069.14", "9,031.56"],
- ["Gadget from products", "2026", "54,960.62", "10,672.63"],
- ["Gizmo from products", "2026", "48,130.71", "9,929.32"],
- ["Widget from products", "2026", "59,095.56", "12,523.37"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("works with custom column that contains a column", () => {
- const customColumnName = "CC Product Category";
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- addCustomColumn({
- formula: "[Product → Category]",
- name: customColumnName,
- actionButtonsGroup: "first",
- });
-
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
-
- addSorting({ field: "Created At" });
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["Doohickey", "2025", "9,031.56", ""],
- ["Gadget", "2025", "10,672.63", ""],
- ["Gizmo", "2025", "9,929.32", ""],
- ["Widget", "2025", "12,523.37", ""],
- ["Doohickey", "2026", "43,069.14", "9,031.56"],
- ["Gadget", "2026", "54,960.62", "10,672.63"],
- ["Gizmo", "2026", "48,130.71", "9,929.32"],
- ["Widget", "2026", "59,095.56", "12,523.37"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("works when custom column is a simple expression (metabase#47870)", () => {
- const customColumnName = "1 + 1";
- const customColumnName2 = "constant";
- const customColumnName3 = "string";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "1+1",
- });
- H.getNotebookStep("expression").icon("add").click();
- H.enterCustomColumnDetails({
- name: customColumnName2,
- formula: "0+1",
- });
- H.popover().findByText("Done").click();
-
- H.getNotebookStep("expression").icon("add").click();
- H.enterCustomColumnDetails({
- name: customColumnName3,
- formula: "concat('a','b')",
- });
- H.popover().findByText("Done").click();
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({
- field: customColumnName2,
- });
- H.addSummaryGroupingField({
- field: customColumnName3,
- });
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- addSorting({ field: "Created At" });
-
- H.visualize();
-
- verifyNoQuestionError();
-
- verifyTableContent([
- ["2", "1", "ab", "2025", "42,156.87", ""],
- ["2", "1", "ab", "2026", "205,256.02", "42,156.87"],
- ["2", "1", "ab", "2027", "510,045.03", "205,256.02"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("works when custom column is a simple expression with CC not in the first place", () => {
- const customColumnName = "1 + 1";
- const customColumnName2 = "constant";
- const customColumnName3 = "string";
-
- H.openTable({ table: ORDERS_ID });
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "1+1",
- });
-
- H.getNotebookStep("expression").icon("add").click();
- H.enterCustomColumnDetails({
- name: customColumnName2,
- formula: "0+1",
- });
- H.popover().findByText("Done").click();
-
- H.getNotebookStep("expression").icon("add").click();
- H.enterCustomColumnDetails({
- name: customColumnName3,
- formula: "concat('a','b')",
- });
- H.popover().findByText("Done").click();
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({
- field: customColumnName2,
- });
- H.addSummaryGroupingField({
- field: customColumnName3,
- });
- addSorting({ field: "Created At" });
-
- H.visualize();
-
- verifyNoQuestionError();
-
- verifyTableContent([
- ["2025", "2", "1", "ab", "42,156.87", ""],
- ["2026", "2", "1", "ab", "205,256.02", "42,156.87"],
- ["2027", "2", "1", "ab", "510,045.03", "205,256.02"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
- });
-
- describe("when custom column is not in the first place of breakout", () => {
- it("works with custom column that contains a function", () => {
- const customColumnName = "CC Product Category";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: 'concat([Product → Category], " from products")',
- });
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- addSorting({ field: "Created At" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2025", "Doohickey from products", "9,031.56", ""],
- ["2025", "Gadget from products", "10,672.63", ""],
- ["2025", "Gizmo from products", "9,929.32", ""],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("works with custom column that contains a column", () => {
- const customColumnName = "CC Product Category";
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "[Product → Category]",
- });
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- addSorting({ field: "Created At" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2025", "Doohickey", "9,031.56", ""],
- ["2025", "Gadget", "10,672.63", ""],
- ["2025", "Gizmo", "9,929.32", ""],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
-
- it("works when custom column is a simple expression", () => {
- const customColumnName = "1 + 1";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "1+1",
- });
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- addSorting({ field: "Created At" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2025", "2", "42,156.87", ""],
- ["2026", "2", "205,256.02", "42,156.87"],
- ["2027", "2", "510,045.03", "205,256.02"],
- ]);
-
- H.openNotebook();
- H.getNotebookStep("summarize").icon("play").should("be.visible");
- });
- });
- });
-
- describe("when expression contains a standard function with offset", () => {
- it("works with avg", () => {
- const customColumnName = "CC Product Price";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "[Product → Rating]",
- });
-
- H.summarize({ mode: "notebook" });
-
- addCustomAggregation({
- formula: `Average([${customColumnName}])`,
- name: "Average product rating",
- isFirst: true,
- });
- addCustomAggregation({
- formula: `Offset(Average([${customColumnName}]), -1)`,
- name: "offsetted average product rating",
- });
-
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- addSorting({ field: customColumnName, order: "desc" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["5", "2025", "5", ""],
- ["5", "2026", "5", "5"],
- ["5", "2027", "5", "5"],
- ["5", "2028", "5", "5"],
- ["5", "2029", "5", "5"],
- ["4.8", "2025", "4.8", ""],
- ["4.8", "2026", "4.8", "4.8"],
- ["4.8", "2027", "4.8", "4.8"],
- ["4.8", "2028", "4.8", "4.8"],
- ["4.8", "2029", "4.8", "4.8"],
- ]);
- });
-
- it("works with 3 breakouts", () => {
- const customColumnName = "CC Product Rating";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- addCustomColumn({
- name: customColumnName,
- formula: "[Product → Rating]",
- });
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({
- table: "User",
- field: "Source",
- });
- addSorting({ field: "Created At", order: "desc" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2029", "0", "Affiliate", "3,443.41", ""],
- ["2029", "0", "Facebook", "4,014.21", ""],
- ]);
- });
- });
-
- it("works with filtering using segment", () => {
- const segmentName = "Orders < 100";
- H.createSegment({
- name: segmentName,
- description: "All orders with a total under $100.",
- table_id: ORDERS_ID,
- definition: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- filter: ["<", ["field", ORDERS.TOTAL, null], 100],
- },
- });
-
- const customColumnName = "CC Product Rating";
-
- H.openTable({ table: ORDERS_ID });
-
- H.openNotebook();
-
- cy.findAllByTestId("action-buttons").first().icon("filter").click();
- H.popover().findByText("Custom Expression").click();
-
- H.enterCustomColumnDetails({
- formula: `[${segmentName}]`,
- });
- H.popover().findByText("Done").click();
-
- addCustomColumn({
- name: customColumnName,
- formula: "[Product → Rating]",
- actionButtonsGroup: "first",
- });
-
- H.summarize({ mode: "notebook" });
-
- H.addSummaryField({ metric: "Sum of ...", field: "Total" });
- addCustomAggregation({
- formula: "Offset(Sum([Total]), -1)",
- name: OFFSET_SUM_TOTAL_AGGREGATION_NAME,
- });
-
- H.addSummaryGroupingField({ field: "Created At", bucketSize: "Year" });
- H.addSummaryGroupingField({
- field: customColumnName,
- });
- H.addSummaryGroupingField({
- table: "User",
- field: "Source",
- });
- addSorting({ field: "Created At", order: "desc" });
-
- H.visualize();
-
- verifyNoQuestionError();
- verifyTableContent([
- ["2029", "0", "Affiliate", "1,303.43", ""],
- ["2029", "0", "Facebook", "1,835.1", ""],
- ]);
- });
-
it("should work with metrics (metabase#47854)", () => {
const metricName = "Count of orders";
const ORDERS_SCALAR_METRIC: StructuredQuestionDetails = {
@@ -1408,41 +575,3 @@ function createOffsetOptions(name = "offset") {
"display-name": name,
};
}
-
-function addSorting({
- field,
- order = "asc",
-}: {
- field: string;
- order?: "asc" | "desc";
-}) {
- H.startSort();
- H.popover().contains(field).click();
-
- if (order === "desc") {
- H.getNotebookStep("sort").contains(field).click();
- }
-}
-
-function addCustomColumn({
- name,
- formula,
- actionButtonsGroup = "last",
-}: {
- name: string;
- formula: string;
- actionButtonsGroup?: "first" | "last";
-}) {
- if (actionButtonsGroup === "first") {
- cy.findAllByTestId("action-buttons").first().icon("add_data").click();
- } else {
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.findAllByTestId("action-buttons").last().icon("add_data").click();
- }
-
- H.enterCustomColumnDetails({
- formula,
- name,
- });
- H.popover().findByText("Done").click();
-}
diff --git a/e2e/test/scenarios/question/summarization.cy.spec.js b/e2e/test/scenarios/question/summarization.cy.spec.js
index eb7b5eb5c80..6872bfa47f3 100644
--- a/e2e/test/scenarios/question/summarization.cy.spec.js
+++ b/e2e/test/scenarios/question/summarization.cy.spec.js
@@ -5,7 +5,7 @@ import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
-const { ORDERS, ORDERS_ID } = SAMPLE_DATABASE;
+const { ORDERS_ID } = SAMPLE_DATABASE;
describe("scenarios > question > summarize sidebar", () => {
beforeEach(() => {
@@ -111,38 +111,6 @@ describe("scenarios > question > summarize sidebar", () => {
});
});
- it("should be able to do subsequent aggregation on a custom expression (metabase#14649)", () => {
- H.createQuestion(
- {
- name: "14649_min",
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [
- [
- "aggregation-options",
- ["sum", ["field", ORDERS.SUBTOTAL, null]],
- { name: "Revenue", "display-name": "Revenue" },
- ],
- ],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }],
- ],
- },
- aggregation: [
- ["min", ["field", "Revenue", { "base-type": "type/Float" }]],
- ],
- },
-
- display: "scalar",
- },
- { visitQuestion: true },
- );
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("49.54");
- });
-
it("should allow using `Custom Expression` in orders metrics (metabase#12899)", () => {
H.openOrdersTable({ mode: "notebook" });
H.summarize({ mode: "notebook" });
diff --git a/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js b/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
index 76eeac4d4e8..d9d5f61e294 100644
--- a/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/maps.cy.spec.js
@@ -476,25 +476,6 @@ describe("scenarios > visualizations > maps", () => {
.should("have.length", 1)
.contains("Longitude is between -180 and 180");
});
-
- it("should handle brush filters that cross the 180th meridian (metabase#41056)", () => {
- pinMapSelectRegion(100, 100, 200, 200);
-
- cy.get(".CardVisualization").should("exist");
- cy.findByTestId("question-row-count").findByText("Showing 9 rows");
-
- // Exact value for these longitude bounds is not important.
- const lngRegex = /\d+(\.\d+)?/.source;
-
- cy.findAllByTestId("filter-pill")
- .should("have.length", 1)
- .contains(
- new RegExp(
- `(Latitude is between .*) and Longitude is between ${lngRegex} and 180` +
- ` or \\1 and Longitude is between -180 and -${lngRegex}`,
- ),
- );
- });
},
);
});
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.js
index 561e2472230..c75a5d85241 100644
--- a/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-charts/visualizations-charts-reproductions.cy.spec.js
@@ -7,46 +7,6 @@ const { PRODUCTS, PRODUCTS_ID } = SAMPLE_DATABASE;
const { PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
const { REVIEWS, REVIEWS_ID } = SAMPLE_DATABASE;
-describe("issue 13504", () => {
- const questionDetails = {
- name: "13504",
- display: "line",
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- filter: [">", ["field", ORDERS.TOTAL, null], 50],
- aggregation: [["count"]],
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
- },
- filter: [">", ["field", "count", { "base-type": "type/Integer" }], 100],
- },
- visualization_settings: {
- "graph.dimensions": ["CREATED_AT"],
- "graph.metrics": ["count"],
- },
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should remove post-aggregation filters from a multi-stage query (metabase#13504)", () => {
- H.createQuestion(questionDetails, { visitQuestion: true });
-
- H.cartesianChartCircle().eq(0).click({ force: true });
-
- H.popover().findByText("See these Orders").click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").within(() => {
- cy.findByText("Total is greater than 50").should("be.visible");
- cy.findByText("Created At: Month is Mar 1–31, 2026").should("be.visible");
- });
- });
-});
-
const externalDatabaseId = 2;
describe("issue 16170", { tags: "@mongo" }, () => {
diff --git a/e2e/test/scenarios/visualizations-tabular/drillthroughs/chart_drill.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/drillthroughs/chart_drill.cy.spec.js
index bb459331555..9e3117e6372 100644
--- a/e2e/test/scenarios/visualizations-tabular/drillthroughs/chart_drill.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/drillthroughs/chart_drill.cy.spec.js
@@ -564,71 +564,6 @@ describe("scenarios > visualizations > drillthroughs > chart drill", () => {
});
});
- it("count of rows from drill-down on binned results should match the number of records (metabase#15324)", () => {
- H.visitQuestionAdhoc({
- name: "15324",
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["binning-strategy", ["field-id", ORDERS.QUANTITY], "num-bins", 10],
- ],
- },
- type: "query",
- },
- display: "table",
- });
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(/^10 –/)
- .parent()
- .parent()
- .next()
- .contains("85")
- .click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("See these Orders").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quantity is greater than or equal to 10");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Quantity is less than 20");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Showing 85 rows");
- });
-
- it("should drill through on a bin of null values (#11345)", () => {
- H.visitQuestionAdhoc({
- name: "11345",
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", ORDERS.DISCOUNT, { binning: { strategy: "default" } }],
- ],
- },
- type: "query",
- },
- display: "table",
- });
-
- // click on the Count column cell showing the count of null rows
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("16,845").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("See these Orders").click();
-
- // count number of distinct values in the Discount column
- H.tableHeaderClick("Discount ($)");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Distinct values").click();
-
- // there should be 0 distinct values since they are all null
- cy.get(".test-TableInteractive-cellWrapper").contains("0");
- });
-
it("should parse value on click through on the first row of pie chart (metabase#15250)", () => {
H.createQuestion({
name: "15250",
diff --git a/e2e/test/scenarios/visualizations-tabular/drillthroughs/column_extract_drill.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/drillthroughs/column_extract_drill.cy.spec.js
index 89a991320b5..26c6cceedaf 100644
--- a/e2e/test/scenarios/visualizations-tabular/drillthroughs/column_extract_drill.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/drillthroughs/column_extract_drill.cy.spec.js
@@ -7,91 +7,13 @@ import { ORDERS_QUESTION_ID } from "e2e/support/cypress_sample_instance_data";
const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
-const DATE_CASES = [
- {
- option: "Hour of day",
- value: "21",
- example: "0, 1",
- },
- {
- option: "Day of month",
- value: "11",
- example: "1, 2",
- },
- {
- option: "Day of week",
- value: "Friday",
- example: "Monday, Tuesday",
- },
- {
- option: "Month of year",
- value: "Feb",
- example: "Jan, Feb",
- },
- {
- option: "Quarter of year",
- value: "Q1",
- example: "Q1, Q2",
- },
- {
- option: "Year",
- value: "2,028",
- example: "2026, 2027",
- },
-];
-
-const EMAIL_CASES = [
- {
- option: "Domain",
- value: "yahoo",
- example: "example, online",
- },
- {
- option: "Host",
- value: "yahoo.com",
- example: "example.com, online.com",
- },
-];
-
const URL_CASES = [
- {
- option: "Domain",
- value: "yahoo",
- example: "example, online",
- },
- {
- option: "Subdomain",
- value: "",
- example: "www, maps",
- },
- {
- option: "Host",
- value: "yahoo.com",
- example: "example.com, online.com",
- },
{
option: "Path",
example: "/en/docs/feature",
},
];
-const DATE_QUESTION = {
- query: {
- "source-table": ORDERS_ID,
- aggregation: [
- ["min", ["field", ORDERS.CREATED_AT, { "base-type": "type/DateTime" }]],
- ],
- breakout: [
- [
- "field",
- ORDERS.CREATED_AT,
- { "base-type": "type/DateTime", "temporal-unit": "month" },
- ],
- ],
- limit: 1,
- },
-};
-
describe("extract action", { viewportWidth: 1600 }, () => {
beforeEach(() => {
H.restore();
@@ -99,21 +21,6 @@ describe("extract action", { viewportWidth: 1600 }, () => {
});
describe("date columns", () => {
- describe("should add a date expression for each option", () => {
- DATE_CASES.forEach(({ option, value, example }) => {
- it(option, () => {
- H.openOrdersTable({ limit: 1 });
- extractColumnAndCheck({
- column: "Created At",
- option,
- value,
- example,
- extraction: "Extract day, month…",
- });
- });
- });
- });
-
describe("should add a new column after the selected column", () => {
it("ad-hoc question", () => {
H.openOrdersTable();
@@ -180,42 +87,6 @@ describe("extract action", { viewportWidth: 1600 }, () => {
});
});
- it("should add an expression based on a breakout column", () => {
- H.createQuestion(DATE_QUESTION, { visitQuestion: true });
- extractColumnAndCheck({
- column: "Created At: Month",
- option: "Month of year",
- value: "Apr",
- extraction: "Extract day, month…",
- });
- });
-
- it("should add an expression based on an aggregation column", () => {
- H.createQuestion(DATE_QUESTION, { visitQuestion: true });
- extractColumnAndCheck({
- column: "Min of Created At",
- option: "Year",
- value: "2,025",
- extraction: "Extract day, month…",
- });
- });
-
- it("should handle duplicate expression names", () => {
- H.openOrdersTable({ limit: 1 });
- extractColumnAndCheck({
- column: "Created At",
- option: "Hour of day",
- newColumn: "Hour of day",
- extraction: "Extract day, month…",
- });
- extractColumnAndCheck({
- column: "Created At",
- option: "Hour of day",
- newColumn: "Hour of day_2",
- extraction: "Extract day, month…",
- });
- });
-
it("should be able to modify the expression in the notebook editor", () => {
H.openOrdersTable({ limit: 1 });
extractColumnAndCheck({
@@ -250,26 +121,6 @@ describe("extract action", { viewportWidth: 1600 }, () => {
});
});
- describe("email columns", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- EMAIL_CASES.forEach(({ option, value, example }) => {
- it(option, () => {
- H.openPeopleTable({ limit: 1 });
- extractColumnAndCheck({
- column: "Email",
- option,
- value,
- example,
- extraction: "Extract domain, host…",
- });
- });
- });
- });
-
describe("url columns", () => {
beforeEach(() => {
H.restore();
diff --git a/e2e/test/scenarios/visualizations-tabular/drillthroughs/geographic_drill.cy.spec.ts b/e2e/test/scenarios/visualizations-tabular/drillthroughs/geographic_drill.cy.spec.ts
deleted file mode 100644
index 82d4d8b4504..00000000000
--- a/e2e/test/scenarios/visualizations-tabular/drillthroughs/geographic_drill.cy.spec.ts
+++ /dev/null
@@ -1,142 +0,0 @@
-const { H } = cy;
-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
-
-const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;
-
-describe("scenarios > visualizations > drillthroughs > geographic drill", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should display proper drills for city, state, and lat/lon queries", () => {
- H.createQuestion(
- {
- name: "Geographic Drills",
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PEOPLE.STATE, null],
- ["field", PEOPLE.CITY, null],
- ["field", PEOPLE.LATITUDE, { binning: { strategy: "default" } }],
- ["field", PEOPLE.LONGITUDE, { binning: { strategy: "default" } }],
- ],
- },
- display: "table",
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("table-body").findAllByText("1").first().click();
- H.popover().within(() => {
- cy.findByText("Zoom in: City").should("be.visible");
- cy.findByText("Zoom in: State").should("be.visible");
- cy.findByText("Zoom in: Lat/Lon").should("be.visible");
- cy.findByText("Zoom in").should("not.exist");
- });
- });
-
- it("should display normal binning zoom in when only lat exists", () => {
- H.createQuestion(
- {
- name: "Geographic Drills",
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PEOPLE.STATE, null],
- ["field", PEOPLE.CITY, null],
- ["field", PEOPLE.LATITUDE, { binning: { strategy: "default" } }],
- ],
- },
- display: "table",
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("table-body").findAllByText("1").first().click();
- H.popover().within(() => {
- cy.findByText("Zoom in: City").should("be.visible");
- cy.findByText("Zoom in: State").should("be.visible");
- cy.findByText("Zoom in: Lat/Lon").should("not.exist");
- cy.findByText("Zoom in").should("be.visible");
- });
- });
-
- it("should display normal binning zoom in when only lon exists", () => {
- H.createQuestion(
- {
- name: "Geographic Drills",
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PEOPLE.STATE, null],
- ["field", PEOPLE.CITY, null],
- ["field", PEOPLE.LONGITUDE, { binning: { strategy: "default" } }],
- ],
- },
- display: "table",
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("table-body").findAllByText("1").first().click();
- H.popover().within(() => {
- cy.findByText("Zoom in: City").should("be.visible");
- cy.findByText("Zoom in: State").should("be.visible");
- cy.findByText("Zoom in: Lat/Lon").should("not.exist");
- cy.findByText("Zoom in").should("be.visible");
- });
- });
-
- it("should display both normal and lat/lon zoom in when lat/lon and a binnable column both exist", () => {
- H.createQuestion(
- {
- name: "Geographic Drills",
- query: {
- "source-table": PEOPLE_ID,
- joins: [
- {
- "source-table": ORDERS_ID,
- condition: [
- "=",
- ["field", PEOPLE.ID, null],
- ["field", ORDERS.USER_ID, null],
- ],
- alias: "Orders",
- fields: "all",
- },
- ],
- filter: [
- "not-null",
- ["field", ORDERS.SUBTOTAL, { "join-alias": "Orders" }],
- ],
- aggregation: [["count"]],
- breakout: [
- ["field", PEOPLE.STATE, null],
- ["field", PEOPLE.CITY, null],
- ["field", PEOPLE.LATITUDE, { binning: { strategy: "default" } }],
- ["field", PEOPLE.LONGITUDE, { binning: { strategy: "default" } }],
- [
- "field",
- ORDERS.SUBTOTAL,
- { binning: { strategy: "default" }, "join-alias": "Orders" },
- ],
- ],
- },
- display: "table",
- },
- { visitQuestion: true },
- );
-
- cy.findByTestId("table-body").findAllByText("1").first().click();
- H.popover().within(() => {
- cy.findByText("Zoom in: City").should("be.visible");
- cy.findByText("Zoom in: State").should("be.visible");
- cy.findByText("Zoom in: Lat/Lon").should("be.visible");
- cy.findByText("Zoom in").should("be.visible");
- });
- });
-});
diff --git a/e2e/test/scenarios/visualizations-tabular/drillthroughs/table_drills.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/drillthroughs/table_drills.cy.spec.js
index 86b41b3a1c3..5f2a4d1223a 100644
--- a/e2e/test/scenarios/visualizations-tabular/drillthroughs/table_drills.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/drillthroughs/table_drills.cy.spec.js
@@ -224,11 +224,6 @@ describe("scenarios > visualizations > drillthroughs > table_drills", () => {
},
],
};
- const queryWithJoinThenFilter = {
- "source-query": queryWithJoin,
- filter: [">", ["field", "count", { "base-type": "type/Integer" }], 0],
- };
-
function pivotDrillTest({
query,
drillCellText,
@@ -268,16 +263,6 @@ describe("scenarios > visualizations > drillthroughs > table_drills", () => {
});
});
- it("should allow category pivot drills on multi-stage queries (metabase#52236)", () => {
- pivotDrillTest({
- query: queryWithJoinThenFilter,
- drillCellText: "4,939",
- menuItems: ["Category", "Vendor"],
- filterText: "Products → Category is Gadget",
- resultText: "Barrows-Johns",
- });
- });
-
it("should allow timeseries pivot drills on single-stage queries (metabase#52236)", () => {
pivotDrillTest({
query: queryWithJoin,
@@ -287,16 +272,6 @@ describe("scenarios > visualizations > drillthroughs > table_drills", () => {
resultText: "July 31, 2025",
});
});
-
- it("should allow timeseries pivot drills on multi-stage queries (metabase#52236)", () => {
- pivotDrillTest({
- query: queryWithJoinThenFilter,
- drillCellText: "3,976",
- menuItems: ["Time", "Products", "Created At"],
- filterText: "Products → Category is Doohickey",
- resultText: "July 31, 2025",
- });
- });
});
describe("native query", () => {
diff --git a/e2e/test/scenarios/visualizations-tabular/pivot_tables.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/pivot_tables.cy.spec.js
index a4640df90b6..340f5d49a23 100644
--- a/e2e/test/scenarios/visualizations-tabular/pivot_tables.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/pivot_tables.cy.spec.js
@@ -486,80 +486,6 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {
);
});
- describe("custom columns (metabase#14604)", () => {
- it("should work with custom columns as values", () => {
- H.visitQuestionAdhoc({
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": ORDERS_ID,
- expressions: {
- "Twice Total": ["*", ["field", ORDERS.TOTAL, null], 2],
- },
- aggregation: [
- ["sum", ["field", ORDERS.TOTAL, null]],
- ["sum", ["expression", "Twice Total"]],
- ],
- breakout: [
- ["field", ORDERS.CREATED_AT, { "temporal-unit": "year" }],
- ],
- },
- type: "query",
- },
- display: "pivot",
- });
-
- // value headings
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Sum of Total");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Sum of Twice Total");
-
- // check values in the table
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("42,156.87"); // sum of total for 2025
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("84,313.74"); // sum of "twice total" for 2025
-
- // check grand totals
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("1,510,621.68"); // sum of total grand total
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("3,021,243.37"); // sum of "twice total" grand total
- });
-
- it("should work with custom columns as pivoted columns", () => {
- H.visitQuestionAdhoc({
- dataset_query: {
- type: "query",
- query: {
- "source-table": PRODUCTS_ID,
- expressions: {
- category_foo: [
- "concat",
- ["field", PRODUCTS.CATEGORY, null],
- "foo",
- ],
- },
- aggregation: [["count"]],
- breakout: [["expression", "category_foo"]],
- },
- database: SAMPLE_DB_ID,
- },
- display: "pivot",
- });
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("category_foo");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Doohickeyfoo");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("42"); // count of Doohickeyfoo
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("200"); // grand total
- });
- });
-
describe("dashboards", () => {
it("should be scrollable even when tiny (metabase#24678)", () => {
H.createQuestionAndDashboard({
@@ -821,32 +747,6 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {
H.popover().findByText(HINT_TEXT).should("not.exist");
});
- it("should work for user without data permissions (metabase#14989)", () => {
- cy.request("POST", "/api/card", {
- name: "14989",
- dataset_query: {
- database: SAMPLE_DB_ID,
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- breakout: [
- ["datetime-field", ["field-id", PRODUCTS.CREATED_AT], "year"],
- ["field-id", PRODUCTS.CATEGORY],
- ],
- },
- type: "query",
- },
- display: "pivot",
- visualization_settings: {},
- }).then(({ body: { id: QUESTION_ID } }) => {
- cy.signIn("nodata");
- H.visitQuestion(QUESTION_ID);
- });
- cy.findAllByTestId("pivot-table-cell").contains("Grand totals");
- cy.findAllByTestId("pivot-table-cell").contains("Row totals");
- cy.findAllByTestId("pivot-table-cell").contains("200");
- });
-
it("should work with custom mapping of display values (metabase#14985)", () => {
cy.intercept("POST", "/api/dataset/pivot").as("datasetPivot");
@@ -1230,52 +1130,6 @@ describe("scenarios > visualizations > pivot tables", { tags: "@slow" }, () => {
H.main().findByText("User → Address").should("be.visible");
});
- it("should return the same number of rows when running as an ad-hoc query vs a saved card (metabase#34278)", () => {
- const query = {
- type: "query",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PRODUCTS.CATEGORY, { "base-type": "type/Text" }],
- ["field", PRODUCTS.EAN, { "base-type": "type/Text" }],
- ],
- },
- database: SAMPLE_DB_ID,
- };
-
- H.visitQuestionAdhoc({
- dataset_query: query,
- display: "pivot",
- visualization_settings: {
- "pivot_table.column_split": {
- rows: ["CATEGORY", "EAN"],
- columns: [],
- values: ["count"],
- },
- },
- });
-
- cy.findByTestId("question-row-count").should(
- "have.text",
- "Showing 205 rows",
- );
-
- H.saveQuestion(undefined, undefined, {
- path: ["Our analytics"],
- });
- cy.wait("@createCard");
- cy.url().should("include", "/question/");
- cy.intercept("POST", "/api/card/pivot/*/query").as("cardPivotQuery");
- cy.reload();
- cy.wait("@cardPivotQuery");
-
- cy.findByTestId("question-row-count").should(
- "have.text",
- "Showing 205 rows",
- );
- });
-
describe("issue 37380", () => {
beforeEach(() => {
const categoryField = [
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.js
index 0a06d30789d..2ec6a4b11bc 100644
--- a/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/visualizations-tabular-reproductions.cy.spec.js
@@ -8,61 +8,6 @@ import { ADMIN_USER_ID } from "e2e/support/cypress_sample_instance_data";
const { ORDERS, ORDERS_ID, PEOPLE, PEOPLE_ID, PRODUCTS, PRODUCTS_ID } =
SAMPLE_DATABASE;
-describe("issue 6010", () => {
- const createMetric = () => {
- return H.createQuestion({
- name: "Metric",
- description: "Metric with a filter",
- type: "metric",
- query: {
- "source-table": ORDERS_ID,
- filter: [">", ORDERS.TOTAL, 150],
- aggregation: [["count"]],
- },
- });
- };
-
- const createQuestion = (metric_id) => {
- return H.createQuestion({
- name: "Question",
- display: "line",
- query: {
- "source-table": ORDERS_ID,
- breakout: [["field", ORDERS.CREATED_AT, { "temporal-unit": "month" }]],
- aggregation: [["metric", metric_id]],
- },
- visualization_settings: {
- "graph.dimensions": ["CREATED_AT"],
- "graph.metrics": ["count"],
- },
- });
- };
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("POST", "/api/dataset").as("dataset");
- });
-
- it("should apply the filter from a metric when drilling through (metabase#6010)", () => {
- createMetric()
- .then(({ body: { id } }) => createQuestion(id))
- .then(({ body: { id } }) => H.visitQuestion(id));
-
- // Metric filters are transformed into aggregation case expression condition. The 21st point is first non filtered
- // point.
- H.cartesianChartCircle().eq(21).click();
-
- H.popover().findByText("See these Orders").click();
- cy.wait("@dataset");
-
- cy.findByTestId("qb-filters-panel").within(() => {
- cy.findByText("Created At: Month is Jan 1–31, 2027").should("be.visible");
- });
- // FIXME metrics v2 -- check that the values in column Total are above 150
- });
-});
-
describe("issue 11249", () => {
const questionDetails = {
name: "13960",
@@ -252,62 +197,6 @@ describe("issue 18976, 18817", () => {
});
});
-describe("issue 19373", { tags: "@skip" }, () => {
- const questiondDetails = {
- name: "Products, Distinct values of Rating, Grouped by Category and Created At (year)",
- query: {
- "source-table": PRODUCTS_ID,
- aggregation: [["distinct", ["field", PRODUCTS.RATING, null]]],
- breakout: [
- ["field", PRODUCTS.CATEGORY, null],
- ["field", PRODUCTS.CREATED_AT, { "temporal-unit": "year" }],
- ],
- },
- };
-
- const ROW_TOTALS_INDEX = 4;
- const GRAND_TOTALS_INDEX = 4;
-
- beforeEach(() => {
- cy.intercept("POST", "/api/dataset/pivot").as("pivotDataset");
-
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestion(questiondDetails, { visitQuestion: true });
- });
-
- it("should return correct sum of the distinct values in row totals (metabase#19373)", () => {
- // Convert to the pivot table manually to reflect the real-world scenario
- H.openVizTypeSidebar();
- cy.findByTestId("Pivot Table-button").should("be.visible").click();
- cy.wait("@pivotDataset");
-
- cy.findAllByRole("grid").eq(0).as("columnTitles");
- cy.findAllByRole("grid").eq(1).as("rowTitles");
- cy.findAllByRole("grid").eq(2).as("tableCells");
-
- // Sanity check before we start asserting on this column
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.get("@columnTitles")
- .findAllByTestId("pivot-table-cell")
- .eq(ROW_TOTALS_INDEX)
- .should("contain", "Row totals");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.get("@rowTitles")
- .findAllByTestId("pivot-table-cell")
- .eq(GRAND_TOTALS_INDEX)
- .should("contain", "Grand totals");
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- cy.get("@tableCells")
- .findAllByTestId("pivot-table-cell")
- .eq(ROW_TOTALS_INDEX)
- .should("contain", "31");
- });
-});
-
describe("issue 21392", () => {
const TEST_QUERY = {
type: "native",
@@ -786,98 +675,6 @@ describe("issue 42697", () => {
});
});
-describe("issue 14148", { tags: "@external" }, () => {
- const PG_DB_ID = 2;
-
- beforeEach(() => {
- H.restore("postgres-12");
- cy.signInAsAdmin();
- });
-
- it("postgres should display pivot tables (metabase#14148)", () => {
- H.withDatabase(PG_DB_ID, ({ PEOPLE, PEOPLE_ID }) =>
- H.visitQuestionAdhoc(
- {
- display: "pivot",
- dataset_query: {
- type: "query",
- database: PG_DB_ID,
- query: {
- "source-table": PEOPLE_ID,
- aggregation: [["count"]],
- breakout: [
- ["field", PEOPLE.SOURCE, null],
- ["field", PEOPLE.CREATED_AT, { "temporal-unit": "year" }],
- ],
- },
- },
- },
- {
- callback: (xhr) =>
- expect(xhr.response.body.cause || "").not.to.contain("ERROR"),
- },
- ),
- );
-
- cy.log(
- "Reported failing on v0.38.0-rc1 querying Postgres, Redshift and BigQuery. It works on MySQL and H2.",
- );
-
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText(/Grand totals/i);
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("2,500");
- });
-});
-
-describe("issue 25415", { tags: "@skip" }, () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should allow to drill-through aggregated query with a custom column on top level (metabase#25415)", () => {
- H.createQuestion(
- {
- name: "Aggregated query with custom column",
- display: "line",
- query: {
- "source-query": {
- "source-table": ORDERS_ID,
- aggregation: [["count"]],
- breakout: [["field", ORDERS.PRODUCT_ID, null]],
- limit: 2,
- },
- expressions: {
- "test custom": [
- "*",
- [
- "field",
- "count",
- {
- "base-type": "type/Integer",
- },
- ],
- 2,
- ],
- },
- },
- },
- { visitQuestion: true },
- );
-
- cy.get(".dc-tooltip-list").get(".dot").first().click({ force: true });
-
- H.popover().findByText("See these Orders").click();
-
- // filter gets applied
- cy.findByTestId("qb-filters-panel").should("contain", "Product ID is 1");
-
- // there is a table with data
- H.tableInteractive().should("exist");
- });
-});
-
describe("issue 7884", () => {
const oldSourceQuestionDetails = {
native: {
diff --git a/test/metabase/dashboards_rest/api_test.clj b/test/metabase/dashboards_rest/api_test.clj
index 6722c7711a8..02c9f2c519b 100644
--- a/test/metabase/dashboards_rest/api_test.clj
+++ b/test/metabase/dashboards_rest/api_test.clj
@@ -3804,6 +3804,52 @@
(is (= "You don't have permissions to do that."
(mt/user-http-request :rasta :post 403 (url))))))))))))))
+(deftest dashboard-card-query-metric-sourced-from-inaccessible-model-test
+ (testing "POST /api/dashboard/:dashboard-id/dashcard/:dashcard-id/card/:card-id/query with a metric sourced from a model"
+ (testing "runs for a user without collection access to the source model"
+ (mt/with-non-admin-groups-no-root-collection-perms
+ (mt/with-temp [:model/Collection model-coll {}
+ :model/Collection dash-coll {}
+ :model/Card model {:type :model
+ :collection_id (u/the-id model-coll)
+ :dataset_query (let [mp (mt/metadata-provider)]
+ (lib/query mp (lib.metadata/table mp (mt/id :orders))))}
+ :model/Card metric {:type :metric
+ :collection_id (u/the-id dash-coll)
+ :dataset_query (let [mp (mt/metadata-provider)]
+ (-> (lib/query mp (lib.metadata/card mp (u/the-id model)))
+ (lib/aggregate (lib/count))))}
+ :model/Dashboard dashboard {:collection_id (u/the-id dash-coll)}
+ :model/DashboardCard dashcard {:dashboard_id (u/the-id dashboard)
+ :card_id (u/the-id metric)}]
+ (perms/grant-collection-read-permissions! (perms-group/all-users) dash-coll)
+ (is (= [[18760]]
+ (mt/rows (mt/user-http-request :rasta :post 202
+ (dashboard-card-query-url
+ (u/the-id dashboard) (u/the-id metric) (u/the-id dashcard)))))))))
+ (testing "runs for a user without query-building data perms"
+ (mt/with-temp [:model/Collection coll {}
+ :model/Card model {:type :model
+ :collection_id (u/the-id coll)
+ :dataset_query (let [mp (mt/metadata-provider)]
+ (lib/query mp (lib.metadata/table mp (mt/id :orders))))}
+ :model/Card metric {:type :metric
+ :collection_id (u/the-id coll)
+ :dataset_query (let [mp (mt/metadata-provider)]
+ (-> (lib/query mp (lib.metadata/card mp (u/the-id model)))
+ (lib/aggregate (lib/count))))}
+ :model/Dashboard dashboard {:collection_id (u/the-id coll)}
+ :model/DashboardCard dashcard {:dashboard_id (u/the-id dashboard)
+ :card_id (u/the-id metric)}]
+ (perms/grant-collection-read-permissions! (perms-group/all-users) coll)
+ (mt/with-no-data-perms-for-all-users!
+ (data-perms/set-database-permission! (perms-group/all-users) (mt/id) :perms/view-data :unrestricted)
+ (data-perms/set-database-permission! (perms-group/all-users) (mt/id) :perms/create-queries :no)
+ (is (= [[18760]]
+ (mt/rows (mt/user-http-request :rasta :post 202
+ (dashboard-card-query-url
+ (u/the-id dashboard) (u/the-id metric) (u/the-id dashcard)))))))))))
+
;; see also [[metabase.query-processor.dashboard-test]]
(deftest dashboard-card-query-parameters-test
(testing "POST /api/dashboard/:dashboard-id/card/:card-id/query"