mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
e2e: refactor content reporting test step
- DOM-based verifycation instead of network interception timing - selective interception - flexiblevalidation
This commit is contained in:
parent
75d106e847
commit
244db720cf
@ -1,109 +1,28 @@
|
||||
import { defineStep } from '@badeball/cypress-cucumber-preprocessor'
|
||||
|
||||
defineStep('I see all the reported posts including the one from above', () => {
|
||||
cy.get('table tbody', { timeout: 30000 }).should('be.visible')
|
||||
cy.get('table tbody').within(() => {
|
||||
cy.contains('tr', 'The Truth about the Holocaust').should('be.visible')
|
||||
})
|
||||
|
||||
cy.intercept({
|
||||
method: 'POST',
|
||||
url: '/api',
|
||||
hostname: 'localhost',
|
||||
}).as('getReports')
|
||||
|
||||
cy.wait(['@getReports'],{ timeout: 30000 }).then((interception) => {
|
||||
console.log('Cypress interception:', interception)
|
||||
cy.wrap(interception.response.statusCode).should('eq', 200)
|
||||
cy.wrap(interception.request.body)
|
||||
.should('have.property', 'query', `query ($orderBy: ReportOrdering, $first: Int, $offset: Int, $reviewed: Boolean, $closed: Boolean) {
|
||||
reports(orderBy: $orderBy, first: $first, offset: $offset, reviewed: $reviewed, closed: $closed) {
|
||||
id
|
||||
createdAt
|
||||
updatedAt
|
||||
closed
|
||||
reviewed {
|
||||
createdAt
|
||||
updatedAt
|
||||
disable
|
||||
moderator {
|
||||
id
|
||||
slug
|
||||
name
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}, (req) => {
|
||||
if (req.body && req.body.query && req.body.query.includes('reports(')) {
|
||||
req.alias = 'getReports'
|
||||
}
|
||||
resource {
|
||||
__typename
|
||||
... on User {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
... on Comment {
|
||||
id
|
||||
contentExcerpt
|
||||
disabled
|
||||
deleted
|
||||
author {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
post {
|
||||
id
|
||||
slug
|
||||
title
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
... on Post {
|
||||
id
|
||||
slug
|
||||
title
|
||||
disabled
|
||||
deleted
|
||||
author {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
filed {
|
||||
submitter {
|
||||
id
|
||||
slug
|
||||
name
|
||||
disabled
|
||||
deleted
|
||||
__typename
|
||||
}
|
||||
createdAt
|
||||
reasonCategory
|
||||
reasonDescription
|
||||
__typename
|
||||
}
|
||||
__typename
|
||||
}
|
||||
}
|
||||
`
|
||||
)
|
||||
cy.wrap(interception.response.body)
|
||||
.should('have.nested.property', 'data.reports.0.resource.author.id')
|
||||
.and('equal', 'annoying-user')
|
||||
})
|
||||
|
||||
cy.get('table tbody').within(() => {
|
||||
cy.contains('tr', 'The Truth about the Holocaust')
|
||||
cy.get('@getReports.all').should('have.length.at.least', 1)
|
||||
cy.get('@getReports.all').then((interceptions) => {
|
||||
const reportsInterception = interceptions.find(interception =>
|
||||
interception.request.body.query.includes('reports(')
|
||||
)
|
||||
expect(reportsInterception).to.exist
|
||||
expect(reportsInterception.response.statusCode).to.eq(200)
|
||||
expect(reportsInterception.response.body).to.have.nested.property('data.reports.0.resource.author.id', 'annoying-user')
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user