mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
add network interception to cypress test
This commit is contained in:
parent
0e046e222c
commit
7528d32dfc
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"projectId": "qa7fe2",
|
"projectId": "qa7fe2",
|
||||||
"defaultCommandTimeout": 180000,
|
"defaultCommandTimeout": 5000,
|
||||||
"pageLoadTimeout": 180000,
|
"pageLoadTimeout": 180000,
|
||||||
"ignoreTestFiles": "*.js",
|
"ignoreTestFiles": "*.js",
|
||||||
"chromeWebSecurity": false,
|
"chromeWebSecurity": false,
|
||||||
|
|||||||
@ -2,10 +2,12 @@ import { Given } from "cypress-cucumber-preprocessor/steps";
|
|||||||
import 'cypress-network-idle';
|
import 'cypress-network-idle';
|
||||||
|
|
||||||
Given('somebody reported the following posts:', table => {
|
Given('somebody reported the following posts:', table => {
|
||||||
|
const reportIdRegex = /^[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}$/
|
||||||
cy.intercept({
|
cy.intercept({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/',
|
url: '/',
|
||||||
hostname: 'localhost',
|
hostname: 'localhost',
|
||||||
|
port: 4000,
|
||||||
}).as('postToLocalhoast')
|
}).as('postToLocalhoast')
|
||||||
|
|
||||||
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
|
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
|
||||||
@ -36,6 +38,7 @@ Given('somebody reported the following posts:', table => {
|
|||||||
cy.wrap(interception.response.statusCode).should('eq', 200)
|
cy.wrap(interception.response.statusCode).should('eq', 200)
|
||||||
cy.wrap(interception.response.body)
|
cy.wrap(interception.response.body)
|
||||||
.should('have.nested.property', 'data.fileReport.reportId')
|
.should('have.nested.property', 'data.fileReport.reportId')
|
||||||
|
.and('match', reportIdRegex)
|
||||||
})
|
})
|
||||||
console.log('Cypress waited for fileReport request')
|
console.log('Cypress waited for fileReport request')
|
||||||
cy.waitForNetworkIdle(2000)
|
cy.waitForNetworkIdle(2000)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user