Skip to content

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

Consolidate dashboard filters 2 e2e specs (#83700)

Nemanja Glumacb1ddf5b6c4e2
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-4.cy.spec.ts b/e2e/test/scenarios/dashboard-filters/dashboard-filters-2-stage-4.cy.spec.ts
similarity index 96%
rename from e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-4.cy.spec.ts
rename to e2e/test/scenarios/dashboard-filters/dashboard-filters-2-stage-4.cy.spec.ts
index 1112f27dfbf..ba1abd89951 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-2-stage-4.cy.spec.ts
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-2-stage-4.cy.spec.ts
@@ -17,7 +17,6 @@ describe("scenarios > dashboard > filters > query stages", () => {
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",
);
@@ -37,7 +36,7 @@ describe("scenarios > dashboard > filters > query stages", () => {
);
});
- it("allows to map to all relevant columns", () => {
+ it("allows to map to all relevant columns and applies a 1st stage implicit join (data source) filter", () => {
H.editDashboard();
cy.log("## date columns");
@@ -52,6 +51,25 @@ describe("scenarios > dashboard > filters > query stages", () => {
QSHelpers.getFilter("Number").click();
verifyNumberMappingOptions();
+ H.dashboardCancelButton().click();
+
+ cy.log("## 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",
+ });
+
function verifyDateMappingOptions() {
QSHelpers.verifyDashcardMappingOptions(
QSHelpers.QUESTION_BASED_QUESTION_INDEX,
@@ -311,24 +329,6 @@ describe("scenarios > dashboard > filters > query stages", () => {
});
});
- 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();
@@ -369,7 +369,7 @@ describe("scenarios > dashboard > filters > query stages", () => {
QSHelpers.setup1stStageAggregationFilter();
QSHelpers.verifyDashcardRowsCount({
- dashcardIndex: 1,
+ dashcardIndex: 0,
dashboardCount: 3,
queryBuilderCount: "Showing 3 rows",
});
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts b/e2e/test/scenarios/dashboard-filters/dashboard-filters-misc.cy.spec.ts
similarity index 96%
rename from e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts
rename to e2e/test/scenarios/dashboard-filters/dashboard-filters-misc.cy.spec.ts
index 2079f75ea08..7e93d13e023 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-misc.cy.spec.ts
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-misc.cy.spec.ts
@@ -14,10 +14,8 @@ describe("pivot tables", () => {
cy.signInAsAdmin();
QSHelpers.createBaseQuestions();
- cy.intercept("POST", "/api/dataset").as("dataset");
cy.intercept("POST", "/api/dataset/pivot").as("datasetPivot");
cy.intercept("GET", "/api/dashboard/**").as("getDashboard");
- cy.intercept("POST", "/api/card/*/query").as("cardQuery");
cy.then(function () {
H.createQuestion({
@@ -108,7 +106,10 @@ describe("pivot tables", () => {
cy.findByTestId("qb-header")
.button(/Filter/)
.click();
- H.popover().findByText("Summaries").should("not.exist");
+ H.popover().within(() => {
+ cy.findByText("Base Orders Question").should("be.visible");
+ cy.findByText("Summaries").should("not.exist");
+ });
function verifyDateMappingOptions() {
QSHelpers.verifyDashcardMappingOptions(QUESTION_PIVOT_INDEX, [
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-1.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-1.cy.spec.js
similarity index 87%
rename from e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-1.cy.spec.js
rename to e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-1.cy.spec.js
index 969dea39577..e3f6f36328f 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-1.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-1.cy.spec.js
@@ -27,25 +27,12 @@ const {
PEOPLE_ID,
} = SAMPLE_DATABASE;
-describe("issue 8030 + 32444", () => {
- const filterDetails = {
- name: "ID Column",
- slug: "id",
- id: "11d79abe",
- type: "id",
- sectionId: "id",
- };
-
+describe("issues 8030 and 32444", () => {
const question1Details = {
name: "Q1",
query: { "source-table": PRODUCTS_ID, limit: 2 },
};
- const question2Details = {
- name: "Q2",
- query: { "source-table": ORDERS_ID, limit: 2 },
- };
-
const questionWithFilter = {
name: "Question with Filter",
type: "query",
@@ -56,72 +43,9 @@ describe("issue 8030 + 32444", () => {
},
};
- const dashboardDetails = {
- name: "Filters",
- parameters: [filterDetails],
- };
- const createQuestionsAndDashboard = () => {
- return H.createQuestion(question1Details).then(
- ({ body: { id: card1_id } }) => {
- return H.createQuestion(question2Details).then(
- ({ body: { id: card2_id } }) => {
- return H.createDashboard(dashboardDetails).then(
- ({ body: { id: dashboard_id } }) => {
- return { dashboard_id, card1_id, card2_id };
- },
- );
- },
- );
- },
- );
- };
-
- const setFilterMapping = ({ dashboard_id, card1_id, card2_id }) => {
- return H.updateDashboardCards({
- dashboard_id,
- cards: [
- {
- card_id: card1_id,
- row: 0,
- col: 0,
- size_x: 5,
- size_y: 4,
- parameter_mappings: [
- {
- parameter_id: filterDetails.id,
- card_id: card1_id,
- target: ["dimension", ["field", PRODUCTS.ID, null]],
- },
- ],
- },
- {
- card_id: card2_id,
- row: 0,
- col: 4,
- size_x: 5,
- size_y: 4,
- parameter_mappings: [
- {
- parameter_id: filterDetails.id,
- card_id: card1_id,
- target: ["dimension", ["field", ORDERS.ID, null]],
- },
- ],
- },
- ].filter(Boolean),
- });
- };
-
- const interceptRequests = ({ dashboard_id, card1_id, card2_id }) => {
- cy.intercept("GET", `/api/dashboard/${dashboard_id}*`).as("getDashboard");
- cy.intercept(
- "POST",
- `/api/dashboard/${dashboard_id}/dashcard/*/card/${card1_id}/query`,
- ).as("getCardQuery1");
- cy.intercept(
- "POST",
- `/api/dashboard/${dashboard_id}/dashcard/*/card/${card2_id}/query`,
- ).as("getCardQuery2");
+ const unconnectedQuestion = {
+ name: "Unconnected",
+ query: { "source-table": PEOPLE_ID, limit: 2 },
};
const addFilterValue = (value) => {
@@ -130,94 +54,63 @@ describe("issue 8030 + 32444", () => {
cy.button("Add filter").click();
};
- describe("issue 8030", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should not reload dashboard cards not connected to a filter (metabase#8030)", () => {
- createQuestionsAndDashboard().then(
- ({ dashboard_id, card1_id, card2_id }) => {
- interceptRequests({ dashboard_id, card1_id, card2_id });
- setFilterMapping({ dashboard_id, card1_id, card2_id }).then(() => {
- cy.visit(`/dashboard/${dashboard_id}`);
- cy.wait("@getDashboard");
- cy.wait("@getCardQuery1");
- cy.wait("@getCardQuery2");
-
- cy.findByText(filterDetails.name).click();
- H.dashboardParametersPopover().within(() => {
- // the filter is connected only to the first card
- cy.findByPlaceholderText("Enter an ID").type("1");
- cy.button("Add filter").click();
- });
- cy.wait("@getCardQuery1");
- cy.get("@getCardQuery1.all").should("have.length", 2);
- cy.get("@getCardQuery2.all").should("have.length", 1);
- });
- },
- );
- });
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
});
- describe("issue 32444", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- });
-
- it("should not reload dashboard cards not connected to a filter (metabase#32444)", () => {
- H.createDashboardWithQuestions({
- questions: [question1Details, questionWithFilter],
- }).then(({ dashboard }) => {
- cy.intercept(
- "POST",
- `/api/dashboard/${dashboard.id}/dashcard/*/card/*/query`,
- ).as("getCardQuery");
-
- H.visitDashboard(dashboard.id);
- H.editDashboard(dashboard.id);
-
- cy.get("@getCardQuery.all").should("have.length", 2);
-
- H.setFilter("Text or Category", "Is");
- H.selectDashboardFilter(
- cy.findAllByTestId("dashcard").first(),
- "Title",
- );
-
- H.undoToast().findByRole("button", { name: "Auto-connect" }).click();
-
- cy.findAllByTestId("dashcard")
- .eq(1)
- .findByLabelText("Disconnect")
- .click();
-
- H.saveDashboard();
-
- // Saving exits edit mode and reloads the dashcards in view mode. How
- // many post-save card queries fire is not deterministic (cached results
- // may be reused), so rather than counting them we wait for the reload to
- // start and then for both cards to settle before re-aliasing below.
- // Otherwise a still in-flight post-save query would be captured by the
- // new intercept on the same URL and miscounted as a filter-triggered
- // query (the test then sees 2, not 1).
- cy.wait("@getCardQuery");
- H.waitForDashcardsToLoad({ count: 2 });
-
- // Reset the intercept after save so we only count filter-triggered queries.
- cy.intercept(
- "POST",
- `/api/dashboard/${dashboard.id}/dashcard/*/card/*/query`,
- ).as("getCardQueryAfterFilter");
-
- addFilterValue("Aerodynamic Bronze Hat");
-
- cy.wait("@getCardQueryAfterFilter");
- // Only the card connected to the filter should re-execute.
- cy.get("@getCardQueryAfterFilter.all").should("have.length", 1);
- });
+ it("should not reload dashboard cards not connected to a filter (metabase#8030, metabase#32444)", () => {
+ H.createDashboardWithQuestions({
+ questions: [question1Details, questionWithFilter, unconnectedQuestion],
+ cards: [
+ { row: 0, col: 0, size_x: 8, size_y: 6 },
+ { row: 0, col: 8, size_x: 8, size_y: 6 },
+ { row: 0, col: 16, size_x: 8, size_y: 6 },
+ ],
+ }).then(({ dashboard }) => {
+ cy.intercept(
+ "POST",
+ `/api/dashboard/${dashboard.id}/dashcard/*/card/*/query`,
+ ).as("getCardQuery");
+
+ H.visitDashboard(dashboard.id);
+ H.editDashboard(dashboard.id);
+
+ cy.get("@getCardQuery.all").should("have.length", 3);
+
+ H.setFilter("Text or Category", "Is");
+ H.selectDashboardFilter(cy.findAllByTestId("dashcard").first(), "Title");
+
+ H.undoToast().findByRole("button", { name: "Auto-connect" }).click();
+
+ cy.findAllByTestId("dashcard")
+ .eq(1)
+ .findByLabelText("Disconnect")
+ .click();
+
+ H.saveDashboard();
+
+ // Saving exits edit mode and reloads the dashcards in view mode. How
+ // many post-save card queries fire is not deterministic (cached results
+ // may be reused), so rather than counting them we wait for the reload to
+ // start and then for all cards to settle before re-aliasing below.
+ // Otherwise a still in-flight post-save query would be captured by the
+ // new intercept on the same URL and miscounted as a filter-triggered
+ // query.
+ cy.wait("@getCardQuery");
+ H.waitForDashcardsToLoad({ count: 3 });
+
+ // Reset the intercept after save so we only count filter-triggered queries.
+ cy.intercept(
+ "POST",
+ `/api/dashboard/${dashboard.id}/dashcard/*/card/*/query`,
+ ).as("getCardQueryAfterFilter");
+
+ addFilterValue("Aerodynamic Bronze Hat");
+
+ cy.wait("@getCardQueryAfterFilter");
+ // Only the card connected to the filter should re-execute.
+ cy.get("@getCardQueryAfterFilter.all").should("have.length", 1);
});
});
});
@@ -227,8 +120,13 @@ describe("issue 12720, issue 47172", () => {
H.visitDashboard(ORDERS_DASHBOARD_ID);
cy.findAllByTestId("dashcard-container").contains(title).click();
+ cy.location("pathname").should("match", /^\/question/);
cy.location("search").should("contain", dashboardFilter.default);
H.filterWidget().contains("After January 1, 2029");
+ cy.findByTestId("question-row-count").should(
+ "have.text",
+ "Showing 1,980 rows",
+ );
}
// After January 1st, 2029
const dashboardFilter = {
@@ -316,6 +214,7 @@ describe("issue 12720, issue 47172", () => {
H.visitDashboard(ORDERS_DASHBOARD_ID);
H.getDashboardCard(1).within(() => {
+ cy.findByTestId("table-root").should("be.visible");
cy.findByText("There was a problem displaying this chart.").should(
"not.exist",
);
@@ -491,10 +390,10 @@ describe("issues 15119 and 16112", () => {
cy.findByText("Rating Filter").click();
cy.findByText("Linked filters").click();
- // turn on the toggle
- H.sidebar().findByRole("switch").parent().get("label").click();
+ H.sidebar().findByRole("switch").click({ force: true });
+ H.sidebar().findByRole("switch").should("be.checked");
- cy.findByText("Save").click();
+ H.saveDashboard();
cy.signIn("nodata");
H.visitDashboard(dashboard_id);
@@ -654,12 +553,14 @@ describe("issue 17211", () => {
it("should not falsely alert that no matching dashboard filter has been found (metabase#17211)", () => {
H.filterWidget().click();
- cy.findByPlaceholderText("Search the list").type("abb");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("Abbeville").click();
+ H.popover().findByPlaceholderText("Search the list").type("abb");
+ // eslint-disable-next-line metabase/no-unsafe-element-filtering
+ H.popover().last().findByText("Abbeville").click();
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.contains("No matching City found").should("not.exist");
+ H.multiAutocompleteValue(0)
+ .should("be.visible")
+ .should("contain", "Abbeville");
+ H.popover().should("not.contain", "No matching City found");
});
});
@@ -722,15 +623,18 @@ describe("issue 17551", () => {
});
it("should include today in the 'All time' date filter when chosen 'Next' (metabase#17551)", () => {
+ H.getDashboardCard().findByText("yesterday").should("be.visible");
+
H.filterWidget().click();
setAdHocFilter({ condition: "Next", includeCurrent: true });
cy.url().should("include", "?date_filter=next30days~");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("tomorrow");
- // eslint-disable-next-line metabase/no-unscoped-text-selectors -- deprecated usage
- cy.findByText("today");
+ H.getDashboardCard().within(() => {
+ cy.findByText("yesterday").should("not.exist");
+ cy.findByText("today").should("be.visible");
+ cy.findByText("tomorrow").should("be.visible");
+ });
});
});
@@ -1020,15 +924,23 @@ describe("issue 22788", () => {
parameters: [filter],
};
+ function assertFilteredByGizmo() {
+ H.getDashboardCard().within(() => {
+ cy.findByText("Mediocre Wooden Table").should("be.visible");
+ cy.findByText("Doohickey").should("not.exist");
+ });
+ }
+
function addFilterAndAssert() {
+ H.getDashboardCard().findAllByText("Doohickey").should("not.be.empty");
+
H.filterWidget().click();
H.dashboardParametersPopover().within(() => {
H.fieldValuesCombobox().type("Gizmo");
cy.button("Add filter").click();
});
- cy.findAllByText("Gizmo");
- cy.findAllByText("Doohickey").should("not.exist");
+ assertFilteredByGizmo();
}
function openFilterSettings() {
@@ -1088,8 +1000,9 @@ describe("issue 22788", () => {
H.saveDashboard();
- cy.findAllByText("Gizmo");
- cy.findAllByText("Doohickey").should("not.exist");
+ cy.location("search").should("eq", "?my_filter_text=Gizmo");
+ cy.reload();
+ assertFilteredByGizmo();
});
});
@@ -1138,7 +1051,6 @@ describe("issue 24235", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
- cy.intercept("POST", "/api/dashboard/**/query").as("getCardQuery");
});
it("should not allow to add a filter when all exclude options are selected (metabase#24235)", () => {
@@ -1565,13 +1477,13 @@ describe("issue 25374", () => {
H.getDashboardCard(0).findByText(questionDetails.name).click();
cy.wait("@cardQuery");
- H.tableInteractiveHeader("COUNT(*)");
+ H.tableInteractiveHeader().should("contain", "COUNT(*)");
H.tableInteractiveBody().findByText("3");
cy.location("search").should("eq", "?num=1%2C2%2C3");
});
- it("should retain comma-separated values on refresh (metabase#25374-2)", () => {
+ it("should retain comma-separated values on refresh and when reverting to default (metabase#25374-2, metabase#25374-3, metabase#25374-4)", () => {
cy.reload();
// Make sure filter widget still has all the values
@@ -1584,9 +1496,7 @@ describe("issue 25374", () => {
// Make sure URL search params are correct
cy.location("search").should("eq", "?equal_to=1%2C2%2C3");
- });
- it("should retain comma-separated values when reverting to default (metabase#25374-3)", () => {
H.editDashboard();
cy.findByTestId("edit-dashboard-parameters-widget-container")
.findByText("Equal to")
@@ -1602,6 +1512,7 @@ describe("issue 25374", () => {
.findByTestId("cell-data")
.should("have.text", "3");
+ cy.log("Reset the filter to its default with the widget button");
cy.button("Clear").click();
cy.wait("@dashcardQuery");
H.getDashboardCard().should(
@@ -1618,32 +1529,7 @@ describe("issue 25374", () => {
.should("have.text", "3");
cy.location("search").should("eq", "?equal_to=1%2C2%2C3");
- // Drill-through and go to the question
- H.getDashboardCard(0).findByText(questionDetails.name).click();
- cy.wait("@cardQuery");
-
- cy.get("[data-testid=cell-data]")
- .should("contain", "COUNT(*)")
- .and("contain", "3");
-
- cy.location("search").should("eq", "?num=1%2C2%2C3");
- });
-
- it("should retain comma-separated values when reverting to default via 'Reset all filters' (metabase#25374-4)", () => {
- H.editDashboard();
- cy.findByTestId("edit-dashboard-parameters-widget-container")
- .findByText("Equal to")
- .click();
- H.dashboardParameterSidebar()
- .findByLabelText("Default value")
- .type("1,2,3");
- H.saveDashboard();
- cy.location("search").should("eq", "?equal_to=1%2C2%2C3");
- H.getDashboardCard()
- .findByTestId("table-body")
- .findByTestId("cell-data")
- .should("have.text", "3");
-
+ cy.log("Reset the filter to its default with 'Reset all filters'");
cy.button("Clear").click();
cy.wait("@dashcardQuery");
cy.location("search").should("eq", "?equal_to=");
@@ -1656,7 +1542,6 @@ describe("issue 25374", () => {
H.popover().findByText("Reset all filters").should("be.visible").click();
cy.wait("@dashcardQuery");
cy.location("search").should("eq", "?equal_to=1%2C2%2C3");
- cy.location("search").should("eq", "?equal_to=1%2C2%2C3");
H.getDashboardCard()
.findByTestId("table-body")
.findByTestId("cell-data")
@@ -1762,6 +1647,7 @@ describe("issue 26230, issue 27356", () => {
};
const PARAM_DASHBOARD = "dashboard with a tall card";
+ const PARAM_DASHBOARD_2 = "another dashboard with a tall card";
const REGULAR_DASHBOARD = "dashboard without params";
function prepareAndVisitDashboards() {
@@ -1772,6 +1658,16 @@ describe("issue 26230, issue 27356", () => {
bookmarkDashboard(id);
});
+ // A second parameterized dashboard to switch to while the first one's
+ // param widget is sticky (metabase#26230).
+ H.createDashboard({
+ name: PARAM_DASHBOARD_2,
+ parameters: [FILTER],
+ }).then(({ body: { id } }) => {
+ createDashCard(id, FILTER);
+ bookmarkDashboard(id);
+ });
+
// A bookmarked dashboard *with* a parameter and a tall mapped card. We
// start here so the param widget can become sticky once scrolled
// (metabase#26230).
@@ -1832,16 +1728,30 @@ describe("issue 26230, issue 27356", () => {
.findByDisplayValue(PARAM_DASHBOARD)
.should("not.be.visible");
+ // A transparent bottom border means the param widget is not sticky.
+ cy.findByTestId("dashboard-parameters-widget-container").should(
+ "not.have.css",
+ "border-bottom-color",
+ "rgba(0, 0, 0, 0)",
+ );
+
+ cy.intercept("GET", "/api/dashboard/*").as("loadDashboard");
+ cy.findByRole("listitem", { name: PARAM_DASHBOARD_2 }).click();
+ cy.wait("@loadDashboard");
+
+ cy.findByRole("main")
+ .findByDisplayValue(PARAM_DASHBOARD_2)
+ .should("be.visible");
cy.findByTestId("dashboard-parameters-widget-container").should(
"have.css",
- "position",
- "sticky",
+ "border-bottom-color",
+ "rgba(0, 0, 0, 0)",
);
// Switching from the parameterized dashboard to the non-parameterized one
// via the navigation sidebar should load cleanly, without erroring
// (metabase#27356).
- cy.intercept("GET", "/api/dashboard/*").as("loadDashboard");
+ cy.button("Toggle sidebar").click();
cy.findByRole("listitem", { name: REGULAR_DASHBOARD }).click();
cy.wait("@loadDashboard");
@@ -1881,7 +1791,7 @@ describe("issue 27768", () => {
parameters: [filter],
});
- H.visitDashboard(dashboard_id, { queryParams: { cat: "Gizmo" } });
+ H.visitDashboard(dashboard_id);
},
);
});
@@ -1896,13 +1806,18 @@ describe("issue 27768", () => {
H.popover().contains("CCategory").click();
H.saveDashboard();
+ H.getDashboardCard().findAllByText("Doohickey").should("not.be.empty");
+
H.filterWidget().click();
H.dashboardParametersPopover().within(() => {
H.fieldValuesCombobox().type("Gizmo");
cy.button("Add filter").click();
});
- cy.findAllByText("Doohickey").should("not.exist");
+ H.getDashboardCard().within(() => {
+ cy.findByText("Mediocre Wooden Table").should("be.visible");
+ cy.findByText("Doohickey").should("not.exist");
+ });
// Make sure the filter is still connected to the custom column
H.editDashboard();
@@ -2041,7 +1956,7 @@ describe("issues 29347, 29346", () => {
cy.intercept("POST", "/api/dashboard/**/card/*/query").as("cardQuery");
});
- it("should be able to filter on remapped values (metabase#29347, metabase#29346)", () => {
+ it("should be able to filter on remapped values in the UI and in the url (metabase#29347, metabase#29346)", () => {
createDashboard();
H.visitDashboard("@dashboardId");
cy.wait("@dashboard");
@@ -2051,10 +1966,11 @@ describe("issues 29347, 29346", () => {
cy.wait("@cardQuery");
verifyRemappedValues(filterValue);
- });
- it("should be able to filter on remapped values in the url (metabase#29347, metabase#29346)", () => {
- createDashboard();
+ // Clear the last used value so the url value is the only source
+ H.clearFilterWidget();
+ cy.wait("@cardQuery");
+
H.visitDashboard("@dashboardId", {
params: { [filterDetails.slug]: filterValue },
});
@@ -2072,7 +1988,7 @@ describe("issues 29347, 29346", () => {
cy.intercept("GET", "/api/embed/dashboard/**/card/*").as("cardQuery");
});
- it("should be able to filter on remapped values (metabase#29347, metabase#29346)", () => {
+ it("should be able to filter on remapped values in the UI and in the url (metabase#29347, metabase#29346)", () => {
createDashboard();
cy.get("@dashboardId").then((dashboardId) =>
H.visitEmbeddedPage({
@@ -2087,26 +2003,7 @@ describe("issues 29347, 29346", () => {
cy.wait("@cardQuery");
verifyRemappedValues(filterValue);
- });
-
- it("should be able to filter on remapped values in the token (metabase#29347, metabase#29346)", () => {
- createDashboard({ dashboardDetails: lockedDashboardDetails });
- cy.get("@dashboardId").then((dashboardId) => {
- H.visitEmbeddedPage({
- resource: { dashboard: dashboardId },
- params: {
- [filterDetails.slug]: filterValue,
- },
- });
- });
- cy.wait("@dashboard");
- cy.wait("@cardQuery");
- verifyRemappedCardValues(filterValue);
- });
-
- it("should be able to filter on remapped values in the url (metabase#29347, metabase#29346)", () => {
- createDashboard();
cy.get("@dashboardId").then((dashboardId) => {
H.visitEmbeddedPage(
{
@@ -2123,6 +2020,22 @@ describe("issues 29347, 29346", () => {
verifyRemappedValues(filterValue);
});
+
+ it("should be able to filter on remapped values in the token (metabase#29347, metabase#29346)", () => {
+ createDashboard({ dashboardDetails: lockedDashboardDetails });
+ cy.get("@dashboardId").then((dashboardId) => {
+ H.visitEmbeddedPage({
+ resource: { dashboard: dashboardId },
+ params: {
+ [filterDetails.slug]: filterValue,
+ },
+ });
+ });
+ cy.wait("@dashboard");
+ cy.wait("@cardQuery");
+
+ verifyRemappedCardValues(filterValue);
+ });
});
describe("public dashboards", () => {
@@ -2131,7 +2044,7 @@ describe("issues 29347, 29346", () => {
cy.intercept("GET", "/api/public/dashboard/**/card/*").as("cardQuery");
});
- it("should be able to filter on remapped values (metabase#29347, metabase#29346)", () => {
+ it("should be able to filter on remapped values in the UI and in the url (metabase#29347, metabase#29346)", () => {
createDashboard();
cy.get("@dashboardId").then((dashboardId) =>
H.visitPublicDashboard(dashboardId),
@@ -2143,15 +2056,10 @@ describe("issues 29347, 29346", () => {
cy.wait("@cardQuery");
verifyRemappedValues(filterValue);
- });
- it("should be able to filter on remapped values in the url (metabase#29347, metabase#29346)", () => {
- createDashboard();
- cy.get("@dashboardId").then((dashboardId) => {
- H.visitPublicDashboard(dashboardId, {
- params: { [filterDetails.slug]: filterValue },
- });
- });
+ cy.location("pathname").then((pathname) =>
+ cy.visit(`${pathname}?${filterDetails.slug}=${filterValue}`),
+ );
cy.wait("@dashboard");
cy.wait("@cardQuery");
@@ -2311,7 +2219,7 @@ describe("issue 43154", () => {
},
});
- function verifyNestedFilter(questionDetails) {
+ function verifyNestedFilter(questionDetails, assertUnfiltered = () => {}) {
H.createQuestion(modelDetails).then(({ body: model }) => {
H.createDashboardWithQuestions({
questions: [questionDetails(model.id)],
@@ -2326,11 +2234,13 @@ describe("issue 43154", () => {
H.popover().findByText("People - User → Source").click();
H.saveDashboard();
+ assertUnfiltered();
H.filterWidget().click();
H.popover().within(() => {
cy.findByText("Twitter").click();
cy.button("Add filter").click();
});
+ H.filterWidget().should("contain", "Twitter");
}
beforeEach(() => {
@@ -2343,7 +2253,10 @@ describe("issue 43154", () => {
});
it("should be able to see field values with a model-based question with aggregation (metabase#43154)", () => {
- verifyNestedFilter(questionWithAggregationDetails);
+ verifyNestedFilter(questionWithAggregationDetails, () =>
+ H.getDashboardCard().findByText("18,760").should("be.visible"),
+ );
+ H.getDashboardCard().findByText("3,772").should("be.visible");
});
});
@@ -2443,20 +2356,19 @@ describe("issue 42829", () => {
});
});
- it("should be able to get field values coming from a sql model-based question in a regular dashboard (metabase#42829)", () => {
+ it("should be able to get field values coming from a sql model-based question in regular, public and embedded dashboards (metabase#42829)", () => {
+ cy.log("regular dashboard");
H.visitDashboard("@dashboardId");
filterAndVerifyResults();
drillAndVerifyResults();
- });
- it("should be able to get field values coming from a sql model-based question in a public dashboard (metabase#42829)", () => {
+ cy.log("public dashboard");
cy.get("@dashboardId").then((dashboardId) =>
H.visitPublicDashboard(dashboardId),
);
filterAndVerifyResults();
- });
- it("should be able to get field values coming from a sql model-based question in a embedded dashboard (metabase#42829)", () => {
+ cy.log("embedded dashboard");
cy.get("@dashboardId").then((dashboardId) =>
H.visitEmbeddedPage({
resource: { dashboard: dashboardId },
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-2.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-2.cy.spec.js
similarity index 90%
rename from e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-2.cy.spec.js
rename to e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-2.cy.spec.js
index 506c2c8bb9d..0f9555e9f57 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-reproductions-2.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-reproductions-2.cy.spec.js
@@ -141,18 +141,6 @@ describe("44047", () => {
},
};
- const sourceQuestionDetails = {
- name: "Source question",
- type: "question",
- query: {
- "source-table": REVIEWS_ID,
- fields: [
- ["field", REVIEWS.ID, { "base-type": "type/BigInteger" }],
- ["field", REVIEWS.RATING, { "base-type": "type/Integer" }],
- ],
- },
- };
-
const parameterDetails = {
name: "Text",
slug: "text",
@@ -206,6 +194,9 @@ describe("44047", () => {
cy.findByText("Remapped").click();
cy.button("Add filter").click();
});
+ H.filterWidget().should("contain", "Remapped");
+ H.getDashboardCard(0).within(() => H.assertTableRowsCount(46));
+ H.getDashboardCard(1).within(() => H.assertTableRowsCount(46));
}
beforeEach(() => {
@@ -224,7 +215,6 @@ describe("44047", () => {
});
it("should be able to use remapped values from an integer field with an overridden semantic type used for a custom dropdown source in public dashboards (metabase#44047)", () => {
- H.createQuestion(sourceQuestionDetails);
H.createDashboardWithQuestions({
dashboardDetails,
questions: [questionDetails, modelDetails],
@@ -309,17 +299,21 @@ describe("issue 45659", () => {
});
});
- it("should remap initial parameter values in public dashboards (metabase#45659)", () => {
- createDashboard().then(({ dashboard }) =>
- H.visitPublicDashboard(dashboard.id),
+ it("should remap initial parameter values in public and embedded dashboards and query each public dashcard once (metabase#45659, metabase#17061)", () => {
+ cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
+ "publicDashcardData",
);
+ createDashboard().then(({ dashboard }) => {
+ cy.wrap(dashboard.id).as("dashboardId");
+ H.visitPublicDashboard(dashboard.id);
+ });
verifyFilterWithRemapping();
- });
+ H.getDashboardCard().within(() => H.assertTableRowsCount(1));
+ cy.get("@publicDashcardData.all").should("have.length", 1);
- it("should remap initial parameter values in embedded dashboards (metabase#45659)", () => {
- createDashboard().then(({ dashboard }) =>
+ cy.get("@dashboardId").then((dashboardId) =>
H.visitEmbeddedPage({
- resource: { dashboard: dashboard.id },
+ resource: { dashboard: dashboardId },
params: {},
}),
);
@@ -520,6 +514,7 @@ describe("issue 35852", () => {
cy.findAllByTestId("cell-data")
.filter(":contains(Gizmo)")
.should("have.length", 2);
+ H.assertQueryBuilderRowCount(2);
H.visitDashboard("@dashboardId");
@@ -531,6 +526,7 @@ describe("issue 35852", () => {
});
H.getDashboardCard().findAllByText("Gizmo").should("have.length", 2);
+ H.getDashboardCard().within(() => H.assertTableRowsCount(2));
});
function createDashboardWithFilterAndQuestionMapped(modelId) {
@@ -907,7 +903,6 @@ describe("issue 45670", { tags: ["@external"] }, () => {
H.resetTestTable({ type: dialect, table: tableName });
cy.signInAsAdmin();
H.resyncDatabase({ dbId: WRITABLE_DB_ID, tableName });
- cy.intercept("PUT", "/api/card/*").as("updateCard");
});
it("should be able to pass query string parameters for boolean parameters in dashboards (metabase#45670)", () => {
@@ -1205,67 +1200,6 @@ describe("issue 54236", () => {
});
});
-describe("issue 17061", () => {
- const questionDetails = {
- query: {
- "source-table": PEOPLE_ID,
- "order-by": [["asc", ["field", PEOPLE.ID, null]]],
- limit: 1,
- },
- };
-
- const parameterDetails = {
- name: "State",
- slug: "state",
- id: "5aefc725",
- type: "string/=",
- sectionId: "location",
- };
-
- const dashboardDetails = {
- parameters: [parameterDetails],
- enable_embedding: true,
- embedding_params: {
- [parameterDetails.slug]: "enabled",
- },
- };
-
- const getParameterMapping = (cardId) => ({
- parameter_id: parameterDetails.id,
- card_id: cardId,
- target: ["dimension", ["field", "STATE", { "base-type": "type/Text" }]],
- });
-
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
- cy.intercept("GET", "/api/public/dashboard/*/dashcard/*/card/*").as(
- "publicDashcardData",
- );
- });
-
- it("should not send multiple query requests for the same dashcards when opening a public dashboard with parameters (metabase#17061)", () => {
- H.createQuestionAndDashboard({
- questionDetails,
- dashboardDetails,
- }).then(({ body: dashcard, questionId }) => {
- H.updateDashboardCards({
- dashboard_id: dashcard.dashboard_id,
- cards: [
- {
- card_id: questionId,
- parameter_mappings: [getParameterMapping(questionId)],
- },
- ],
- });
- H.visitPublicDashboard(dashcard.dashboard_id);
- });
-
- H.getDashboardCard().findByText("1").should("be.visible");
- cy.get("@publicDashcardData.all").should("have.length", 1);
- });
-});
-
describe("issue 62627", () => {
beforeEach(() => {
H.restore();
@@ -1431,7 +1365,7 @@ describe("issue 55678", () => {
});
});
-describe("issue 14595", () => {
+describe("issue 14595", { tags: ["@external"] }, () => {
const dialect = "postgres";
const tableName = "many_data_types";
@@ -1593,40 +1527,46 @@ describe("issue 44090", () => {
});
});
- it("should not overflow the dashboard header when a filter contains a long value that contains spaces (metabase#44090)", () => {
- const LONG_VALUE =
+ it("should not overflow the dashboard header when a filter contains a long value (metabase#44090)", () => {
+ const LONG_VALUE_WITH_SPACES =
"Minima non hic doloribus ipsa dolore ratione in numquam. Minima eos vel harum velit. Consequatur consequuntur culpa sed eum";
+ const LONG_VALUE_WITHOUT_SPACES =
+ "MinimanonhicdoloribusipsadolorerationeinnumquamMinimaeosvelharumvelitConsequaturconsequunturculpasedeum";
H.filterWidget().click();
H.popover()
.first()
.within(() => {
- cy.findByPlaceholderText("Search the list").type(LONG_VALUE);
+ cy.findByPlaceholderText("Search the list").type(
+ LONG_VALUE_WITH_SPACES,
+ );
cy.button("Add filter").click();
});
- H.filterWidget().then(($el) => {
- const { width } = $el[0].getBoundingClientRect();
- cy.wrap(width).should("be.lt", 300);
- });
- });
+ cy.location("search").should("contain", "string=Minima");
+ H.filterWidget()
+ .should("contain", "Minima")
+ .invoke("outerWidth")
+ .should("be.lt", 300);
- it("should not overflow the dashboard header when a filter contains a long value that does not contain spaces (metabase#44090)", () => {
- const LONG_VALUE =
- "MinimanonhicdoloribusipsadolorerationeinnumquamMinimaeosvelharumvelitConsequaturconsequunturculpasedeum";
+ H.clearFilterWidget();
+ cy.location("search").should("not.contain", "string=Minima");
H.filterWidget().click();
H.popover()
.first()
.within(() => {
- cy.findByPlaceholderText("Search the list").type(LONG_VALUE);
+ cy.findByPlaceholderText("Search the list").type(
+ LONG_VALUE_WITHOUT_SPACES,
+ );
cy.button("Add filter").click();
});
- H.filterWidget().then(($el) => {
- const { width } = $el[0].getBoundingClientRect();
- cy.wrap(width).should("be.lt", 300);
- });
+ cy.location("search").should("contain", "string=Minimanonhic");
+ H.filterWidget()
+ .should("contain", "Minima")
+ .invoke("outerWidth")
+ .should("be.lt", 300);
});
});
@@ -1660,7 +1600,6 @@ describe("issue 59306", () => {
card_id: card.id,
parameter_id: parameter.id,
target: ["dimension", ["field", PRODUCTS.CATEGORY, null]],
- has_field_values: "input",
},
],
},
@@ -1682,59 +1621,7 @@ describe("issue 59306", () => {
});
});
-describe("Issue 60987", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
-
- H.createQuestionAndDashboard({
- questionDetails: {
- type: "question",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- 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",
- },
- ],
- ],
- },
- ],
- },
- },
- }).then((response) => {
- H.visitDashboard(response.body.dashboard_id);
- });
- });
-
- it("should show the empty state for parameters when searching the in the parameter target picker popover (metabase#60987)", () => {
- H.editDashboard();
- H.setFilter("Text or Category", "Is");
- H.getDashboardCard().findByText("Select…").click();
- H.popover().findByPlaceholderText("Find...").type("aa");
- H.popover().findByText("Didn't find any results").should("be.visible");
- });
-});
-
-describe("Issue 60987", () => {
+describe("issues 60987 and 46767", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
@@ -1781,66 +1668,17 @@ describe("Issue 60987", () => {
H.getDashboardCard().findByText("Select…").click();
});
- it("should show the empty state for parameters when searching the in the parameter target picker popover (metabase#60987)", () => {
+ it("should show the empty state and no empty sections when searching in the parameter target picker popover (metabase#60987, metabase#46767)", () => {
H.popover().within(() => {
cy.findByPlaceholderText("Find...").type("aa");
cy.findByText("Didn't find any results")
.should("be.visible")
.should("have.css", "color", "rgba(7, 23, 34, 0.62)"); // the text "text-medium"
- });
- });
-});
-describe("Issue 46767", () => {
- beforeEach(() => {
- H.restore();
- cy.signInAsAdmin();
+ cy.findByPlaceholderText("Find...").clear().type("Name");
+ cy.findByText("User").should("be.visible");
- H.createQuestionAndDashboard({
- questionDetails: {
- type: "question",
- query: {
- "source-table": ORDERS_ID,
- joins: [
- {
- "source-table": PRODUCTS_ID,
- 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",
- },
- ],
- ],
- },
- ],
- },
- },
- }).then((response) => {
- H.visitDashboard(response.body.dashboard_id);
- });
-
- H.editDashboard();
- H.setFilter("Text or Category", "Is");
- H.getDashboardCard().findByText("Select…").click();
- });
-
- it("search results for parameter target picker should not show empty sections (metabase#46767)", () => {
- H.popover().within(() => {
- cy.findByPlaceholderText("Find...").type("Ean");
+ cy.findByPlaceholderText("Find...").clear().type("Ean");
cy.findByText("Products").should("be.visible");
cy.findByText("User").should("not.exist");
});
@@ -1912,11 +1750,17 @@ describe("issue 46541", () => {
cy.log("Set parameter value on Dashboard B");
H.visitDashboard("@dashboardB");
+ cy.intercept("POST", "/api/dashboard/*/dashcard/*/card/*/query").as(
+ "dashcardQueryB",
+ );
H.filterWidget(OTHER_FILTER).click();
H.popover().within(() => {
cy.findByPlaceholderText("Enter a number").type("10");
cy.button("Add filter").click();
});
+ H.filterWidget(OTHER_FILTER).should("contain", "10");
+ // The last used value is stored while running the dashcard query.
+ cy.wait("@dashcardQueryB");
cy.log("Set up click behaviour on Dashboard A");
H.visitDashboard("@dashboardA");
@@ -2051,7 +1895,6 @@ describe("issue #66670", () => {
beforeEach(() => {
H.restore();
cy.signInAsAdmin();
- cy.intercept("PUT", "/api/dashboard/*").as("updateDashboard");
cy.intercept("GET", "/api/revision*").as("revisionHistory");
});
@@ -2095,7 +1938,6 @@ describe("issue #66670", () => {
cy.log("Step 5: Save the dashboard");
H.saveDashboard();
- cy.wait("@updateDashboard");
cy.log("Step 5b: Update the title and save again");
H.editDashboard();
@@ -2104,7 +1946,6 @@ describe("issue #66670", () => {
.clear()
.type("Updated Dashboard Title");
H.saveDashboard();
- cy.wait("@updateDashboard");
cy.log("Step 6: Move Question B to the trash");
H.visitQuestion(questionBId);
@@ -2116,6 +1957,7 @@ describe("issue #66670", () => {
"Step 8: Revert dashboard to earlier version where filter used Question B",
);
H.visitDashboard(dashboardId);
+ cy.intercept("POST", "/api/revision/revert").as("revertDashboard");
H.openDashboardInfoSidebar();
H.sidesheet().within(() => {
cy.findByRole("tab", { name: "History" }).click();
@@ -2126,6 +1968,12 @@ describe("issue #66670", () => {
.first()
.click();
});
+ cy.wait("@revertDashboard")
+ .its("response.statusCode")
+ .should("eq", 200);
+ cy.findByTestId("dashboard-header")
+ .findByDisplayValue("Test Dashboard UXW-2494")
+ .should("be.visible");
// Close sidesheet
H.sidesheet().findByLabelText("Close").click();
diff --git a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-with-question-revert.cy.spec.js b/e2e/test/scenarios/dashboard-filters/dashboard-filters-with-question-revert.cy.spec.js
similarity index 98%
rename from e2e/test/scenarios/dashboard-filters-2/dashboard-filters-with-question-revert.cy.spec.js
rename to e2e/test/scenarios/dashboard-filters/dashboard-filters-with-question-revert.cy.spec.js
index dac44f2c455..c24d6e841dc 100644
--- a/e2e/test/scenarios/dashboard-filters-2/dashboard-filters-with-question-revert.cy.spec.js
+++ b/e2e/test/scenarios/dashboard-filters/dashboard-filters-with-question-revert.cy.spec.js
@@ -234,6 +234,7 @@ describe("issue 35954", () => {
H.filterWidget().click();
cy.findByPlaceholderText("Enter a number").type("3{enter}");
cy.button("Add filter").click();
+ H.filterWidget().should("contain", "3");
assertFilterIsDisconnected();
});
@@ -260,6 +261,7 @@ describe("issue 35954", () => {
H.filterWidget().click();
cy.findByPlaceholderText("Enter a number").type("3{enter}");
cy.button("Add filter").click();
+ H.filterWidget().should("contain", "3");
assertFilterIsDisconnected();
});
diff --git a/e2e/test/scenarios/dashboard-filters-2/shared/dashboard-filters-query-stages.ts b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-query-stages.ts
similarity index 88%
rename from e2e/test/scenarios/dashboard-filters-2/shared/dashboard-filters-query-stages.ts
rename to e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-query-stages.ts
index 182f46c4a96..dd873910863 100644
--- a/e2e/test/scenarios/dashboard-filters-2/shared/dashboard-filters-query-stages.ts
+++ b/e2e/test/scenarios/dashboard-filters/shared/dashboard-filters-query-stages.ts
@@ -152,16 +152,8 @@ export function createQ1Query(source: Card): StructuredQuery {
};
}
-// Q2 - join, custom column, 2 aggregations, no breakouts
-export function createQ2Query(source: Card): StructuredQuery {
- return {
- ...createQ1Query(source),
- aggregation: [["count"], ["sum", TOTAL_FIELD]],
- };
-}
-
// Q3 - join, custom column, no aggregations, 3 breakouts
-export function createQ3Query(source: Card): StructuredQuery {
+function createQ3Query(source: Card): StructuredQuery {
return {
...createQ1Query(source),
breakout: [
@@ -195,7 +187,7 @@ export function createQ3Query(source: Card): StructuredQuery {
}
// Q4 - join, custom column, 2 aggregations, 2 breakouts
-export function createQ4Query(source: Card): StructuredQuery {
+function createQ4Query(source: Card): StructuredQuery {
return {
...createQ3Query(source),
aggregation: [["count"], ["sum", TOTAL_FIELD]],
@@ -203,7 +195,7 @@ export function createQ4Query(source: Card): StructuredQuery {
}
// Q5 - Q4 + 2nd stage with join, custom column, no aggregations, no breakouts
-export function createQ5Query(source: Card): StructuredQuery {
+function createQ5Query(source: Card): StructuredQuery {
return {
"source-query": createQ4Query(source),
expressions: {
@@ -249,29 +241,8 @@ export function createQ5Query(source: Card): StructuredQuery {
};
}
-// Q6 - Q4 + 2nd stage with join, custom column, 2 aggregations, no breakouts
-export function createQ6Query(source: Card): StructuredQuery {
- return {
- ...createQ5Query(source),
- aggregation: [
- ["count"],
- [
- "sum",
- [
- "field",
- REVIEWS.RATING,
- {
- "base-type": "type/Integer",
- "join-alias": "Reviews - Created At: Month",
- },
- ],
- ],
- ],
- };
-}
-
// Q7 - Q4 + 2nd stage with join, custom column, no aggregations, 2 breakouts
-export function createQ7Query(source: Card): StructuredQuery {
+function createQ7Query(source: Card): StructuredQuery {
return {
...createQ5Query(source),
breakout: [
@@ -315,14 +286,6 @@ export function createQ8Query(source: Card): StructuredQuery {
};
}
-// Q9 - Q8 + 3rd stage with 1 aggregation
-export function createQ9Query(source: Card): StructuredQuery {
- return {
- "source-query": createQ8Query(source),
- aggregation: [["count"]],
- };
-}
-
type CreateQuery = (source: Card) => StructuredQuery;
export function createAndVisitDashboardWithCardMatrix(
@@ -534,12 +497,13 @@ export function setup1stStageBreakoutFilter() {
H.getDashboardCard(0).findByText("Select…").click();
H.popover().within(() => {
- getPopoverItem("Category", 1).scrollIntoView().click();
+ getPopoverItem("Product → Category", 0).scrollIntoView().click();
});
+ closeToasts();
H.getDashboardCard(1).findByText("Select…").click();
H.popover().within(() => {
- getPopoverItem("Category", 1).scrollIntoView().click();
+ getPopoverItem("Product → Category", 0).scrollIntoView().click();
});
H.saveDashboard();
@@ -696,18 +660,14 @@ export function getFilter(name: string) {
return cy.findByTestId("fixed-width-filters").findByText(name);
}
-export function getPopoverList() {
- return cy.findAllByRole("grid").eq(0);
-}
-
-export function getPopoverItems() {
+function getPopoverItems() {
return cy.get("[data-element-id=list-section]");
}
/**
* @param index if more than 1 item with the same name is visible, specify which one should be used
*/
-export function getPopoverItem(name: string, index = 0) {
+function getPopoverItem(name: string, index = 0) {
/**
* Without scrollIntoView() the popover may scroll automatically to a different
* place when clicking the item (unclear why).
@@ -765,7 +725,7 @@ type SectionName = string;
type ColumnName = string;
type MappingSection = [SectionName | null, ColumnName[]];
-export function verifyPopoverMappingOptions(sections: MappingSection[]) {
+function verifyPopoverMappingOptions(sections: MappingSection[]) {
const expectedItemsCount = sections.reduce(
(sum, [sectionName, columnNames]) =>
sum + (sectionName ? 1 : 0) + columnNames.length,
@@ -824,39 +784,3 @@ export function verifyDashcardRowsCount({
cy.wait("@dataset");
cy.findByTestId("question-row-count").should("have.text", queryBuilderCount);
}
-
-export function verifyDashcardCellValues({
- dashcardIndex,
- values,
-}: {
- dashcardIndex: number;
- values: string[];
-}) {
- for (let valueIndex = 0; valueIndex < values.length; ++valueIndex) {
- const value = values[valueIndex];
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.getDashboardCard(dashcardIndex)
- .findByTestId("table-body")
- .findAllByRole("row")
- .first()
- .findAllByTestId("cell-data")
- .eq(valueIndex)
- .should("have.text", value);
- }
-
- H.getDashboardCard(dashcardIndex)
- .findByTestId("legend-caption-title")
- .click();
- cy.wait("@dataset");
-
- for (let valueIndex = 0; valueIndex < values.length; ++valueIndex) {
- const value = values[valueIndex];
-
- // eslint-disable-next-line metabase/no-unsafe-element-filtering
- H.tableInteractiveBody()
- .findAllByTestId("cell-data")
- .eq(valueIndex)
- .should("have.text", value);
- }
-}