mattwr18 8aa7f376b6 Update Post query for blockedByUsers
- Admin/Moderators see Posts even if they are blocked
2019-10-01 17:45:09 +02:00

155 lines
3.7 KiB
JavaScript

import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
/* global cy */
let lastReportTitle
let davidIrvingPostTitle = 'The Truth about the Holocaust'
let davidIrvingPostSlug = 'the-truth-about-the-holocaust'
let davidIrvingName = 'David Irving'
const savePostTitle = $post => {
return $post
.first()
.find('.ds-heading')
.first()
.invoke('text')
.then(title => {
lastReportTitle = title
})
}
Given("I see David Irving's post on the landing page", page => {
cy.openPage('landing')
})
Given("I see David Irving's post on the post page", page => {
cy.visit(`/post/${davidIrvingPostSlug}`)
cy.contains(davidIrvingPostTitle) // wait
})
Given('I am logged in with a {string} role', role => {
cy.factory().create('User', {
email: `${role}@example.org`,
password: '1234',
termsAndConditionsAgreedVersion: "0.0.2",
role
})
cy.login({
email: `${role}@example.org`,
password: '1234'
})
})
When('I click on "Report Post" from the content menu of the post', () => {
cy.contains('.ds-card', davidIrvingPostTitle)
.find('.content-menu-trigger')
.click({force: true})
cy.get('.popover .ds-menu-item-link')
.contains('Report Post')
.click()
})
When('I click on "Report User" from the content menu in the user info box', () => {
cy.contains('.ds-card', davidIrvingPostTitle)
.get('.user-content-menu .content-menu-trigger')
.click({ force: true })
cy.get('.popover .ds-menu-item-link')
.contains('Report User')
.click()
})
When('I click on the author', () => {
cy.get('.username')
.click()
.url().should('include', '/profile/')
})
When('I report the author', () => {
cy.get('.page-name-profile-id-slug').then(() => {
invokeReportOnElement('.ds-card').then(() => {
cy.get('button')
.contains('Send')
.click()
})
})
})
When('I click on send in the confirmation dialog', () => {
cy.get('button')
.contains('Send')
.click()
})
Then('I get a success message', () => {
cy.get('.iziToast-message').contains('Thanks')
})
Then('I see my reported user', () => {
cy.get('table').then(() => {
cy.get('tbody tr')
.first()
.contains(lastReportTitle.trim())
})
})
Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover')
.find('a[href="/settings"]', 'Settings')
.should('exist') // OK, the dropdown is actually open
cy.get('.avatar-menu-popover')
.find('a[href="/moderation"]', 'Moderation')
.should('not.exist')
})
When(/^I confirm the reporting dialog .*:$/, message => {
cy.contains(message) // wait for element to become visible
cy.get('.ds-modal').within(() => {
cy.get('button')
.contains('Report')
.click()
})
})
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ id }) => {
const submitter = {
email: `submitter${id}@example.org`,
password: '1234'
}
cy.factory()
.create('User', submitter)
.authenticateAs(submitter)
.mutate(`mutation($id: ID!, $description: String!) {
report(description: $description, id: $id) {
id
}
}`, {
id,
description: 'Offensive content'
})
})
})
Then('I see all the reported posts including the one from above', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', davidIrvingPostTitle)
})
})
Then('each list item links to the post page', () => {
cy.contains(davidIrvingPostTitle).click()
cy.location('pathname').should('contain', '/post')
})
When("they have a post someone has reported", () => {
cy.factory()
.create("Post", {
authorId: 'annnoying-user',
title,
});
})