From 0e046e222ce79b9479e3d474429d1d2149aaa6bd Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 26 May 2023 12:53:18 +0200 Subject: [PATCH] add network interception to cypress test --- .../somebody_reported_the_following_posts.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js b/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js index 6d433c324..e7de8b96e 100644 --- a/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js +++ b/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js @@ -2,6 +2,12 @@ import { Given } from "cypress-cucumber-preprocessor/steps"; import 'cypress-network-idle'; Given('somebody reported the following posts:', table => { + cy.intercept({ + method: 'POST', + url: '/', + hostname: 'localhost', + }).as('postToLocalhoast') + table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => { const submitter = { email: submitterEmail, @@ -19,6 +25,19 @@ Given('somebody reported the following posts:', table => { reasonCategory, reasonDescription }) + cy.wait(['@postToLocalhoast']).then((interception) => { + cy.wrap(interception.response.statusCode).should('eq', 200) + }) + cy.wait(['@postToLocalhoast']).then((interception) => { + cy.wrap(interception.response.statusCode).should('eq', 200) + }) + cy.wait(['@postToLocalhoast']).then((interception) => { + console.log('Cypress interception:', interception) + cy.wrap(interception.response.statusCode).should('eq', 200) + cy.wrap(interception.response.body) + .should('have.nested.property', 'data.fileReport.reportId') + }) + console.log('Cypress waited for fileReport request') cy.waitForNetworkIdle(2000) }) }) \ No newline at end of file