add network waiting to several cypress steps

This commit is contained in:
mahula 2023-05-26 17:28:04 +02:00
parent a5eca59f88
commit 14ed84620b
4 changed files with 4 additions and 7 deletions

View File

@ -1,5 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import 'cypress-network-idle';
When("I click on the avatar menu in the top right corner", () => {
cy.get(".avatar-menu").click();
cy.waitForNetworkIdle(2000);
});

View File

@ -7,7 +7,6 @@ Given('somebody reported the following posts:', table => {
method: 'POST',
url: '/',
hostname: 'localhost',
port: 4000,
}).as('postToLocalhost')
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
@ -30,9 +29,6 @@ Given('somebody reported the following posts:', table => {
cy.wait(['@postToLocalhost']).then((interception) => {
cy.wrap(interception.response.statusCode).should('eq', 200)
})
cy.wait(['@postToLocalhost']).then((interception) => {
cy.wrap(interception.response.statusCode).should('eq', 200)
})
cy.wait(['@postToLocalhost']).then((interception) => {
console.log('Cypress interception:', interception)
cy.wrap(interception.response.statusCode).should('eq', 200)
@ -40,7 +36,6 @@ Given('somebody reported the following posts:', table => {
.should('have.nested.property', 'data.fileReport.reportId')
.and('match', reportIdRegex)
})
console.log('Cypress waited for fileReport request')
cy.waitForNetworkIdle(2000)
})
})

View File

@ -1,4 +1,5 @@
import { When } from "cypress-cucumber-preprocessor/steps";
import 'cypress-network-idle';
When("I click on {string}", element => {
const elementSelectors = {
@ -16,4 +17,5 @@ When("I click on {string}", element => {
cy.get(elementSelectors[element])
.click()
.wait(750);
cy.waitForNetworkIdle(2000);
});

View File

@ -50,8 +50,6 @@ Cypress.Commands.add(
{ prevSubject: true },
(graphQLClient, mutation, variables, response) => {
return new Cypress.Promise(async (resolve, reject) => {
const response = await graphQLClient.request(mutation, variables)
console.log('Cypress command mutate:', response)
graphQLClient.request(mutation, variables).then(() => resolve(graphQLClient))
})