Bug 42801: Fix race condition in ERM/UsageReports_spec.ts

cy.get("#report_builder").contains("Submit").click();
cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as(
    "reportRequest"
);
cy.wait("@reportRequest");

We should intercept before the click.

Test plan:
yarn cypress run --spec t/cypress/integration/ERM/UsageReports_spec.ts
Run it several times and confirm that it always passes

The failure was:
    <testcase name="Custom reports Should show the Display by year filter when filter is required" time="0.000" classname="Should show the Display by year filter when filter is required">
      <failure message="Timed out retrying after 10000ms: `cy.wait()` timed out waiting `10000ms` for the 1st request to the route: `reportRequest`. No request ever occurred.

https://on.cypress.io/wait" type="CypressError"><![CDATA[CypressError: Timed out retrying after 10000ms: `cy.wait()` timed out waiting `10000ms` for the 1st request to the route: `reportRequest`. No request ever occurred.
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-06-09 11:29:59 +02:00 committed by Pedro Amorim
parent 393c9478a0
commit 674749c621
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 1 additions and 1 deletions

View File

@ -314,10 +314,10 @@ describe("Custom reports", () => {
cy.get("#report_type .vs__search").type("PR" + "{enter}", {
force: true,
});
cy.get("#report_builder").contains("Submit").click();
cy.intercept("GET", "/api/v1/erm/eUsage/monthly_report/*").as(
"reportRequest"
);
cy.get("#report_builder").contains("Submit").click();
cy.wait("@reportRequest");
cy.get(".yearly_filter label").contains("Display by year");