mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Fix HidePosts.feature
This commit is contained in:
parent
a0257fc303
commit
4db242933f
@ -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 => {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user