Skip to content

Commit

Permalink
[flaky test]solution for aliases.js (#920)
Browse files Browse the repository at this point in the history
* wait added for api call before cy.contains

Signed-off-by: kohinoor98 <[email protected]>

* adding an arbitrary wait for aliases.js

Signed-off-by: kohinoor98 <[email protected]>

* optimised beforeEach and increased wait time

Signed-off-by: kohinoor98 <[email protected]>

* increasing timeout and custom impl for retry

Signed-off-by: kohinoor98 <[email protected]>

* revert retry logic

Signed-off-by: kohinoor98 <[email protected]>

* added log for apiCaller and removed wait for osd

Signed-off-by: kohinoor98 <[email protected]>

---------

Signed-off-by: kohinoor98 <[email protected]>
  • Loading branch information
kohinoor98 authored Nov 17, 2023
1 parent 669ac54 commit ab2c497
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,32 @@ describe("Aliases", () => {
});

beforeEach(() => {
// Intercept the specific POST request
cy.intercept("POST", "/api/ism/apiCaller", (req) => {
if (req.body.data && req.body.data.name === "**" && req.body.data.s === "alias:desc" && req.body.endpoint === "cat.aliases") {
req.alias = "apiCaller"; // Assign an alias directly if the condition is met
}
});

// Visit ISM OSD
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/aliases`);

// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
cy.contains("Rows per page", { timeout: 60000 });
// Wait for 120 seconds for OSD to start.
// eslint-disable-next-line cypress/no-unnecessary-waiting
// cy.wait(120000);

const startTime = new Date().getTime();

// Wait for the API call to complete
cy.wait("@apiCaller", { timeout: 240000 }).then(() => {
// Log the calculated duration
const endTime = new Date().getTime();
const duration = endTime - startTime; // Duration in milliseconds
cy.log(`@apiCaller completed in ${duration} milliseconds`);
});

// Common text to wait for to confirm page loaded, give up to 120 seconds for initial load
cy.contains("Rows per page", { timeout: 120000 }).should("be.visible");
});

describe("can be searched / sorted / paginated", () => {
Expand Down

0 comments on commit ab2c497

Please sign in to comment.