Skip to content
Snippets Groups Projects
Unverified Commit 719f3ed6 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

e2e: Fix dashboard number filter flakes (#46785)

* Try to fix dashboard-filters-number flake

* Try to fix dashboard-filters-number flake

* Intercept all dashboard data requests for number filters
parent 02f5a20e
No related branches found
No related tags found
No related merge requests found
import { import { ORDERS_DASHBOARD_ID } from "e2e/support/cypress_sample_instance_data";
ORDERS_DASHBOARD_ID,
ORDERS_DASHBOARD_DASHCARD_ID,
} from "e2e/support/cypress_sample_instance_data";
import { import {
restore, restore,
popover, popover,
...@@ -35,6 +32,18 @@ describe("scenarios > dashboard > filters > number", () => { ...@@ -35,6 +32,18 @@ describe("scenarios > dashboard > filters > number", () => {
visitDashboard(ORDERS_DASHBOARD_ID); visitDashboard(ORDERS_DASHBOARD_ID);
editDashboard(); editDashboard();
/**
* Even though we're already intercepting this route in the visitDashboard helper,
* it is important to alias it differently here, and to then wait for it in tests.
*
* The place where the intercept is first set matters.
* If we set it before the visitDashboard, we'd have to wait for it after the visit,
* otherwise we'd always be one wait behind in tests.
*/
cy.intercept("POST", "api/dashboard/*/dashcard/*/card/*/query").as(
"dashboardData",
);
}); });
it("should work when set through the filter widget", () => { it("should work when set through the filter widget", () => {
...@@ -53,19 +62,19 @@ describe("scenarios > dashboard > filters > number", () => { ...@@ -53,19 +62,19 @@ describe("scenarios > dashboard > filters > number", () => {
}); });
saveDashboard(); saveDashboard();
cy.wait("@dashboardData");
DASHBOARD_NUMBER_FILTERS.forEach( DASHBOARD_NUMBER_FILTERS.forEach(
({ operator, value, representativeResult }, index) => { ({ operator, value, representativeResult }, index) => {
filterWidget().eq(index).click(); filterWidget().eq(index).click();
addWidgetNumberFilter(value); addWidgetNumberFilter(value);
cy.wait("@dashboardData");
cy.log(`Make sure ${operator} filter returns correct result`); cy.log(`Make sure ${operator} filter returns correct result`);
cy.findByTestId("dashcard").within(() => { cy.findByTestId("dashcard").should("contain", representativeResult);
cy.findByText(representativeResult);
});
clearFilterWidget(index); clearFilterWidget(index);
cy.wait(`@dashcardQuery${ORDERS_DASHBOARD_DASHCARD_ID}`); cy.wait("@dashboardData");
}, },
); );
}); });
...@@ -79,20 +88,22 @@ describe("scenarios > dashboard > filters > number", () => { ...@@ -79,20 +88,22 @@ describe("scenarios > dashboard > filters > number", () => {
addWidgetNumberFilter("2.07"); addWidgetNumberFilter("2.07");
saveDashboard(); saveDashboard();
cy.wait("@dashboardData");
cy.findByTestId("dashcard").within(() => { cy.findByTestId("dashcard")
cy.findByText("37.65"); .should("contain", "37.65")
}); .and("not.contain", "101.04");
clearFilterWidget(); clearFilterWidget();
cy.wait("@dashboardData");
filterWidget().click(); filterWidget().click();
addWidgetNumberFilter("5.27", { buttonLabel: "Update filter" }); addWidgetNumberFilter("5.27", { buttonLabel: "Update filter" });
cy.wait("@dashboardData");
cy.findByTestId("dashcard").within(() => { cy.findByTestId("dashcard")
cy.findByText("101.04"); .should("contain", "101.04")
}); .and("not.contain", "37.65");
}); });
it("should support being required", () => { it("should support being required", () => {
...@@ -120,15 +131,18 @@ describe("scenarios > dashboard > filters > number", () => { ...@@ -120,15 +131,18 @@ describe("scenarios > dashboard > filters > number", () => {
addWidgetNumberFilter("2.07", { buttonLabel: "Update filter" }); addWidgetNumberFilter("2.07", { buttonLabel: "Update filter" });
saveDashboard(); saveDashboard();
cy.wait("@dashboardData");
ensureDashboardCardHasText("37.65"); ensureDashboardCardHasText("37.65");
// Updates the filter value // Updates the filter value
setFilterWidgetValue("5.27", "Enter a number"); setFilterWidgetValue("5.27", "Enter a number");
cy.wait("@dashboardData");
ensureDashboardCardHasText("95.77"); ensureDashboardCardHasText("95.77");
// Resets the value back by clicking widget icon // Resets the value back by clicking widget icon
resetFilterWidgetToDefault(); resetFilterWidgetToDefault();
filterWidget().findByText("2.07"); filterWidget().findByText("2.07");
cy.wait("@dashboardData");
ensureDashboardCardHasText("37.65"); ensureDashboardCardHasText("37.65");
// Removing value resets back to default // Removing value resets back to default
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment