Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Psami-wondah committed Jul 16, 2024
1 parent d32bbad commit ba76d03
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 143 deletions.
31 changes: 3 additions & 28 deletions cypress/e2e/datasets/access-to-funding.page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,8 @@ const interceptAllRequests = () => {
cy.intercept(`${apiUrl}/**`).as("apiData");
};

// @ts-ignore
const interceptRequests = () => {
const apiUrl = Cypress.env("api_url");

cy.intercept(`${apiUrl}/allocations/cumulative-by-cycles`).as(
"allocationCycle"
);
cy.intercept(`${apiUrl}/eligibility/stats/**`).as("eligibilityStats");
cy.intercept(`${apiUrl}/eligibility/table`).as("eligibilityTable");
cy.intercept(`${apiUrl}/allocations/sunburst`).as("allocationSunburst");
cy.intercept(`${apiUrl}/allocations/table`).as("allocationTable");
cy.intercept(`${apiUrl}/allocations/treemap`).as("allocationTreemap");
cy.intercept(`${apiUrl}/funding-requests`).as("fundingRequests");
};
// @ts-ignore
const waitData = (requestCount: number) => {
if (requestCount === 0) {
cy.wait("@allocationCycle");
cy.wait("@eligibilityStats");
cy.wait("@eligibilityTable");
cy.wait("@allocationSunburst");
cy.wait("@allocationTable");
cy.wait("@allocationTreemap");
cy.wait("@fundingRequests");
return;
}
for (let i = 0; i < requestCount; i++) {
cy.wait("@apiData");
}
Expand All @@ -43,13 +19,12 @@ describe(
() => {
beforeEach(() => {
interceptAllRequests();
interceptRequests();

cy.visit("/");
waitData(11);
waitData(22);
cy.contains("[data-cy=header-menu-button]", "Datasets").click();
cy.contains("[data-cy=header-menu-button]", "Access to Funding").click();
waitData(0);
waitData(8);
});

it("displays the header", { scrollBehavior: "nearest" }, () => {
Expand All @@ -72,7 +47,7 @@ describe(
cy.contains('[data-cy="category-dropdown-item"]', "2022").click();
});

cy.wait("@eligibilityStats");
waitData(1);

cy.contains('[data-cy="category-dropdown-button"]', "2022").should(
"be.visible"
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/datasets/annual-results.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("Testing The Location page", () => {
interceptAllRequests();

cy.visit("/");
waitData(11);
waitData(22);
cy.contains("[data-cy=header-menu-button]", "Datasets").click();
cy.contains("[data-cy=header-menu-button]", "Annual Results").click();
waitData(4);
Expand Down
Loading

0 comments on commit ba76d03

Please sign in to comment.