The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Consolidate per type dashboard filter e2e specs (#83581)
Nemanja Glumacdc16c798462c
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.tsindex 2b9d671d6f0..c600fc3d0c2 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@@ -20,244 +20,233 @@ const PARAMETER_NAME = "Boolean parameter";const COLUMN_NAME = "Boolean";const FIELD_NAME = "boolean";-describe(- "scenarios > dashboard > filters > number",- { tags: "@external" },- () => {+describe("scenarios > dashboard > filters > boolean", () => {+ describe("mbql queries", () => {beforeEach(() => {- H.restore(`${DIALECT}-writable`);- H.resetTestTable({ type: DIALECT, table: TABLE_NAME });+ H.restore();cy.signInAsAdmin();- H.resyncDatabase({ tableName: TABLE_NAME });});- describe("mbql queries", () => {- it("should allow to map a boolean parameter to a boolean column of an MBQL query and drill-thru", () => {- createQuestionAndDashboard().then(({ dashboardId }) =>- H.visitDashboard(dashboardId),- );- H.editDashboard();- createAndMapParameter();- H.saveDashboard();-- testParameterWidget({- allRowCountText: "200 rows",- trueRowCountText: "1 row",- falseRowCountText: "199 rows",- });-- cy.log("drill-thru");- H.filterWidget().click();- H.popover().button("Add filter").click();- H.getDashboardCard().findByText(QUESTION_NAME).click();- H.assertQueryBuilderRowCount(1);- H.queryBuilderFiltersPanel()- .findByText(`${COLUMN_NAME} is true`)- .should("be.visible");- });-- it("should allow to use a 'Update dashboard filter' click behavior", () => {- createQuestionAndDashboard().then(({ dashboardId }) =>- H.visitDashboard(dashboardId),- );-- cy.log("set up click behavior");- H.editDashboard();- createAndMapParameter();- H.showDashboardCardActions();- cy.findByLabelText("Click behavior").click();- H.sidebar().within(() => {- cy.findByText(COLUMN_NAME).click();- cy.findByText("Update a dashboard filter").click();- cy.findByTestId("unset-click-mappings")- .findByText(PARAMETER_NAME)- .click();- });- H.selectDropdown().findByText(COLUMN_NAME).click();- H.saveDashboard();-- cy.log("assert click behavior");- H.getDashboardCard().findAllByText("true").first().click();- H.filterWidget().findByText("True").should("be.visible");- H.getDashboardCard().findByText("1 row").should("be.visible");- H.getDashboardCard().findAllByText("true").first().click();- H.filterWidget().findByText("True").should("not.exist");- H.getDashboardCard().findByText("200 rows").should("be.visible");- });-- it("should allow to use a 'Go to a custom destination - Saved question' click behavior", () => {- createQuestionAndDashboard().then(({ dashboardId }) =>- H.visitDashboard(dashboardId),- );-- cy.log("set up click behavior");- H.editDashboard();- createAndMapParameter();- H.showDashboardCardActions();- cy.findByLabelText("Click behavior").click();- H.sidebar().within(() => {- cy.findByText(COLUMN_NAME).click();- cy.findByText("Go to a custom destination").click();- cy.findByText("Saved question").click();- });- H.entityPickerModal().findByText(QUESTION_NAME).click();- H.sidebar()- .findByTestId("unset-click-mappings")- .findByText(COLUMN_NAME)+ it("should allow to map a boolean parameter to a boolean column of an MBQL query, update it with a click behavior, and drill-thru", () => {+ createQuestionAndDashboard().then(({ dashboardId }) =>+ H.visitDashboard(dashboardId),+ );+ H.editDashboard();+ createAndMapParameter();+ H.showDashboardCardActions();+ cy.findByLabelText("Click behavior").click();+ H.sidebar().within(() => {+ cy.findByText(COLUMN_NAME).click();+ cy.findByText("Update a dashboard filter").click();+ cy.findByTestId("unset-click-mappings")+ .findByText(PARAMETER_NAME).click();- H.selectDropdown().findByText(COLUMN_NAME).click();- H.saveDashboard();-- cy.log("assert click behavior");- H.getDashboardCard().findAllByText("true").first().click();- H.queryBuilderFiltersPanel()- .findByText(`${COLUMN_NAME} is true`)- .should("be.visible");- H.assertTableRowsCount(1);});-- it("should allow to use a 'Go to a custom destination - Dashboard' click behavior with a column", () => {- setupDashboardClickBehavior({- targetName: COLUMN_NAME,- });-- cy.log("assert click behavior");- H.getDashboardCard().findAllByText("true").first().click();- H.dashboardHeader().findByText(DASHBOARD_NAME).should("be.visible");- H.filterWidget().findByText("True").should("be.visible");+ H.selectDropdown().findByText(COLUMN_NAME).click();+ H.saveDashboard();++ cy.log("'Update a dashboard filter' click behavior");+ H.getDashboardCard().findAllByText("true").first().click();+ H.filterWidget().findByText("True").should("be.visible");+ H.getDashboardCard().findByText("1 row").should("be.visible");+ H.getDashboardCard().findAllByText("true").first().click();+ H.filterWidget().findByText("True").should("not.exist");+ H.getDashboardCard().findByText("200 rows").should("be.visible");++ testParameterWidget({+ allRowCountText: "200 rows",+ trueRowCountText: "1 row",+ falseRowCountText: "199 rows",+ hasBooleanColumn: true,});- it("should allow to use a 'Go to a custom destination - Dashboard' click behavior with a parameter", () => {- setupDashboardClickBehavior({- targetName: PARAMETER_NAME,- });-- cy.log("assert click behavior");- H.filterWidget().click();- H.popover().button("Add filter").click();- H.getDashboardCard().findAllByText("true").first().click();- H.dashboardHeader().findByText(DASHBOARD_NAME).should("be.visible");- H.filterWidget().findByText("True").should("be.visible");+ cy.log("drill-thru");+ H.filterWidget().click();+ H.popover().button("Add filter").click();+ H.getDashboardCard().findByText(QUESTION_NAME).click();+ H.assertQueryBuilderRowCount(1);+ H.queryBuilderFiltersPanel()+ .findByText(`${COLUMN_NAME} is true`)+ .should("be.visible");+ });++ it("should allow to use a 'Go to a custom destination - Saved question' click behavior", () => {+ createQuestionAndDashboard().then(({ dashboardId }) =>+ H.visitDashboard(dashboardId),+ );++ cy.log("set up click behavior");+ H.editDashboard();+ H.showDashboardCardActions();+ cy.findByLabelText("Click behavior").click();+ H.sidebar().within(() => {+ cy.findByText(COLUMN_NAME).click();+ cy.findByText("Go to a custom destination").click();+ cy.findByText("Saved question").click();});+ H.entityPickerModal().findByText(QUESTION_NAME).click();+ H.sidebar()+ .findByTestId("unset-click-mappings")+ .findByText(COLUMN_NAME)+ .click();+ H.selectDropdown().findByText(COLUMN_NAME).click();+ H.saveDashboard();++ cy.log("assert click behavior");+ H.getDashboardCard().findAllByText("true").first().click();+ H.queryBuilderFiltersPanel()+ .findByText(`${COLUMN_NAME} is true`)+ .should("be.visible");+ H.assertTableRowsCount(1);});- describe("native queries with field filters", () => {- it("should allow to map a boolean parameter to a boolean field filter of a SQL query and drill-thru", () => {- createNativeQuestionWithFieldFilterAndDashboard().then(- ({ dashboardId }) => H.visitDashboard(dashboardId),- );- H.editDashboard();- createAndMapParameter();- H.saveDashboard();-- testParameterWidget({- allRowCountText: "2 rows",- trueRowCountText: "1 row",- falseRowCountText: "1 row",- });-- cy.log("drill-thru");- H.filterWidget().click();- H.popover().button("Add filter").click();- H.getDashboardCard().findByText(QUESTION_NAME).click();- H.queryBuilderHeader().findByText(QUESTION_NAME).should("be.visible");- H.assertQueryBuilderRowCount(1);- H.filterWidget().findByText("True").should("be.visible");+ it("should allow to use a 'Go to a custom destination - Dashboard' click behavior with a column or a parameter", () => {+ setupDashboardClickBehavior();++ cy.log("column source passes the clicked value");+ H.getDashboardCard().findAllByText("true").first().click();+ H.dashboardHeader().findByText(DASHBOARD_NAME).should("be.visible");+ H.filterWidget().findByText("True").should("be.visible");+ H.getDashboardCard().findByText("1 row").should("be.visible");++ cy.log(+ "parameter source passes the filter value, not the clicked row's true",+ );+ cy.go("back");+ H.dashboardHeader().findByText(DASHBOARD_2_NAME).should("be.visible");+ H.filterWidget().click();+ H.popover().within(() => {+ cy.findByText("False").click();+ cy.button("Add filter").click();});+ H.getDashboardCard(1).findByText("199 rows").should("be.visible");+ H.getDashboardCard(0).findByText("200 rows").should("be.visible");+ H.getDashboardCard(0).findAllByText("1").first().click();+ H.dashboardHeader().findByText(DASHBOARD_NAME).should("be.visible");+ H.filterWidget().findByText("False").should("be.visible");+ H.getDashboardCard().findByText("199 rows").should("be.visible");+ });+ });- it("should allow to use a 'Go to a custom destination - Saved question' click behavior", () => {- createNativeQuestionWithFieldFilterAndDashboard().then(- ({ dashboardId }) => H.visitDashboard(dashboardId),- );-- cy.log("set up click behavior");- H.editDashboard();- createAndMapParameter();- H.showDashboardCardActions();- cy.findByLabelText("Click behavior").click();- H.sidebar().within(() => {- cy.findByText(FIELD_NAME).click();- cy.findByText("Go to a custom destination").click();- cy.findByText("Saved question").click();- });- H.entityPickerModal().findByText(QUESTION_NAME).click();- H.sidebar()- .findByTestId("unset-click-mappings")- .findByText(COLUMN_NAME)- .click();- H.selectDropdown().findByText(FIELD_NAME).click();- H.saveDashboard();+ describe("native queries with field filters", { tags: "@external" }, () => {+ beforeEach(() => {+ H.restore(`${DIALECT}-writable`);+ H.resetTestTable({ type: DIALECT, table: TABLE_NAME });+ cy.signInAsAdmin();+ H.resyncDatabase({ tableName: TABLE_NAME });+ });- cy.log("assert click behavior");- H.getDashboardCard().findAllByText("true").first().click();- H.assertTableRowsCount(1);- H.filterWidget().findByText("True").should("be.visible");+ it("should allow to map a boolean parameter to a boolean field filter of a SQL query, use it in click behaviors, and drill-thru", () => {+ createNativeQuestionWithFieldFilterAndDashboard().then(+ ({ dashboardId, questionId }) => {+ H.visitDashboard(dashboardId);+ H.editDashboard();+ createAndMapParameter();++ cy.log(+ "set up a saved question click behavior on the boolean column",+ );+ H.showDashboardCardActions();+ cy.findByLabelText("Click behavior").click();+ H.sidebar().within(() => {+ cy.findByText(FIELD_NAME).click();+ cy.findByText("Go to a custom destination").click();+ cy.findByText("Saved question").click();+ });+ H.entityPickerModal().findByText(QUESTION_NAME).click();+ H.sidebar()+ .findByTestId("unset-click-mappings")+ .findByText(COLUMN_NAME)+ .click();+ H.selectDropdown().findByText(FIELD_NAME).click();++ cy.log("set up a URL click behavior on the id column");+ H.sidebar().icon("chevronleft").click();+ H.sidebar().within(() => {+ cy.findByText("id").click();+ cy.findByText("Go to a custom destination").click();+ cy.findByText("URL").click();+ });+ H.modal().within(() => {+ cy.findByPlaceholderText(+ "e.g. http://acme.com/id/{{user_id}}",+ ).type(+ `http://localhost:4000/question/${questionId}?boolean={{${FIELD_NAME}}}`,+ { parseSpecialCharSequences: false },+ );+ cy.button("Done").click();+ });+ H.saveDashboard();+ },+ );++ cy.log("assert the saved question click behavior");+ H.getDashboardCard().findAllByText("true").first().click();+ H.assertTableRowsCount(1);+ H.filterWidget().findByText("True").should("be.visible");++ cy.log("assert the URL click behavior with the second row's value");+ cy.go("back");+ H.getDashboardCard().findByText("2").click();+ H.assertTableRowsCount(1);+ H.filterWidget().findByText("False").should("be.visible");++ cy.go("back");+ H.dashboardHeader().findByText(DASHBOARD_NAME).should("be.visible");+ testParameterWidget({+ allRowCountText: "2 rows",+ trueRowCountText: "1 row",+ falseRowCountText: "1 row",+ hasBooleanColumn: true,});- it("should allow to use a 'Go to a custom destination - URL' click behavior", () => {- createNativeQuestionWithFieldFilterAndDashboard().then(- ({ dashboardId, questionId }) => {- H.visitDashboard(dashboardId);-- cy.log("set up click behavior");- H.editDashboard();- createAndMapParameter();- H.showDashboardCardActions();- cy.findByLabelText("Click behavior").click();- H.sidebar().within(() => {- cy.findByText(FIELD_NAME).click();- cy.findByText("Go to a custom destination").click();- cy.findByText("URL").click();- });- H.modal().within(() => {- cy.findByPlaceholderText(- "e.g. http://acme.com/id/{{user_id}}",- ).type(- `http://localhost:4000/question/${questionId}?boolean={{${FIELD_NAME}}}`,- { parseSpecialCharSequences: false },- );- cy.button("Done").click();- });- H.saveDashboard();-- cy.log("assert click behavior");- H.getDashboardCard().findAllByText("true").first().click();- H.assertTableRowsCount(1);- H.filterWidget().findByText("True").should("be.visible");- },- );- });+ cy.log("drill-thru");+ H.filterWidget().click();+ H.popover().button("Add filter").click();+ H.getDashboardCard().findByText(QUESTION_NAME).click();+ H.queryBuilderHeader().findByText(QUESTION_NAME).should("be.visible");+ H.assertQueryBuilderRowCount(1);+ H.filterWidget().findByText("True").should("be.visible");});+ });- describe("native queries with variables", () => {- it("should allow to map a boolean parameter to a boolean variable of a SQL query and drill-thru", () => {- createNativeQuestionWithVariableAndDashboard().then(({ dashboardId }) =>- H.visitDashboard(dashboardId),- );- H.editDashboard();- createAndMapParameter();- H.saveDashboard();-- testParameterWidget({- allRowCountText: "200 rows",- trueRowCountText: "53 rows",- falseRowCountText: "54 rows",- });-- H.filterWidget().click();- H.popover().button("Add filter").click();- H.getDashboardCard().findByText(QUESTION_NAME).click();- H.queryBuilderHeader().findByText(QUESTION_NAME).should("be.visible");- H.assertQueryBuilderRowCount(53);- H.filterWidget().findByText("True").should("be.visible");+ describe("native queries with variables", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should allow to map a boolean parameter to a boolean variable of a SQL query and drill-thru", () => {+ createNativeQuestionWithVariableAndDashboard().then(({ dashboardId }) =>+ H.visitDashboard(dashboardId),+ );+ H.editDashboard();+ createAndMapParameter();+ H.saveDashboard();++ testParameterWidget({+ allRowCountText: "200 rows",+ trueRowCountText: "53 rows",+ falseRowCountText: "54 rows",+ hasBooleanColumn: false,});++ H.filterWidget().click();+ H.popover().button("Add filter").click();+ H.getDashboardCard().findByText(QUESTION_NAME).click();+ H.queryBuilderHeader().findByText(QUESTION_NAME).should("be.visible");+ H.assertQueryBuilderRowCount(53);+ H.filterWidget().findByText("True").should("be.visible");});- },-);+ });+});function createQuestionAndDashboard({questionName = QUESTION_NAME,dashboardName = DASHBOARD_NAME,+}: {+ questionName?: string;+ dashboardName?: string;} = {}) {const questionDetails: StructuredQuestionDetails = {name: questionName,@@ -359,14 +348,15 @@ function createNativeQuestionWithVariableAndDashboard() {function createAndMapParameter({columnName = COLUMN_NAME,parameterName = PARAMETER_NAME,+ dashcardIndex = 0,} = {}) {cy.log("parameter mapping");H.setFilter("Boolean", undefined, parameterName);- H.selectDashboardFilter(H.getDashboardCard(), columnName);+ H.selectDashboardFilter(H.getDashboardCard(dashcardIndex), columnName);H.dashboardParametersDoneButton().click();}-function setupDashboardClickBehavior({ targetName }: { targetName: string }) {+function setupDashboardClickBehavior() {cy.log("setup target dashboard");createQuestionAndDashboard({dashboardName: DASHBOARD_NAME,@@ -378,44 +368,80 @@ function setupDashboardClickBehavior({ targetName }: { targetName: string }) {H.saveDashboard();});- cy.log("set up click behavior");+ cy.log(+ "set up click behavior on an unfiltered card, with the parameter mapped to a second card",+ );createQuestionAndDashboard({dashboardName: DASHBOARD_2_NAME,questionName: QUESTION_2_NAME,- }).then(({ dashboardId }) => {+ }).then(({ dashboardId, questionId }) => {+ H.updateDashboardCards({+ dashboard_id: dashboardId,+ cards: [{ card_id: questionId }, { card_id: questionId, col: 12 }],+ });H.visitDashboard(dashboardId);H.editDashboard();- createAndMapParameter();- H.showDashboardCardActions();- cy.findByLabelText("Click behavior").click();- H.sidebar().within(() => {- cy.findByText(COLUMN_NAME).click();- cy.findByText("Go to a custom destination").click();- cy.findByText("Dashboard").click();+ createAndMapParameter({ dashcardIndex: 1 });+ H.showDashboardCardActions(0);+ H.getDashboardCard(0).findByLabelText("Click behavior").click();+ addDashboardDestination({+ columnName: COLUMN_NAME,+ sourceName: COLUMN_NAME,});- H.entityPickerModal().within(() => {- cy.findByText(DASHBOARD_NAME).click();+ H.sidebar().icon("chevronleft").click();+ addDashboardDestination({+ columnName: "ID",+ sourceName: PARAMETER_NAME,});- H.sidebar().findByText(PARAMETER_NAME).click();- H.selectDropdown().findByText(targetName).click();H.saveDashboard();});}+function addDashboardDestination({+ columnName,+ sourceName,+}: {+ columnName: string;+ sourceName: string;+}) {+ H.sidebar().within(() => {+ cy.findByText(columnName).click();+ cy.findByText("Go to a custom destination").click();+ cy.findByText("Dashboard").click();+ });+ H.entityPickerModal().within(() => {+ cy.findByText(DASHBOARD_NAME).click();+ });+ H.sidebar().findByText(PARAMETER_NAME).click();+ H.selectDropdown().findByText(sourceName).click();+}+function testParameterWidget({allRowCountText,trueRowCountText,falseRowCountText,+ hasBooleanColumn,}: {allRowCountText: string;trueRowCountText: string;falseRowCountText: string;+ hasBooleanColumn: boolean;}) {+ const assertBooleanCells = (value: boolean) => {+ if (hasBooleanColumn) {+ H.getDashboardCard().within(() => {+ cy.findAllByText(String(value)).first().should("be.visible");+ cy.findByText(String(!value)).should("not.exist");+ });+ }+ };+cy.log("parameter widget");H.getDashboardCard().findByText(allRowCountText).should("be.visible");H.filterWidget().click();H.popover().button("Add filter").click();H.getDashboardCard().findByText(trueRowCountText).should("be.visible");+ assertBooleanCells(true);H.filterWidget().icon("close").click();H.getDashboardCard().findByText(allRowCountText).should("be.visible");H.filterWidget().click();@@ -424,11 +450,13 @@ function testParameterWidget({cy.findByText("Add filter").click();});H.getDashboardCard().findByText(falseRowCountText).should("be.visible");+ assertBooleanCells(false);H.filterWidget().click();H.popover().within(() => {cy.findByText("True").click();cy.findByText("Update filter").click();});H.getDashboardCard().findByText(trueRowCountText).should("be.visible");+ assertBooleanCells(true);H.filterWidget().icon("close").click();}diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-date.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-date.cy.spec.jsindex cefbf67fc0b..dd5683ef67e 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-date.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-date.cy.spec.js@@ -10,17 +10,13 @@ import { DASHBOARD_DATE_FILTERS } from "./shared/dashboard-filters-date";describe("scenarios > dashboard > filters > date", () => {beforeEach(() => {- cy.intercept("GET", "/api/table/*/query_metadata").as("metadata");-H.restore();cy.signInAsAdmin();-- H.visitDashboard(ORDERS_DASHBOARD_ID);-- H.editDashboard();});it("should work when set through the filter widget", () => {+ visitOrdersDashboardInEditMode();+// Add and connect every single available date filter typeObject.entries(DASHBOARD_DATE_FILTERS).forEach(([filter]) => {cy.log(`Make sure we can connect ${filter} filter`);@@ -31,6 +27,7 @@ describe("scenarios > dashboard > filters > date", () => {});H.saveDashboard();+ cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);// Go through each of the filters and make sure they work individuallyObject.entries(DASHBOARD_DATE_FILTERS).forEach(@@ -42,11 +39,12 @@ describe("scenarios > dashboard > filters > date", () => {filterType: filter,filterValue: value,});+ cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);cy.log(`Make sure ${filter} filter returns correct result`);- cy.findByTestId("dashcard").within(() => {- cy.findByText(representativeResult);- });+ cy.findByTestId("dashcard")+ .should("contain", representativeResult)+ .and("not.contain", "39.72");H.clearFilterWidget(index);cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);@@ -54,38 +52,28 @@ describe("scenarios > dashboard > filters > date", () => {);});- // Rather than going through every single filter type,- // make sure the default filter works for just one of the available options- 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();+ it("should support being required", () => {+ visitOrdersDashboardInEditMode();- DateFilter.setMonthAndYear({- month: "Nov",- year: "2025",+ cy.log("show sub-day resolutions in relative date filter (metabase#6660)");+ H.setFilter("Date picker", "All Options");+ H.dashboardParameterSidebar().findByText("No default").click();+ H.popover().within(() => {+ cy.findByText("Relative date range…").click();+ cy.findByText("Next").click();+ cy.findByDisplayValue("days").click();});-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Select…").click();- H.popover().contains("Created At").first().click();-- H.saveDashboard();-- // The default value should immediately be applied- cy.findByTestId("dashcard").within(() => {- cy.findByText("85.88");+ H.selectDropdown().within(() => {+ cy.findByText("hours").should("be.visible");+ cy.findByText("minutes").click();});+ H.popover()+ .findByLabelText(/Include this minute/)+ .should("not.be.checked")+ .click()+ .should("be.checked");+ H.dashboardParameterSidebar().button("Remove").click();- // Make sure we can override the default value- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("November 2025").click();- H.popover().contains("Jun").click();- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("33.9");- });-- it("should support being required", () => {H.setFilter("Date picker", "Month and Year", "Month and Year");// Can't save without a default value@@ -114,44 +102,18 @@ describe("scenarios > dashboard > filters > date", () => {H.selectDashboardFilter(cy.findByTestId("dashcard"), "Created At");H.saveDashboard();+ H.ensureDashboardCardHasText("27.74");+// Updates the filter valueH.filterWidget().should("contain.text", "November 2026").click();H.popover().findByText("Dec").click();H.filterWidget().findByText("December 2026");- H.ensureDashboardCardHasText("76.83");+ H.getDashboardCard().should("contain", "76.83").and("not.contain", "27.74");// Resets the value back by clicking widget iconH.resetFilterWidgetToDefault();H.filterWidget().findByText("November 2026");- H.ensureDashboardCardHasText("27.74");- });-- it("should show sub-day resolutions in relative date filter (metabase#6660)", () => {- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();-- H.setFilter("Date picker", "All Options");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("No default").click();- // click on Relative date range…, to open the relative date filter type tabs- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Relative date range…").click();- // choose Next, under which the new options should be available- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Next").click();- // click on Days (the default value), which should open the resolution dropdown- cy.findByDisplayValue("days").click();- // Hours should appear in the selection box (don't click it)- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("hours");- // Minutes should appear in the selection box; click it- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("minutes").click();- // also check the "Include this minute" checkbox- // which is actually "Include" followed by "this minute" wrapped in <strong>, so has to be clicked this way- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.contains("Include this minute").click();+ H.getDashboardCard().should("contain", "27.74").and("not.contain", "76.83");});it("correctly serializes exclude filter on non-English locales (metabase#29122)", () => {@@ -184,6 +146,11 @@ describe("scenarios > dashboard > filters > date", () => {});});+function visitOrdersDashboardInEditMode() {+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ H.editDashboard();+}+function dateFilterSelector({ filterType, filterValue } = {}) {switch (filterType) {case "Month and Year":@@ -205,12 +172,13 @@ function dateFilterSelector({ filterType, filterValue } = {}) {cy.findByText("Add filter").click();break;- case "Relative Date":- DateFilter.setRelativeDate(filterValue);- break;-case "All Options":- DateFilter.setAdHocFilter(filterValue);+ H.popover().within(() => {+ cy.findByText("Fixed date range…").click();+ cy.findByText("Before").click();+ cy.findByLabelText("Date").clear().type(filterValue).blur();+ cy.button("Add filter").click();+ });break;default:diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-id.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-id.cy.spec.jsindex b6976860cc4..c50fcee91d1 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-id.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-id.cy.spec.js@@ -3,6 +3,34 @@ import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";import { addWidgetStringFilter } from "../native/helpers/e2e-field-filter-helpers";+const ID_FILTERS = [+ {+ name: "Order ID",+ selectColumn: () => H.popover().contains("ID").first().click(),+ value: "15",+ representativeResult: "114.42",+ },+ {+ name: "User ID",+ selectColumn: () => H.popover().contains("User ID").click(),+ value: "4",+ representativeResult: "47.68",+ remappedValue: "Arnold Adams - 4",+ },+ {+ name: "Product ID",+ // There are three of these, and the order is fixed:+ // "own" column first, then implicit join on People and User alphabetically.+ // We select index 1 to get the Product.ID.+ selectColumn: () =>+ H.popover().within(() => {+ cy.findAllByText("ID").eq(1).click();+ }),+ value: "10",+ representativeResult: "6.75",+ },+];+describe("scenarios > dashboard > filters > ID", () => {beforeEach(() => {H.restore();@@ -11,10 +39,6 @@ describe("scenarios > dashboard > filters > ID", () => {H.visitDashboard(ORDERS_DASHBOARD_ID);H.editDashboard();- H.setFilter("ID");-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Select…").click();/*** Even though we're already intercepting this route in the visitDashboard helper,@@ -29,100 +53,78 @@ describe("scenarios > dashboard > filters > ID", () => {);});- describe("should work for the primary key", () => {- beforeEach(() => {- H.popover().contains("ID").first().click();- });-- it("when set through the filter widget", () => {- H.saveDashboard();- cy.wait("@dashboardData");-- H.filterWidget().click();- addWidgetStringFilter("15");- cy.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("dashcard").should("contain", "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.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("dashcard").should("contain", "114.42");- });+ it("should work for the primary key, the foreign key and the implicit join when set through the filter widget", () => {+ ID_FILTERS.forEach((filter) => addIdFilter(filter));++ H.saveDashboard();+ cy.wait("@dashboardData");++ ID_FILTERS.forEach(+ ({ name, value, representativeResult, remappedValue }, index) => {+ cy.log(name);+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(index).click();+ addWidgetStringFilter(value);+ cy.wait("@dashboardData");+ cy.findByTestId("loading-indicator").should("not.exist");++ assertDashcardResult(representativeResult);+ if (remappedValue) {+ H.filterWidget({ name }).should("contain", remappedValue);+ }++ H.clearFilterWidget(index);+ cy.wait("@dashboardData");+ },+ );});- describe("should work for the foreign key", () => {- beforeEach(() => {- H.popover().contains("User ID").click();- });-- it("when set through the filter widget", () => {- H.saveDashboard();- cy.wait("@dashboardData");-- H.filterWidget().click();- addWidgetStringFilter("4");- cy.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("dashcard").should("contain", "47.68");- H.checkFilterLabelAndValue("ID", "Arnold Adams - 4");- });-- it("when set as the default filter", () => {- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ it("should work for the primary key, the foreign key and the implicit join when set as the default filter", () => {+ ID_FILTERS.forEach((filter) => {+ addIdFilter(filter);cy.findByText("Default value").next().click();- addWidgetStringFilter("4");-- H.saveDashboard();- cy.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("dashcard").should("contain", "47.68");- H.checkFilterLabelAndValue("ID", "Arnold Adams - 4");- });- });-- describe("should work on the implicit join", () => {- beforeEach(() => {- H.popover().within(() => {- // There are three of these, and the order is fixed:- // "own" column first, then implicit join on People and User alphabetically.- // We select index 1 to get the Product.ID.- cy.findAllByText("ID").eq(1).click();- });+ addWidgetStringFilter(filter.value);});- it("when set through the filter widget", () => {- H.saveDashboard();- cy.wait("@dashboardData");-- H.filterWidget().click();- addWidgetStringFilter("10");- cy.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");+ H.saveDashboard();+ cy.wait("@dashboardData");+ cy.findByTestId("loading-indicator").should("not.exist");++ ID_FILTERS.forEach(+ ({ name, representativeResult, remappedValue }, index) => {+ cy.log(name);+ const otherIndexes = ID_FILTERS.map((_, i) => i).filter(+ (i) => i !== index,+ );++ otherIndexes.forEach((otherIndex) => {+ H.clearFilterWidget(otherIndex);+ cy.wait("@dashboardData");+ });++ assertDashcardResult(representativeResult);+ if (remappedValue) {+ H.filterWidget({ name }).should("contain", remappedValue);+ }++ otherIndexes.forEach((otherIndex) => {+ H.resetFilterWidgetToDefault(otherIndex);+ cy.wait("@dashboardData");+ });+ },+ );+ });+});- cy.findByTestId("dashcard").should("contain", "6.75");- });+function addIdFilter({ name, selectColumn }) {+ H.setFilter("ID", undefined, name);- 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("10");+ cy.findByText("Select…").click();+ selectColumn();+}- H.saveDashboard();- cy.wait("@dashboardData");- cy.findByTestId("loading-indicator").should("not.exist");-- cy.findByTestId("dashcard").should("contain", "6.75");- });- });-});+function assertDashcardResult(representativeResult) {+ cy.findByTestId("dashcard")+ .should("contain", representativeResult)+ .and("not.contain", "39.72");+}diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-location.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-location.cy.spec.jsindex 966e4eed858..fadf6275657 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-location.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-location.cy.spec.js@@ -21,48 +21,48 @@ describe("scenarios > dashboard > filters > location", () => {H.editDashboard();});- it("should work when set through the filter widget", () => {- Object.entries(DASHBOARD_LOCATION_FILTERS).forEach(([filter]) => {+ it("should work when set through the filter widget or as the default filter", () => {+ Object.entries(DASHBOARD_LOCATION_FILTERS).forEach(([filter], index) => {cy.log(`Make sure we can connect ${filter} filter`);H.setFilter("Location", filter);cy.findByText("Select…").click();H.popover().contains("City").click();++ if (index === 0) {+ cy.findByText("Default value").next().click();+ selectFilterValueFromList(DASHBOARD_LOCATION_FILTERS[filter].value);+ }});H.saveDashboard();+ cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);++ cy.log("Make sure the default filter value is applied");+ cy.findByTestId("dashcard")+ .should("contain", DASHBOARD_LOCATION_FILTERS.Is.representativeResult)+ .and("not.contain", "39.72");+ H.clearFilterWidget(0);+ cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);+ cy.findByTestId("dashcard").should("contain", "39.72");Object.entries(DASHBOARD_LOCATION_FILTERS).forEach(([filter, { value, representativeResult }], index) => {// eslint-disable-next-line metabase/no-unsafe-element-filteringH.filterWidget().eq(index).click();- addWidgetStringFilter(value);+ // The "Is" value matches its default, so the widget offers "Set to default"+ addWidgetStringFilter(value, {+ buttonLabel: index === 0 ? "Set to default" : "Add filter",+ });+ cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);cy.log(`Make sure ${filter} filter returns correct result`);- cy.findByTestId("dashcard").within(() => {- cy.contains(representativeResult);- });+ cy.findByTestId("dashcard")+ .should("contain", representativeResult)+ .and("not.contain", "39.72");H.clearFilterWidget(index);cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`);},);});-- 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("City").click();-- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Default value").next().click();-- selectFilterValueFromList("Abbeville");-- H.saveDashboard();-- cy.findByTestId("dashcard").within(() => {- cy.contains("1510");- });- });});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.jsindex f1c78117e56..eb6604170d3 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@@ -16,120 +16,107 @@ describe("scenarios > dashboard > filters", { tags: "@slow" }, () => {beforeEach(() => {H.restore();cy.signInAsAdmin();- cy.intercept("POST", "/api/dataset").as("dataset");});- describe("static list source (dropdown)", () => {- it("should be able to use a static list source", () => {- H.createQuestionAndDashboard({- questionDetails: targetQuestion,- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });-- H.editDashboard();- H.setFilter("Number", "Equal to", "Number");- mapFilterToQuestion();- H.setFilterListSource({- values: [["10", "Ten"], ["20", "Twenty"], "30"],- });- H.saveDashboard();-- filterDashboard({ isDropdown: true });- H.filterWidget().findByText("Twenty").should("be.visible");- H.getDashboardCard().findByText("4").should("be.visible");+ it("should be able to use a static list source with a dropdown or a search box", () => {+ H.createQuestionAndDashboard({+ questionDetails: targetQuestion,+ }).then(({ body: { dashboard_id } }) => {+ H.visitDashboard(dashboard_id);});- });- describe("static list source (search)", () => {- it("should be able to use a static list source (search)", () => {- H.createQuestionAndDashboard({- questionDetails: targetQuestion,- }).then(({ body: { dashboard_id } }) => {- H.visitDashboard(dashboard_id);- });-- H.editDashboard();- H.setFilter("Number", "Equal to", "Number");- mapFilterToQuestion();- H.sidebar().findByText("Search box").click();- H.setFilterListSource({- values: [["10", "Ten"], ["20", "Twenty"], "30"],- });- H.saveDashboard();-- filterDashboard({ isLabeled: true });- H.filterWidget().findByText("Twenty").should("be.visible");+ H.editDashboard();+ H.setFilter("Number", "Equal to", "Number");+ mapFilterToQuestion();+ H.setFilterListSource({+ values: [["10", "Ten"], ["20", "Twenty"], "30"],+ });+ H.setFilter("Number", "Equal to", "Number search");+ mapFilterToQuestion();+ H.sidebar().findByText("Search box").click();+ H.setFilterListSource({+ values: [["10", "Ten"], ["20", "Twenty"], "30"],});+ H.saveDashboard();++ cy.log("dropdown");+ filterDashboard({ index: 0, isDropdown: true });++ H.filterWidget().eq(0).findByText("Twenty").should("be.visible");+ H.getDashboardCard().findByText("4").should("be.visible");+ H.clearFilterWidget(0);+ H.getDashboardCard().findByText("18,760").should("be.visible");++ cy.log("search box");+ filterDashboard({ index: 1, isLabeled: true });++ H.filterWidget().eq(1).findByText("Twenty").should("be.visible");+ H.getDashboardCard().findByText("4").should("be.visible");});- describe("card source (dropdown)", () => {- it("should allow to use a card source with numeric columns and a single value", () => {- cy.log("setup a dashboard");- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();- H.setFilter("Number", "Less than or equal to");- H.selectDashboardFilter(H.getDashboardCard(), "Total");- H.sidebar().findByText("Dropdown list").click();- H.setFilterQuestionSource({ question: "Orders", field: "ID" });- H.saveDashboard();-- cy.log("pick a value without searching");- H.filterWidget().click();- H.popover().within(() => {- cy.findByText("5").click();- cy.button("Add filter").click();- });- H.getDashboardCard().findByText("1 row").should("be.visible");-- cy.log("pick a value with searching");- H.filterWidget().click();- H.popover().within(() => {- cy.findByPlaceholderText("Search the list").type("225");- cy.findByLabelText("5").should("not.exist");- cy.findByText("225").click();- cy.button("Update filter").click();- });- H.getDashboardCard()- .findByText("Showing first 2,000 rows")- .should("be.visible");+ it("should allow to use a card source with numeric columns and single or multiple values", () => {+ cy.log("setup a dashboard");+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ H.editDashboard();+ H.setFilter("Number", "Less than or equal to");+ H.selectDashboardFilter(H.getDashboardCard(), "Total");+ H.sidebar().findByText("Dropdown list").click();+ H.setFilterQuestionSource({ question: "Orders", field: "ID" });+ H.setFilter("Number", "Equal to");+ H.selectDashboardFilter(H.getDashboardCard(), "Quantity");+ H.sidebar().findByText("Dropdown list").click();+ H.setFilterQuestionSource({ question: "Orders", field: "ID" });+ H.saveDashboard();++ cy.log("single value: pick a value without searching");++ H.filterWidget().eq(0).click();+ H.popover().within(() => {+ cy.findByText("5").click();+ cy.button("Add filter").click();});+ H.getDashboardCard().findByText("1 row").should("be.visible");++ cy.log("single value: pick a value with searching");- it("should allow to use a card source with numeric columns and multiple values", () => {- cy.log("setup a dashboard");- H.visitDashboard(ORDERS_DASHBOARD_ID);- H.editDashboard();- H.setFilter("Number", "Equal to");- H.selectDashboardFilter(H.getDashboardCard(), "Quantity");- H.sidebar().findByText("Dropdown list").click();- H.setFilterQuestionSource({ question: "Orders", field: "ID" });- H.saveDashboard();-- cy.log("pick a value without searching");- H.filterWidget().click();- H.popover().within(() => {- cy.findByText("7").click();- cy.findByText("25").click();- cy.button("Add filter").click();- });- H.getDashboardCard().findByText("932 rows").should("be.visible");-- cy.log("pick a value with searching");- H.filterWidget().click();- H.popover().within(() => {- cy.findByLabelText("7").should("be.checked");- cy.findByLabelText("25").should("be.checked");- cy.findByPlaceholderText("Search the list").type("225");- cy.findByLabelText("7").should("not.exist");- cy.findByText("225").click();- cy.button("Update filter").click();- });- H.filterWidget().click();- H.popover().within(() => {- cy.findByLabelText("7").should("be.checked");- cy.findByLabelText("25").should("be.checked");- cy.findByLabelText("225").should("be.checked");- });+ H.filterWidget().eq(0).click();+ H.popover().within(() => {+ cy.findByTestId("5-filter-value").should("be.visible");+ cy.findByPlaceholderText("Search the list").type("20");+ cy.findByTestId("5-filter-value").should("not.exist");+ cy.findByText("20").click();+ cy.button("Update filter").click();+ });+ H.getDashboardCard().within(() => H.assertTableRowsCount(52));+ H.clearFilterWidget(0);++ cy.log("multiple values: pick a value without searching");++ H.filterWidget().eq(1).click();+ H.popover().within(() => {+ cy.findByText("7").click();+ cy.findByText("25").click();+ cy.button("Add filter").click();+ });+ H.getDashboardCard().findByText("932 rows").should("be.visible");++ cy.log("multiple values: pick a value with searching");++ H.filterWidget().eq(1).click();+ H.popover().within(() => {+ cy.findByLabelText("7").should("be.checked");+ cy.findByLabelText("25").should("be.checked");+ cy.findByPlaceholderText("Search the list").type("225");+ cy.findByLabelText("7").should("not.exist");+ cy.findByText("225").click();+ cy.button("Update filter").click();+ });++ H.filterWidget().eq(1).click();+ H.popover().within(() => {+ cy.findByLabelText("7").should("be.checked");+ cy.findByLabelText("25").should("be.checked");+ cy.findByLabelText("225").should("be.checked");});});});@@ -139,8 +126,9 @@ const mapFilterToQuestion = (column = "Quantity") => {H.popover().within(() => cy.findByText(column).click());};-const filterDashboard = ({ isLabeled = false, isDropdown = false } = {}) => {- H.filterWidget().click();+const filterDashboard = ({ index, isLabeled = false, isDropdown = false }) => {+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(index).click();if (isDropdown) {H.popover().within(() => {@@ -160,11 +148,5 @@ const filterDashboard = ({ isLabeled = false, isDropdown = false } = {}) => {// eslint-disable-next-line metabase/no-unsafe-element-filteringH.popover().last().findByText("Twenty").click();H.popover().first().button("Add filter").click();- return;}-- H.popover().within(() => {- cy.findByPlaceholderText("Enter a number").type("20");- cy.button("Add filter").click();- });};diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-number.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-number.cy.spec.jsindex bbfa4c6551d..67a96b460e7 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-number.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-number.cy.spec.js@@ -7,8 +7,6 @@ import { DASHBOARD_NUMBER_FILTERS } from "./shared/dashboard-filters-number";describe("scenarios > dashboard > filters > number", () => {beforeEach(() => {- cy.intercept("GET", "/api/table/*/query_metadata").as("metadata");-H.restore();cy.signInAsAdmin();@@ -44,50 +42,67 @@ describe("scenarios > dashboard > filters > number", () => {H.popover().contains("Tax").click();});+ H.setFilter("Number", "Between");+ H.selectDashboardFilter(H.getDashboardCard(), "Total");+H.saveDashboard();cy.wait("@dashboardData");DASHBOARD_NUMBER_FILTERS.forEach(- ({ operator, value, representativeResult }, index) => {+ ({ operator, value, representativeResult, negativeAssertion }, index) => {// eslint-disable-next-line metabase/no-unsafe-element-filteringH.filterWidget().eq(index).click();addWidgetNumberFilter(value);cy.wait("@dashboardData");cy.log(`Make sure ${operator} filter returns correct result`);- cy.findByTestId("dashcard").should("contain", representativeResult);+ cy.findByTestId("dashcard")+ .should("contain", representativeResult)+ .and("not.contain", negativeAssertion);H.clearFilterWidget(index);cy.wait("@dashboardData");},);- });-- it("should work when set as the default filter", () => {- H.setFilter("Number", "Equal to");- H.selectDashboardFilter(cy.findByTestId("dashcard"), "Tax");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Default value").next().click();-- addWidgetNumberFilter("2.07");-- H.saveDashboard();- cy.wait("@dashboardData");- cy.findByTestId("dashcard")- .should("contain", "37.65")- .and("not.contain", "101.04");+ cy.log("Between filters work without min or max (metabase#54364)");+ const betweenIndex = DASHBOARD_NUMBER_FILTERS.length;+ const getInput = (index) =>+ cy+ .findAllByPlaceholderText("Enter a number")+ .should("have.length", 2)+ .eq(index);+ const getMinInput = () => getInput(0);+ const getMaxInput = () => getInput(1);- H.clearFilterWidget();- cy.wait("@dashboardData");+ cy.log("min only");+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(betweenIndex).click();+ H.popover().within(() => {+ getMinInput().type("150");+ cy.button("Add filter").click();+ });+ H.getDashboardCard().within(() => H.assertTableRowsCount(256));- H.filterWidget().click();- addWidgetNumberFilter("5.27", { buttonLabel: "Update filter" });- cy.wait("@dashboardData");+ cy.log("max only");+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(betweenIndex).click();+ H.popover().within(() => {+ getMinInput().clear();+ getMaxInput().type("20");+ cy.button("Update filter").click();+ });+ H.getDashboardCard().within(() => H.assertTableRowsCount(52));- cy.findByTestId("dashcard")- .should("contain", "101.04")- .and("not.contain", "37.65");+ cy.log("min and max");+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(betweenIndex).click();+ H.popover().within(() => {+ getMinInput().clear().type("150");+ getMaxInput().clear().type("155");+ cy.button("Update filter").click();+ });+ H.getDashboardCard().within(() => H.assertTableRowsCount(166));});it("should support being required", () => {@@ -116,7 +131,7 @@ describe("scenarios > dashboard > filters > number", () => {H.saveDashboard();cy.wait("@dashboardData");- H.ensureDashboardCardHasText("37.65");+ assertDefaultTaxApplied();// Updates the filter valueH.setFilterWidgetValue("5.27", "Enter a number");@@ -127,54 +142,24 @@ describe("scenarios > dashboard > filters > number", () => {H.resetFilterWidgetToDefault();H.filterWidget().findByText("2.07");cy.wait("@dashboardData");- H.ensureDashboardCardHasText("37.65");+ assertDefaultTaxApplied();// Removing value resets back to default+ H.setFilterWidgetValue("5.27", "Enter a number");+ cy.wait("@dashboardData");+ H.ensureDashboardCardHasText("95.77");H.setFilterWidgetValue(null, "Enter a number", {buttonLabel: "Set to default",});+ cy.wait("@dashboardData");H.filterWidget().findByText("2.07");- H.ensureDashboardCardHasText("37.65");- });-- it("should allow between filters without min or max (metabase#54364)", () => {- const getInput = (index) =>- cy- .findAllByPlaceholderText("Enter a number")- .should("have.length", 2)- .eq(index);-- const getMinInput = () => getInput(0);- const getMaxInput = () => getInput(1);-- H.setFilter("Number", "Between");- H.selectDashboardFilter(H.getDashboardCard(), "Total");- H.saveDashboard();-- cy.log("min only");- H.filterWidget().click();- H.popover().within(() => {- getMinInput().type("150");- cy.button("Add filter").click();- });- H.getDashboardCard().within(() => H.assertTableRowsCount(256));-- cy.log("max only");- H.filterWidget().click();- H.popover().within(() => {- getMinInput().clear();- getMaxInput().type("20");- cy.button("Update filter").click();- });- H.getDashboardCard().within(() => H.assertTableRowsCount(52));-- cy.log("min and max only");- H.filterWidget().click();- H.popover().within(() => {- getMinInput().clear().type("150");- getMaxInput().clear().type("155");- cy.button("Update filter").click();- });- H.getDashboardCard().within(() => H.assertTableRowsCount(166));+ assertDefaultTaxApplied();});});++function assertDefaultTaxApplied() {+ cy.findByTestId("dashcard")+ .should("contain", "37.65")+ .and("not.contain", "110.93")+ .and("not.contain", "95.77");+}diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-management.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-management.cy.spec.jsindex 73a5b93bfad..d6d41547334 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-management.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-management.cy.spec.js@@ -54,12 +54,21 @@ describe("scenarios > dashboard > filters > SQL > management", () => {H.sidebar().findByText("Filter operator").next().click();H.popover().findByText("Between").click();- H.getDashboardCard().should("not.contain", "Column to filter on");+ H.getDashboardCard()+ .should(+ "contain",+ "A number variable in this card can only be connected to a number filter with Equal to operator.",+ )+ .and("not.contain", "Column to filter on");H.sidebar().findByText("Filter operator").next().click();H.popover().findByText("Equal to").click();- H.getDashboardCard().should("not.contain", "Tax GTE");+ H.getDashboardCard()+ .should("contain", "Column to filter on")+ .findByRole("button")+ .should("contain", "Select…")+ .and("not.contain", "Tax GTE");H.saveDashboard();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.jsdeleted file mode 100644index 81d793b3dab..00000000000--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-field-filter.cy.spec.js+++ /dev/null@@ -1,99 +0,0 @@-import { produce } from "immer";--const { H } = cy;-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PRODUCTS } = SAMPLE_DATABASE;--const questionDetails = {- name: "SQL products category, required, 2 selections",- native: {- query: "select distinct category from PRODUCTS where {{filter}}",- "template-tags": {- filter: {- id: "e33dc805-6b71-99a5-ee14-128383953986",- name: "filter",- "display-name": "Filter",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "category",- default: ["Gizmo", "Gadget"],- required: false,- },- },- },-};--const questionDetailsWithRequiredFilter = produce(questionDetails, (draft) => {- draft.native["template-tags"].filter.required = true;-});--const filter = {- name: "Category",- slug: "category",- id: "49fcc65c",- type: "category",- default: "Widget",-};--const dashboardDetails = {- name: "Required Filters Dashboard",- parameters: [filter],-};--describe("scenarios > dashboard > filters > SQL > field filter > required ", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();- });-- it("should respect default filter precedence (dashboard filter, then SQL field filters)", () => {- H.createNativeQuestionAndDashboard({- questionDetails: questionDetailsWithRequiredFilter,- 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);- });-- // Default dashboard filter- cy.location("search").should("eq", "?category=Widget");-- cy.findByTestId("dashcard").as("dashboardCard").contains("Widget");-- H.filterWidget().contains("Widget");-- H.clearFilterWidget();-- cy.location("search").should("eq", "?category=");-- // The default shouldn't apply, so we should get an error- cy.findByTestId("dashcard").contains("Gizmo");-- // The empty filter widget- H.filterWidget().contains("Category");-- cy.reload();-- // This part confirms that the issue metabase#13960 has been fixed- cy.location("search").should("eq", "?category=");- cy.findByTestId("dashcard").contains("Gizmo");-- // Let's make sure the default dashboard filter is respected upon a subsequent visit from the root- cy.visit("/collection/root");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Required Filters Dashboard").click();-- cy.location("search").should("eq", "?category=Widget");- });-});diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-simple-filter.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-simple-filter.cy.spec.jsdeleted file mode 100644index e785355aa9f..00000000000--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required-simple-filter.cy.spec.js+++ /dev/null@@ -1,112 +0,0 @@-const { H } = cy;--const questionDetails = {- name: "Return input value",- native: {- query: "select {{filter}}",- "template-tags": {- filter: {- id: "7182a24e-163a-099c-b085-156f0879aaec",- name: "filter",- "display-name": "Filter",- type: "text",- required: true,- default: "Foo",- },- },- },- display: "scalar",-};--const filter = {- name: "Text",- slug: "text",- id: "904aa8b7",- type: "string/=",- sectionId: "string",- default: "Bar",-};--const dashboardDetails = {- name: "Required Filters Dashboard",- parameters: [filter],-};--describe("scenarios > dashboard > filters > SQL > simple filter > required ", () => {- beforeEach(() => {- H.restore();- cy.signInAsAdmin();-- H.createNativeQuestionAndDashboard({- questionDetails,- dashboardDetails,- }).then(({ body: dashboardCard }) => {- const { card_id, dashboard_id } = dashboardCard;-- const mapFilterToCard = {- parameter_mappings: [- {- parameter_id: filter.id,- card_id,- target: ["variable", ["template-tag", "filter"]],- },- ],- };-- H.editDashboardCard(dashboardCard, mapFilterToCard);-- H.visitDashboard(dashboard_id);- });- });-- it("should respect default filter precedence while properly updating the url for each step of the flow", () => {- // Default dashboard filter- cy.location("search").should("eq", "?text=Bar");-- cy.findByTestId("dashcard").contains("Bar");-- cy.findByDisplayValue("Bar");-- H.clearFilterWidget();-- cy.location("search").should("eq", "?text=");-- // SQL question defaults- cy.findByTestId("dashcard").contains("Foo");-- // The empty filter widget- cy.findByPlaceholderText("Text");-- cy.reload();-- // This part confirms that the issue metabase#13960 has been fixed- cy.location("search").should("eq", "?text=");-- cy.findByTestId("dashcard").contains("Foo");-- // Let's make sure the default dashboard filter is respected upon a subsequent visit from the root- cy.visit("/collection/root");- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage- cy.findByText("Required Filters Dashboard").click();-- cy.location("search").should("eq", "?text=Bar");-- // Finally, when we remove dashboard filter's default value, the url should reflect that by removing the placeholder- H.editDashboard();-- H.filterWidget({ isEditing: true, name: "Text" }).click();-- H.sidebar().within(() => {- removeDefaultFilterValue("Bar");- });-- H.saveDashboard();-- // The URL query params should include the value from the dashboard filter default- cy.location("search").should("eq", "?text=");- });-});--function removeDefaultFilterValue(value) {- cy.findByDisplayValue(value).parent().find(".Icon-close").click();-}diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required.cy.spec.jsnew file mode 100644index 00000000000..47a97b03459--- /dev/null+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-sql-required.cy.spec.js@@ -0,0 +1,164 @@+const { H } = cy;+import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";++const { PRODUCTS } = SAMPLE_DATABASE;++const variableQuestionDetails = {+ name: "Return input value",+ native: {+ query: "select {{filter}}",+ "template-tags": {+ filter: {+ id: "7182a24e-163a-099c-b085-156f0879aaec",+ name: "filter",+ "display-name": "Filter",+ type: "text",+ required: true,+ default: "Foo",+ },+ },+ },+ display: "scalar",+};++const fieldFilterQuestionDetails = {+ name: "SQL products category, required, 2 selections",+ native: {+ query: "select distinct category from PRODUCTS where {{filter}}",+ "template-tags": {+ filter: {+ id: "e33dc805-6b71-99a5-ee14-128383953986",+ name: "filter",+ "display-name": "Filter",+ type: "dimension",+ dimension: ["field", PRODUCTS.CATEGORY, null],+ "widget-type": "category",+ default: ["Gizmo", "Gadget"],+ required: true,+ },+ },+ },+};++const textFilter = {+ name: "Text",+ slug: "text",+ id: "904aa8b7",+ type: "string/=",+ sectionId: "string",+ default: "Bar",+};++const categoryFilter = {+ name: "Category",+ slug: "category",+ id: "49fcc65c",+ type: "category",+ default: "Widget",+};++const dashboardDetails = {+ name: "Required Filters Dashboard",+ parameters: [textFilter, categoryFilter],+};++describe("scenarios > dashboard > filters > SQL > required", () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ });++ it("should respect default filter precedence (dashboard filter, then SQL default) while keeping the url in sync", () => {+ createDashboardWithRequiredFilterCards();++ cy.log("dashboard filter defaults apply");+ cy.location("search").should("eq", "?category=Widget&text=Bar");+ H.getDashboardCard(0).should("contain", "Bar");+ H.getDashboardCard(1)+ .should("contain", "Widget")+ .and("not.contain", "Gizmo");+ cy.findByDisplayValue("Bar").should("be.visible");+ H.filterWidget().eq(1).should("contain", "Widget");++ cy.log("cleared dashboard filters fall back to the SQL defaults");+ H.clearFilterWidget(0);+ H.clearFilterWidget(1);+ cy.location("search").should("eq", "?category=&text=");+ assertSqlDefaultsApplied();+ cy.findByPlaceholderText("Text").should("be.visible");+ H.filterWidget().eq(1).should("contain", "Category");++ cy.log("cleared dashboard filters stay cleared on reload (metabase#13960)");+ cy.reload();+ assertSqlDefaultsApplied();+ cy.location("search").should("eq", "?category=&text=");++ cy.log("dashboard filter defaults apply on a subsequent visit");+ cy.visit("/collection/root");+ // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage+ cy.findByText("Required Filters Dashboard").click();+ cy.location("search").should("eq", "?category=Widget&text=Bar");++ cy.log("removing a dashboard filter default clears it in the url");+ H.editDashboard();+ H.filterWidget({ isEditing: true, name: "Text" }).click();+ H.sidebar().within(() => {+ removeDefaultFilterValue("Bar");+ });+ H.saveDashboard();+ cy.location("search").should("eq", "?category=Widget&text=");+ });+});++function createDashboardWithRequiredFilterCards() {+ H.createDashboard(dashboardDetails).then(({ body: { id: dashboard_id } }) => {+ H.createNativeQuestion(variableQuestionDetails).then(+ ({ body: { id: variableCardId } }) => {+ H.createNativeQuestion(fieldFilterQuestionDetails).then(+ ({ body: { id: fieldFilterCardId } }) => {+ H.updateDashboardCards({+ dashboard_id,+ cards: [+ {+ card_id: variableCardId,+ parameter_mappings: [+ {+ parameter_id: textFilter.id,+ card_id: variableCardId,+ target: ["variable", ["template-tag", "filter"]],+ },+ ],+ },+ {+ card_id: fieldFilterCardId,+ col: 11,+ parameter_mappings: [+ {+ parameter_id: categoryFilter.id,+ card_id: fieldFilterCardId,+ target: ["dimension", ["template-tag", "filter"]],+ },+ ],+ },+ ],+ });+ H.visitDashboard(dashboard_id);+ },+ );+ },+ );+ });+}++function assertSqlDefaultsApplied() {+ H.getDashboardCard(0).should("contain", "Foo");+ H.getDashboardCard(1)+ .should("contain", "Gizmo")+ .and("contain", "Gadget")+ .and("not.contain", "Widget")+ .and("not.contain", "Doohickey");+}++function removeDefaultFilterValue(value) {+ cy.findByDisplayValue(value).parent().find(".Icon-close").click();+}diff --git a/e2e/test/scenarios/dashboard-filters/dashboard-filters-text-category.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-text-category.cy.spec.jsindex 438de0857c9..bfb783a67de 100644--- a/e2e/test/scenarios/dashboard-filters/dashboard-filters-text-category.cy.spec.js+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-text-category.cy.spec.js@@ -30,31 +30,6 @@ describe("scenarios > dashboard > filters > text/category", () => {});});- it("should drill to a question with multi-value 'contains' filter applied (metabase#42999)", () => {- H.setFilter("Text or Category", "Contains");- cy.findAllByRole("radio", { name: "Multiple values" }).should("be.checked");- cy.findByTestId("visualization-root").findByText("Select…").click();- H.popover().contains("Source").click();- H.saveDashboard();- waitDashboardCardQuery();-- H.filterWidget().eq(0).click();- applyFilterByType("Contains", "oo,aa");- waitDashboardCardQuery();-- H.getDashboardCard().findByText("test question").click();-- cy.location("href").should("contain", "/question#");- cy.findByTestId("filter-pill").should(- "contain.text",- "User → Source contains 2 selections",- );- cy.findByTestId("app-bar").should(- "contain.text",- "Started from test question",- );- });-it("should work when set through the filter widget", () => {DASHBOARD_TEXT_FILTERS.forEach(({ operator, single }) => {cy.log(`Make sure we can connect ${operator} filter`);@@ -98,37 +73,29 @@ describe("scenarios > dashboard > filters > text/category", () => {waitDashboardCardQuery();},);- });-- it("should reset filter state when all values are unselected (metabase#25533)", () => {- const filterType = "Is";- const filterValue = "Organic";-- cy.log(`Make sure we can connect '${filterType}' filter`);- H.setFilter("Text or Category", filterType);-- cy.findByTestId("dashcard").findByText("Select…").click();- H.popover().contains("Source").click();- H.saveDashboard();- waitDashboardCardQuery();-- H.filterWidget().click();- applyFilterByType(filterType, filterValue);+ cy.log(+ "drill to a question with multi-value 'contains' filter applied (metabase#42999)",+ );+ const containsIndex = DASHBOARD_TEXT_FILTERS.findIndex(+ ({ operator, single }) => operator === "Contains" && !single,+ );+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(containsIndex).click();+ applyFilterByType("Contains", "oo,aa");waitDashboardCardQuery();- H.filterWidget().click();- cy.log("uncheck all values");-- H.popover().within(() => {- cy.findByText(filterValue).click();- cy.button("Update filter").click();- waitDashboardCardQuery();- });+ H.getDashboardCard().findByText("test question").click();- H.filterWidget().within(() => {- cy.icon("close").should("not.exist");- });+ cy.location("href").should("contain", "/question#");+ cy.findByTestId("filter-pill").should(+ "contain.text",+ "User → Source contains 2 selections",+ );+ cy.findByTestId("app-bar").should(+ "contain.text",+ "Started from test question",+ );});it("should work when set as the default filter which (if cleared) should not be preserved on reload (metabase#13960)", () => {@@ -199,68 +166,108 @@ describe("scenarios > dashboard > filters > text/category", () => {);// Updates the filter value- selectDefaultValueFromPopover("Twitter", { buttonLabel: "Update filter" });+ selectDefaultValueFromPopover("Organic", { buttonLabel: "Update filter" });H.saveDashboard();waitDashboardCardQuery();- H.ensureDashboardCardHasText("37.65");+ assertOrganicOnly();// Resets the value back by clicking widget icon- H.toggleFilterWidgetValues(["Google", "Organic"], {+ H.toggleFilterWidgetValues(["Google", "Twitter"], {buttonLabel: "Update filter",});waitDashboardCardQuery();+ H.ensureDashboardCardHasText("37.65");H.resetFilterWidgetToDefault();waitDashboardCardQuery();- H.filterWidget().findByText("Twitter");+ H.filterWidget().findByText("Organic");+ assertOrganicOnly();// Removing value resets back to default- H.toggleFilterWidgetValues(["Twitter"], {+ H.toggleFilterWidgetValues(["Google", "Twitter"], {+ buttonLabel: "Update filter",+ });+ waitDashboardCardQuery();+ H.ensureDashboardCardHasText("37.65");+ H.toggleFilterWidgetValues(["Organic", "Google", "Twitter"], {buttonLabel: "Set to default",});- H.filterWidget().findByText("Twitter").should("be.visible");+ waitDashboardCardQuery();+ cy.get(H.POPOVER_ELEMENT).should("not.exist");+ H.filterWidget().findByText("Organic").should("be.visible");+ assertOrganicOnly();});- it("should use the list value picker for single-value category filters (metabase#49323)", () => {- H.setFilter("Text or Category", "Is");-+ it("should use the list value picker for single- and multi-value category filters (metabase#49323) and reset when all values are unselected (metabase#25533)", () => {+ H.setFilter("Text or Category", "Is", "Single title");H.selectDashboardFilter(cy.findByTestId("dashcard"), "Title");-H.sidebar().findByText("A single value").click();- H.saveDashboard();-- waitDashboardCardQuery();-- H.filterWidget().contains("Text").click();- H.popover().within(() => {- cy.findByRole("combobox").should("not.exist");- cy.findByText("Aerodynamic Concrete Bench").should("be.visible").click();- cy.findByText("Aerodynamic Bronze Hat").should("be.visible").click();- cy.button("Add filter").click();- });- H.filterWidget().findByText("Aerodynamic Bronze Hat").should("be.visible");- });-- it("should use the list value picker for multi-value category filters (metabase#49323)", () => {- H.setFilter("Text or Category", "Is");+ H.setFilter("Text or Category", "Is", "Multiple titles");H.selectDashboardFilter(cy.findByTestId("dashcard"), "Title");- H.sidebar().findByText("Multiple values").click();+ H.setFilter("Text or Category", "Is", "Source");+ H.selectDashboardFilter(cy.findByTestId("dashcard"), "Source");H.saveDashboard();+ waitDashboardCardQuery();+ cy.log(+ "reset filter state when all values are unselected (metabase#25533)",+ );+ H.filterWidget({ name: "Source" }).click();+ applyFilterByType("Is", "Organic");waitDashboardCardQuery();+ H.filterWidget({ name: "Source" })+ .should("contain", "Organic")+ .icon("close")+ .should("be.visible");- H.filterWidget().contains("Text").click();+ H.filterWidget({ name: "Source" }).click();H.popover().within(() => {- cy.findByRole("combobox").should("not.exist");- cy.findByText("Aerodynamic Concrete Bench").should("be.visible").click();- cy.findByText("Aerodynamic Bronze Hat").should("be.visible").click();- cy.button("Add filter").click();+ cy.findByText("Organic").click();+ cy.button("Update filter").click();+ });+ waitDashboardCardQuery();+ H.filterWidget({ name: "Source" })+ .should("not.contain", "Organic")+ .within(() => {+ cy.icon("close").should("not.exist");+ });+ cy.location("search").should("match", /[?&]source=(&|$)/);++ [+ {+ name: "Single title",+ listTestId: "single-select-list-field",+ widgetText: "Aerodynamic Bronze Hat",+ },+ {+ name: "Multiple titles",+ listTestId: "list-field",+ widgetText: "2 selections",+ },+ ].forEach(({ name, listTestId, widgetText }, index) => {+ cy.log(name);+ H.filterWidget({ name }).click();+ H.popover().within(() => {+ cy.findByTestId(listTestId).should("be.visible");+ cy.findByText("Aerodynamic Concrete Bench").should("be.visible");+ cy.findByRole("combobox").should("not.exist");+ cy.findByText("Aerodynamic Concrete Bench").click();+ cy.findByText("Aerodynamic Bronze Hat").should("be.visible").click();+ cy.button("Add filter").click();+ });+ // eslint-disable-next-line metabase/no-unsafe-element-filtering+ H.filterWidget().eq(index).findByText(widgetText).should("be.visible");});- H.filterWidget().findByText("2 selections").should("be.visible");});});+function assertOrganicOnly() {+ cy.findByTestId("dashcard")+ .should("contain", "39.58")+ .and("not.contain", "37.65");+}+function waitDashboardCardQuery() {cy.get("@dashCardId").then((id) => {cy.wait(`@dashcardQuery${id}`);diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-date.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-date.jsindex 4f109633e0b..b4f5e8e4519 100644--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-date.js+++ b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-date.js@@ -25,9 +25,7 @@ export const DASHBOARD_DATE_FILTERS = {representativeResult: "75.41",},"All Options": {- value: {- timeBucket: "years",- },- representativeResult: "79.37", // this may change every year+ value: "06/01/2025",+ representativeResult: "53.6",},};diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-location.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-location.jsindex d6bc2a17c91..2e97b56ce78 100644--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-location.js+++ b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-location.js@@ -4,16 +4,16 @@ export const DASHBOARD_LOCATION_FILTERS = {representativeResult: "1510",},"Is not": {- value: "Abbeville",- representativeResult: "37.65",+ value: "Wood River",+ representativeResult: "148.23",},Contains: {value: "Abb",representativeResult: "1510",},"Does not contain": {- value: "Abb",- representativeResult: "37.65",+ value: "Wood",+ representativeResult: "148.23",},"Starts with": {value: "Abb",diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-number.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-number.jsindex 26ecac1275e..ed3f2de3239 100644--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-number.js+++ b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-number.js@@ -3,37 +3,38 @@ export const DASHBOARD_NUMBER_FILTERS = [operator: "Equal to",value: "2.07",representativeResult: "37.65",+ negativeAssertion: "110.93",},{operator: "Equal to",value: "2.07",representativeResult: "37.65",+ negativeAssertion: "110.93",single: true,},{operator: "Not equal to",value: "2.07",representativeResult: "110.93",+ negativeAssertion: "39.72",},{operator: "Not equal to",value: "2.07",representativeResult: "110.93",+ negativeAssertion: "39.72",single: true,},- {- operator: "Between",- value: ["3", "5"],- representativeResult: "68.23",- },{operator: "Greater than or equal to",value: "6.01",representativeResult: "110.93",+ negativeAssertion: "39.72",},{operator: "Less than or equal to",value: "2",representativeResult: "29.8",+ negativeAssertion: "39.72",},];diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-date.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-date.jsdeleted file mode 100644index 58b953588e7..00000000000--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-date.js+++ /dev/null@@ -1,107 +0,0 @@-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PEOPLE } = SAMPLE_DATABASE;--export const DASHBOARD_SQL_DATE_FILTERS = {- "Month and Year": {- sqlFilter: "date/month-year",- value: {- month: "Sep",- year: "2025",- },- representativeResult: "Rene Muller",- },- "Quarter and Year": {- sqlFilter: "date/quarter-year",- value: {- quarter: "Q2",- year: "2025",- },- representativeResult: "Khalid Pouros",- },- "Single Date": {- sqlFilter: "date/single",- value: "05/24/2025",- representativeResult: "Delphia Price",- },- "Date Range": {- sqlFilter: "date/range",- value: {- startDate: "05/25/2025",- endDate: "06/01/2025",- },- representativeResult: "Trisha Hoeger",- },- "All Options": {- sqlFilter: "date/all-options",- value: {- timeBucket: "years",- },- representativeResult: "Rene Muller", // this may change every year- },-};--export const questionDetails = {- name: "SQL with Field Filters",- native: {- query:- " select PEOPLE.NAME, PEOPLE.CREATED_AT from people where true\n [[AND {{monthyear}}]]\n [[AND {{quarteryear}}]]\n [[AND {{single}}]]\n [[AND {{range}}]]\n [[AND {{relative}}]]\n [[AND {{date}}]]\n limit 10",- "template-tags": {- monthyear: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "Month and Year",- id: "5e40619a-34ff-426d-a5b8-251defe355e5",- name: "monthyear",- type: "dimension",- "widget-type": "date/month-year",- },- quarteryear: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "Quarter and Year",- id: "1f4ddbaf-e071-7be3-ce5d-fdc5b4f62ab9",- name: "quarteryear",- type: "dimension",- "widget-type": "date/quarter-year",- },- single: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "Single Date",- id: "726fd574-ed18-5b06-4d9d-4f901ef3378a",- name: "single",- type: "dimension",- "widget-type": "date/single",- },- range: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "Date Range",- id: "f4ed832a-8882-d25a-1517-95a7ac478660",- name: "range",- type: "dimension",- "widget-type": "date/range",- },- relative: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "Relative Date",- id: "4a6c70c8-8b39-7058-5b4e-7a7ede920fca",- name: "relative",- type: "dimension",- "widget-type": "date/relative",- },-- date: {- default: null,- dimension: ["field", PEOPLE.CREATED_AT, null],- "display-name": "All Options",- id: "04171d50-5901-edaf-fba1-9b14211e965e",- name: "date",- type: "dimension",- "widget-type": "date/all-options",- },- },- },-};diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-location.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-location.jsdeleted file mode 100644index 0b44a0ddc9b..00000000000--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-location.js+++ /dev/null@@ -1,100 +0,0 @@-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PEOPLE } = SAMPLE_DATABASE;--export const questionDetails = {- name: "SQL with Field Filter",- native: {- query:- "select PEOPLE.NAME, PEOPLE.CITY from PEOPLE where true \n[[AND {{is}}]] \n[[AND {{not}}]] \n[[AND {{contains}}]] \n[[AND {{doesntcontain}}]] \n[[AND {{startswith}}]] \n[[AND {{endswith}}]] limit 10",- "template-tags": {- is: {- id: "bcd8b984-2e16-ffa4-82fc-2895ac8570f9",- name: "is",- "display-name": "Is",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/=",- default: null,- },- not: {- id: "c057de9d-dbba-3e93-1882-4409fa00629c",- name: "not",- "display-name": "Is not",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/!=",- default: null,- },- contains: {- id: "df86d80a-6575-996d-fd40-d2a4b8eb2a17",- name: "contains",- "display-name": "Contains",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/contains",- default: null,- },- doesntcontain: {- id: "ffe304fc-6c7b-6e70-d49d-33c91883e592",- name: "doesntcontain",- "display-name": "Does not contain",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/does-not-contain",- default: null,- },- startswith: {- id: "80e0894d-015a-ca28-8c4a-3b2ac4759507",- name: "startswith",- "display-name": "Starts with",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/starts-with",- default: null,- },- endswith: {- id: "25d5d9cf-bb95-2d56-507d-79d0d04fb314",- name: "endswith",- "display-name": "Ends with",- type: "dimension",- dimension: ["field", PEOPLE.CITY, null],- "widget-type": "string/ends-with",- default: null,- },- },- },-};--export const DASHBOARD_SQL_LOCATION_FILTERS = {- Is: {- sqlFilter: "string/=",- value: "Rye",- representativeResult: "Arnold Adams",- },- "Is not": {- sqlFilter: "string/!=",- value: "Rye",- representativeResult: "Hudson Borer",- },- Contains: {- sqlFilter: "string/contains",- value: "oo",- representativeResult: "Hudson Borer",- },- "Does not contain": {- sqlFilter: "string/does-not-contain",- value: "oo",- representativeResult: "Domenica Williamson",- },- "Starts with": {- sqlFilter: "string/starts-with",- value: "W",- representativeResult: "Hudson Borer",- },- "Ends with": {- sqlFilter: "string/ends-with",- value: "g",- representativeResult: "Aracely Jenkins",- },-};diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-number.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-number.jsdeleted file mode 100644index 43f99627203..00000000000--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-number.js+++ /dev/null@@ -1,86 +0,0 @@-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PRODUCTS } = SAMPLE_DATABASE;--export const DASHBOARD_SQL_NUMBER_FILTERS = {- "Equal to": {- sqlFilter: "number/=",- value: "3.8",- representativeResult: "Small Marble Hat",- },- "Not equal to": {- sqlFilter: "number/!=",- value: "2.07",- representativeResult: "Rustic Paper Wallet",- },- Between: {- sqlFilter: "number/between",- value: ["3", "4"],- representativeResult: "Small Marble Hat",- },- "Greater than or equal to": {- sqlFilter: "number/>=",- value: "4.3",- representativeResult: "Aerodynamic Linen Coat",- },- "Less than or equal to": {- sqlFilter: "number/<=",- value: "3",- representativeResult: "Enormous Aluminum Shirt",- },-};--export const questionDetails = {- name: "SQL with number filter",- native: {- query:- "select PRODUCTS.TITLE, PRODUCTS.RATING from PRODUCTS where true \n[[AND {{equal}}]] \n[[AND {{notEqual}}]] \n[[AND {{between}}]] \n[[AND {{gteq}}]] \n[[AND {{lteq}}]]",- "template-tags": {- equal: {- id: "197c0532-e2f8-24be-8d71-757369d3a75f",- name: "equal",- "display-name": "Equal to",- type: "dimension",- dimension: ["field", PRODUCTS.RATING, null],- "widget-type": "number/=",- default: null,- },- notEqual: {- id: "827ca517-e493-397f-971c-1a2d2f12d5f1",- name: "notEqual",- "display-name": "Not equal to",- type: "dimension",- dimension: ["field", PRODUCTS.RATING, null],- "widget-type": "number/!=",- default: null,- },- between: {- id: "6a3d9a46-671b-dee3-2971-fc180d27adfd",- name: "between",- "display-name": "Between",- type: "dimension",- dimension: ["field", PRODUCTS.RATING, null],- "widget-type": "number/between",- default: null,- },- gteq: {- id: "edd13ea2-e244-69f8-db5a-2a7f9722f269",- name: "gteq",- "display-name": "Greater than or equal to",- type: "dimension",- dimension: ["field", PRODUCTS.RATING, null],- "widget-type": "number/>=",- default: null,- },- lteq: {- id: "cce8c724-f0df-6fa1-81dc-58e7a8171caa",- name: "lteq",- "display-name": "Less than or equal to",- type: "dimension",- dimension: ["field", PRODUCTS.RATING, null],- "widget-type": "number/<=",- default: null,- },- },- },-};diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-text-category.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-text-category.jsdeleted file mode 100644index 52ec7cb8800..00000000000--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-sql-text-category.js+++ /dev/null@@ -1,100 +0,0 @@-import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";--const { PRODUCTS } = SAMPLE_DATABASE;--export const DASHBOARD_SQL_TEXT_FILTERS = {- Is: {- sqlFilter: "string/=",- value: "Gizmo",- representativeResult: "Rustic Paper Wallet",- },- "Is not": {- sqlFilter: "string/!=",- value: "Gadget",- representativeResult: "Rustic Paper Wallet",- },- Contains: {- sqlFilter: "string/contains",- value: "oo",- representativeResult: "Small Marble Shoes",- },- "Does not contain": {- sqlFilter: "string/does-not-contain",- value: "oo",- representativeResult: "Rustic Paper Wallet",- },- "Starts with": {- sqlFilter: "string/starts-with",- value: "G",- representativeResult: "Rustic Paper Wallet",- },- "Ends with": {- sqlFilter: "string/ends-with",- value: "y",- representativeResult: "Small Marble Shoes",- },-};--export const questionDetails = {- name: "SQL with Field Filter",- native: {- query:- "select * from PRODUCTS where true \n[[AND {{is}}]] \n[[AND {{not}}]] \n[[AND {{contains}}]] \n[[AND {{doesntcontain}}]] \n[[AND {{startswith}}]] \n[[AND {{endswith}}]]",- "template-tags": {- is: {- id: "bcd8b984-2e16-ffa4-82fc-2895ac8570f9",- name: "is",- "display-name": "Is",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/=",- default: null,- },- not: {- id: "c057de9d-dbba-3e93-1882-4409fa00629c",- name: "not",- "display-name": "Is not",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/!=",- default: null,- },- contains: {- id: "df86d80a-6575-996d-fd40-d2a4b8eb2a17",- name: "contains",- "display-name": "Contains",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/contains",- default: null,- },- doesntcontain: {- id: "ffe304fc-6c7b-6e70-d49d-33c91883e592",- name: "doesntcontain",- "display-name": "Does not contain",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/does-not-contain",- default: null,- },- startswith: {- id: "80e0894d-015a-ca28-8c4a-3b2ac4759507",- name: "startswith",- "display-name": "Starts with",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/starts-with",- default: null,- },- endswith: {- id: "25d5d9cf-bb95-2d56-507d-79d0d04fb314",- name: "endswith",- "display-name": "Ends with",- type: "dimension",- dimension: ["field", PRODUCTS.CATEGORY, null],- "widget-type": "string/ends-with",- default: null,- },- },- },-};diff --git a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-text-category.js b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-text-category.jsindex 72d684369aa..6fa9c154c6c 100644--- a/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-text-category.js+++ b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-text-category.js@@ -4,12 +4,14 @@ export const DASHBOARD_TEXT_FILTERS = [single: true,value: "Organic",representativeResult: "39.58",+ negativeAssertion: "37.65",},{operator: "Is not",single: true,- value: "Organic",- representativeResult: "37.65",+ value: "Twitter",+ representativeResult: "148.23",+ negativeAssertion: "37.65",},// It is important to keep multiple values as a single string in the value field.{@@ -36,32 +38,32 @@ export const DASHBOARD_TEXT_FILTERS = [single: true,value: '"oo,tt"',representativeResult: "37.65",- negativeASsertion: "39.58",+ negativeAssertion: "39.58",},{operator: "Starts with",value: "A,b",representativeResult: "85.72",- negativeASsertion: "70.15",+ negativeAssertion: "37.65",},{operator: "Starts with",single: true,value: '"A,b"',representativeResult: "No results",- negativeASsertion: "85.72",+ negativeAssertion: "85.72",},{operator: "Ends with",value: "e,s",representativeResult: "47.68",- negativeASsertion: "127.88",+ negativeAssertion: "127.88",},{operator: "Ends with",single: true,value: '"e,s"',representativeResult: "No results",- negativeASsertion: "47.68",+ negativeAssertion: "47.68",},];