Fix HidePosts.feature

This commit is contained in:
Robert Schäfer 2019-03-16 19:23:27 +01:00
parent a0257fc303
commit 4db242933f
4 changed files with 31 additions and 13 deletions

View File

@ -156,20 +156,30 @@ When('I press {string}', label => {
Given('we have the following posts in our database:', table => {
table.hashes().forEach(({ Author, ...postAttributes }) => {
postAttributes.deleted = Boolean(postAttributes.deleted)
postAttributes.disabled = Boolean(postAttributes.disabled)
cy.factory()
.create('User', {
const userAttributes = {
name: Author,
email: `${Author}@example.org`,
password: '1234'
})
.authenticateAs({
email: `${Author}@example.org`,
password: '1234'
})
}
postAttributes.deleted = Boolean(postAttributes.deleted)
const disabled = Boolean(postAttributes.disabled)
cy.factory()
.create('User', userAttributes)
.authenticateAs(userAttributes)
.create('Post', postAttributes)
if(disabled) {
const moderatorParams = {
email: 'moderator@example.org',
role: 'moderator',
password: '1234'
}
cy.factory()
.create('User', moderatorParams)
.authenticateAs(moderatorParams)
.mutate('mutation($id: ID!) { disable(id: $id) }', postAttributes)
}
})
})
Then('I see a success message:', message => {

View File

@ -5,10 +5,10 @@ Feature: Hide Posts
Background:
Given we have the following posts in our database:
| title | deleted | disabled |
| This post should be visible | | |
| This post is disabled | | x |
| This post is deleted | x | |
| id | title | deleted | disabled |
| p1 | This post should be visible | | |
| p2 | This post is disabled | | x |
| p3 | This post is deleted | x | |
Scenario: Disabled posts don't show up on the landing page
Given I am logged in with a "user" role

View File

@ -34,6 +34,14 @@ Cypress.Commands.add(
}
)
Cypress.Commands.add(
'mutate',
{ prevSubject: true },
(factory, mutation, variables) => {
return factory.mutate(mutation, variables)
}
)
Cypress.Commands.add(
'authenticateAs',
{ prevSubject: true },