From e05e795a5d6ed9af09e6fdf0e9be0f5aec80f81d Mon Sep 17 00:00:00 2001 From: Ketul Shah Date: Fri, 17 Nov 2023 19:06:28 +0530 Subject: [PATCH] added retry logic for peer due to timeout error Signed-off-by: Ketul Shah --- .../step_definitions/notifcation_steps.js | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/packages/apollo/test/cypress/support/step_definitions/notifcation_steps.js b/packages/apollo/test/cypress/support/step_definitions/notifcation_steps.js index b9610496..fda2bbb7 100644 --- a/packages/apollo/test/cypress/support/step_definitions/notifcation_steps.js +++ b/packages/apollo/test/cypress/support/step_definitions/notifcation_steps.js @@ -16,7 +16,36 @@ /* eslint-disable new-cap */ import { Given, Then, When } from "@badeball/cypress-cucumber-preprocessor"; +import { exit } from "process"; -Then(/^I should see a success toast with class (?:'|")(.*?)(?:'|") which says (?:'|")(.*?)(?:'|")$/, (className, expectedMessage) => { - cy.get(className, { timeout: 60000 }).contains(expectedMessage).should('be.visible') -}); \ No newline at end of file +Then(/^I should see a success toast with class (?:'|")(.*?)(?:'|") which says (?:'|")(.*?)(?:'|")$/, (className, expectedMessage) => { + // Retry logic as sometimes timeout error is displayed while creating peer and retry works + if (expectedMessage.includes('Peer')) + { + let found = false + for(let i = 0; i<10;i++){ + if (found == false) + { + cy.wait(2000) + cy.log('Checking if error displayed') + cy.get('body').then(($body) => { + if ($body.find('.ibp-side-panel-error-details').length) { + cy.get(`button[id="submit"]`).click() + cy.wait(6000) + cy.get(className, { timeout: 60000 }).contains(expectedMessage).should('be.visible') + found = true + } + }) + cy.log('Checking for success toast') + cy.get('body').then(($body) => { + if ($body.find(className).length) { + cy.get(className, { timeout: 60000 }).contains(expectedMessage).should('be.visible') + found = true + } + }) + } + } + }else{ + cy.get(className, { timeout: 60000 }).contains(expectedMessage).should('be.visible') + } +});