Skip to content

Commit

Permalink
Merge pull request #24 from ketulsha/cypress
Browse files Browse the repository at this point in the history
added retry logic for peer due to timeout error
  • Loading branch information
ketulsha authored Nov 17, 2023
2 parents 053e085 + e05e795 commit ec3a554
Showing 1 changed file with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')
});
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')
}
});

0 comments on commit ec3a554

Please sign in to comment.