Skip to content

Commit ab2c497

Browse files
authored
[flaky test]solution for aliases.js (#920)
* 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]>
1 parent 669ac54 commit ab2c497

File tree

1 file changed

+23
-2
lines changed
  • cypress/integration/plugins/index-management-dashboards-plugin

1 file changed

+23
-2
lines changed

cypress/integration/plugins/index-management-dashboards-plugin/aliases.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,32 @@ describe("Aliases", () => {
2626
});
2727

2828
beforeEach(() => {
29+
// Intercept the specific POST request
30+
cy.intercept("POST", "/api/ism/apiCaller", (req) => {
31+
if (req.body.data && req.body.data.name === "**" && req.body.data.s === "alias:desc" && req.body.endpoint === "cat.aliases") {
32+
req.alias = "apiCaller"; // Assign an alias directly if the condition is met
33+
}
34+
});
35+
2936
// Visit ISM OSD
3037
cy.visit(`${BASE_PATH}/app/${IM_PLUGIN_NAME}#/aliases`);
3138

32-
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
33-
cy.contains("Rows per page", { timeout: 60000 });
39+
// Wait for 120 seconds for OSD to start.
40+
// eslint-disable-next-line cypress/no-unnecessary-waiting
41+
// cy.wait(120000);
42+
43+
const startTime = new Date().getTime();
44+
45+
// Wait for the API call to complete
46+
cy.wait("@apiCaller", { timeout: 240000 }).then(() => {
47+
// Log the calculated duration
48+
const endTime = new Date().getTime();
49+
const duration = endTime - startTime; // Duration in milliseconds
50+
cy.log(`@apiCaller completed in ${duration} milliseconds`);
51+
});
52+
53+
// Common text to wait for to confirm page loaded, give up to 120 seconds for initial load
54+
cy.contains("Rows per page", { timeout: 120000 }).should("be.visible");
3455
});
3556

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

0 commit comments

Comments
 (0)