Report feature uses factories

This commit is contained in:
Robert Schäfer 2019-02-25 19:59:16 +01:00
parent cec78c1954
commit cf898d5417
3 changed files with 9 additions and 19 deletions

View File

@ -9,8 +9,8 @@ Feature: Report and Moderate
Background:
Given we have the following posts in our database:
| Author | title | content |
| David Irving | The Truth about the Holocaust | It never existed! |
| Author | id | title | content |
| David Irving | p1 | 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
@ -45,8 +45,8 @@ Feature: Report and Moderate
Scenario: Review reported content
Given somebody reported the following posts:
| Slug |
| the-truth-about-the-holocaust |
| id |
| p1 |
And I am logged in with a "moderator" role
When I click on the avatar menu in the top right corner
And I click on "Moderation"

View File

@ -125,27 +125,17 @@ When(/^I confirm the reporting dialog .*:$/, () => {
})
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ slug }, index) => {
const author = {
id: `author${index}`,
email: `author${index}@example.org`,
password: '1234'
}
table.hashes().forEach(({ id }) => {
const reporter = {
id: `reporter${index}`,
email: `reporter${index}@example.org`,
email: `reporter${id}@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' }
resource: { id, type: 'contribution' }
})
})
})

View File

@ -139,7 +139,7 @@ When('I press {string}', label => {
})
Given('we have the following posts in our database:', table => {
table.hashes().forEach(({ Author, title, content }) => {
table.hashes().forEach(({ Author, id, title, content }) => {
cy.factory()
.create('user', {
name: Author,
@ -150,7 +150,7 @@ Given('we have the following posts in our database:', table => {
email: `${Author}@example.org`,
password: '1234'
})
.create('post', { title, content })
.create('post', { id, title, content })
})
})