diff --git a/cypress/support/step_definitions/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js b/cypress/support/step_definitions/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js index 40d018f6a..dda881f10 100644 --- a/cypress/support/step_definitions/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js +++ b/cypress/support/step_definitions/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js @@ -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') }) })