From 370748ce55af2cf63b46a641d7190910c621df5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 27 Feb 2019 15:14:45 +0100 Subject: [PATCH] Sketch cypress test to hide posts from the public --- cypress/integration/common/steps.js | 18 +++++++++++-- .../integration/moderation/HidePosts.feature | 27 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 cypress/integration/moderation/HidePosts.feature diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index c17c2729b..ccd6ac14f 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -151,7 +151,9 @@ When('I press {string}', label => { }) Given('we have the following posts in our database:', table => { - table.hashes().forEach(({ Author, id, title, content }) => { + table.hashes().forEach(({ Author, ...postAttributes}) => { + postAttributes.deleted = Boolean(postAttributes.deleted) + postAttributes.disabled = Boolean(postAttributes.disabled) cy.factory() .create('User', { name: Author, @@ -162,7 +164,7 @@ Given('we have the following posts in our database:', table => { email: `${Author}@example.org`, password: '1234' }) - .create('Post', { id, title, content }) + .create('Post', postAttributes) }) }) @@ -212,3 +214,15 @@ Then('the post was saved successfully', () => { cy.get('.ds-card-header > .ds-heading').should('contain', lastPost.title) cy.get('.content').should('contain', lastPost.content) }) + +Then(/^I should see only ([0-9]+) posts? on the landing page/, (postCount) => { + cy.get('.post-card').should('have.length', postCount) +}) + +Then('the first post on the landing page has the title:', (title) => { + cy.get('.post-card:first').should('contain', title) +}) + +Then('I see a 404 error with the following message:', (message) => { + cy.get('.error').should('contain', message) +}) diff --git a/cypress/integration/moderation/HidePosts.feature b/cypress/integration/moderation/HidePosts.feature new file mode 100644 index 000000000..6a11eaf3b --- /dev/null +++ b/cypress/integration/moderation/HidePosts.feature @@ -0,0 +1,27 @@ +Feature: Hide Posts + As the moderator team + we'd like to be able to hide posts from the public + to enforce our network's code of conduct and/or legal regulations + + 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 | | + + Scenario: Disabled posts don't show up on the landing page + Given I am logged in with a "user" role + Then I should see only 1 post on the landing page + And the first post on the landing page has the title: + """ + This post should be visible + """ + + Scenario: Visiting a disabled post's page should return 404 + Given I am logged in with a "user" role + When I visit the "/post/this-post-is-disabled" page + Then I see a 404 error with the following message: + """ + We cannot find that post :( + """