mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refactor most of report cucumber feature
This commit is contained in:
parent
5e0d245b40
commit
233c6abbab
@ -9,13 +9,13 @@ Feature: Report and Moderate
|
||||
|
||||
Background:
|
||||
Given we have the following posts in our database:
|
||||
| Author | Title | Content | Slug |
|
||||
| David Irving | The Truth about the Holocaust | It never existed! | the-truth-about-the-holocaust |
|
||||
| Author | title | content |
|
||||
| David Irving | The Truth about the Holocaust | It never existed! |
|
||||
|
||||
Scenario Outline: Report a post from various pages
|
||||
Given I am logged in with a "user" role
|
||||
And I see David Irving's post on the <Page>
|
||||
When I click on "Report Contribution" from the triple dot menu of the post
|
||||
When I see David Irving's post on the <Page>
|
||||
And I click on "Report Contribution" from the triple dot menu of the post
|
||||
And I confirm the reporting dialog because it is a criminal act under German law:
|
||||
"""
|
||||
Do you really want to report the contribution "The Truth about the Holocaust"?
|
||||
|
||||
@ -3,9 +3,9 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
|
||||
/* global cy */
|
||||
|
||||
let lastReportTitle
|
||||
let dummyReportedPostTitle = 'Hacker, Freaks und Funktionäre'
|
||||
let dummyReportedPostSlug = 'hacker-freaks-und-funktionareder-ccc'
|
||||
let dummyAuthorName = 'Jenny Rostock'
|
||||
let davidIrvingPostTitle = 'The Truth about the Holocaust'
|
||||
let davidIrvingPostSlug = 'the-truth-about-the-holocaust'
|
||||
let davidIrvingName = 'David Irving'
|
||||
|
||||
const savePostTitle = $post => {
|
||||
return $post
|
||||
@ -23,21 +23,27 @@ Given("I see David Irving's post on the landing page", page => {
|
||||
})
|
||||
|
||||
Given("I see David Irving's post on the post page", page => {
|
||||
cy.visit(`/post/${dummyReportedPostSlug}`)
|
||||
cy.contains(dummyReportedPostTitle) // wait
|
||||
cy.visit(`/post/${davidIrvingPostSlug}`)
|
||||
cy.contains(davidIrvingPostTitle) // wait
|
||||
})
|
||||
|
||||
Given('I am logged in with a {string} role', role => {
|
||||
cy.loginAs(role)
|
||||
cy.factory().create('user', {
|
||||
email: `${role}@example.org`,
|
||||
password: '1234',
|
||||
role
|
||||
})
|
||||
cy.login({
|
||||
email: `${role}@example.org`,
|
||||
password: '1234',
|
||||
})
|
||||
})
|
||||
|
||||
When(
|
||||
'I click on "Report Contribution" from the triple dot menu of the post',
|
||||
() => {
|
||||
//TODO: match the created post title, not a dummy post title
|
||||
cy.contains('.ds-card', dummyReportedPostTitle)
|
||||
cy.contains('.ds-card', davidIrvingPostTitle)
|
||||
.find('.content-menu-trigger')
|
||||
.find(':nth-child(2)')
|
||||
.click()
|
||||
|
||||
cy.get('.popover .ds-menu-item-link')
|
||||
@ -49,8 +55,7 @@ When(
|
||||
When(
|
||||
'I click on "Report User" from the triple dot menu in the user info box',
|
||||
() => {
|
||||
//TODO: match the created post author, not a dummy author
|
||||
cy.contains('.ds-card', dummyAuthorName)
|
||||
cy.contains('.ds-card', davidIrvingName)
|
||||
.find('.content-menu-trigger')
|
||||
.first()
|
||||
.click()
|
||||
@ -111,7 +116,7 @@ When(/^I confirm the reporting dialog .*:$/, () => {
|
||||
//TODO: match the right post
|
||||
const message = 'Do you really want to report the'
|
||||
cy.contains(message) // wait for element to become visible
|
||||
//TODO: cy.get('.ds-modal').contains(dummyReportedPostTitle)
|
||||
//TODO: cy.get('.ds-modal').contains(davidIrvingPostTitle)
|
||||
cy.get('.ds-modal').within(() => {
|
||||
cy.get('button')
|
||||
.contains('Send Report')
|
||||
@ -120,22 +125,37 @@ When(/^I confirm the reporting dialog .*:$/, () => {
|
||||
})
|
||||
|
||||
Given('somebody reported the following posts:', table => {
|
||||
table.hashes().forEach(row => {
|
||||
//TODO: calll factory here
|
||||
// const options = Object.assign({}, row, { reported: true })
|
||||
//create('post', options)
|
||||
table.hashes().forEach(({slug}, index) => {
|
||||
const author = {
|
||||
id: `author${index}`,
|
||||
email: `author${index}@example.org`,
|
||||
password: '1234'
|
||||
}
|
||||
const reporter = {
|
||||
id: `reporter${index}`,
|
||||
email: `reporter${index}@example.org`,
|
||||
password: '1234'
|
||||
}
|
||||
cy.factory()
|
||||
.create('user', author)
|
||||
.authenticateAs(author)
|
||||
.create('post', { id: `p${index}` })
|
||||
cy.factory()
|
||||
.create('user', reporter)
|
||||
.authenticateAs(reporter)
|
||||
.create('report', { description: 'I don\'t like this post', resource: { id: `p${index}`, type: 'post' } })
|
||||
})
|
||||
})
|
||||
|
||||
Then('I see all the reported posts including the one from above', () => {
|
||||
//TODO: match the right post
|
||||
cy.get('table tbody').within(() => {
|
||||
cy.contains('tr', dummyReportedPostTitle)
|
||||
cy.contains('tr', davidIrvingPostTitle)
|
||||
})
|
||||
})
|
||||
|
||||
Then('each list item links to the post page', () => {
|
||||
//TODO: match the right post
|
||||
cy.contains(dummyReportedPostTitle).click()
|
||||
cy.contains(davidIrvingPostTitle).click()
|
||||
cy.location('pathname').should('contain', '/post')
|
||||
})
|
||||
|
||||
@ -18,9 +18,6 @@ const narratorParams = {
|
||||
Given('I am logged in', () => {
|
||||
cy.login(loginCredentials)
|
||||
})
|
||||
Given('I am logged in as {string}', userType => {
|
||||
cy.loginAs(userType)
|
||||
})
|
||||
|
||||
Given('we have a selection of tags and categories as well as posts', () => {
|
||||
cy.factory()
|
||||
@ -128,9 +125,18 @@ When('I press {string}', label => {
|
||||
})
|
||||
|
||||
Given('we have the following posts in our database:', table => {
|
||||
table.hashes().forEach(row => {
|
||||
//TODO: calll factory here
|
||||
//create('post', row)
|
||||
table.hashes().forEach(({Author, title, content}) => {
|
||||
cy.factory()
|
||||
.create('user', {
|
||||
name: Author,
|
||||
email: `${Author}@example.org`,
|
||||
password: '1234'
|
||||
})
|
||||
.authenticateAs({
|
||||
email: `${Author}@example.org`,
|
||||
password: '1234'
|
||||
})
|
||||
.create('post', { title, content })
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user