diff --git a/cypress/integration/Moderator.HidePost.feature b/cypress/integration/Moderator.HidePost.feature new file mode 100644 index 000000000..0ef802267 --- /dev/null +++ b/cypress/integration/Moderator.HidePost.feature @@ -0,0 +1,40 @@ +Feature: Hide Posts + As a moderator + I would like to be able to hide posts from the public + to enforce our network's code of conduct and/or legal regulations + + Background: + Given the following "users" are in the database: + | slug | email | password | id | name | role | termsAndConditionsAgreedVersion | + | user | user@example.org | abcd | user | User-Chad | user | 0.0.4 | + | moderator | moderator@example.org | 1234 | moderator | Mod-Man | moderator | 0.0.4 | + Given the following "posts" are in the database: + | 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 newsfeed as user + When I am logged in as "user" + And I navigate to page "/" + Then I should see only 1 posts on the newsfeed + And the first post on the newsfeed has the title: + """ + This post should be visible + """ + + Scenario: Disabled posts show up on the newsfeed as moderator + When I am logged in as "moderator" + And I navigate to page "/" + Then I should see only 2 posts on the newsfeed + And the first post on the newsfeed has the title: + """ + This post is disabled + """ + + Scenario: Visiting a disabled post's page should return 404 + Given I am logged in as "user" + Then the page "/post/this-post-is-disabled" returns a 404 error with a message: + """ + This post could not be found + """ diff --git a/cypress/integration/Moderator.HidePost/I_should_see_only_{int}_posts_on_the_newsfeed.js b/cypress/integration/Moderator.HidePost/I_should_see_only_{int}_posts_on_the_newsfeed.js new file mode 100644 index 000000000..611365bb0 --- /dev/null +++ b/cypress/integration/Moderator.HidePost/I_should_see_only_{int}_posts_on_the_newsfeed.js @@ -0,0 +1,7 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("I should see only {int} posts on the newsfeed", posts => { + cy.get(".post-teaser") + .should("have.length", posts); +}); + \ No newline at end of file diff --git a/cypress/integration/Moderator.HidePost/the_page_{string}_returns_a_404_error_with_a_message.js b/cypress/integration/Moderator.HidePost/the_page_{string}_returns_a_404_error_with_a_message.js new file mode 100644 index 000000000..6d9cfb2ef --- /dev/null +++ b/cypress/integration/Moderator.HidePost/the_page_{string}_returns_a_404_error_with_a_message.js @@ -0,0 +1,14 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("the page {string} returns a 404 error with a message:", (route, message) => { + cy.request({ + url: route, + failOnStatusCode: false + }) + .its("status") + .should("eq", 404); + cy.visit(route, { + failOnStatusCode: false + }); + cy.get(".error-message").should("contain", message); +}); \ No newline at end of file diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js index 975bc06a4..7c49aa3fb 100644 --- a/cypress/integration/common/.steps.js +++ b/cypress/integration/common/.steps.js @@ -76,26 +76,6 @@ When("I click on the avatar menu in the top right corner", () => { cy.get(".avatar-menu").click(); }); -Then(/^I should see only ([0-9]+) posts? on the newsfeed/, postCount => { - cy.get(".post-teaser").should("have.length", postCount); -}); - -Then( - "the page {string} returns a 404 error with a message:", - (route, message) => { - cy.request({ - url: route, - failOnStatusCode: false - }) - .its("status") - .should("eq", 404); - cy.visit(route, { - failOnStatusCode: false - }); - cy.get(".error-message").should("contain", message); - } -); - Given("there is an annoying user called {string}", name => { cy.factory().build("user", { id: "annoying-user", diff --git a/cypress/integration/Admin.PinPost/the_first_post_on_the_newsfeed_has_the_title.js b/cypress/integration/common/the_first_post_on_the_newsfeed_has_the_title.js similarity index 100% rename from cypress/integration/Admin.PinPost/the_first_post_on_the_newsfeed_has_the_title.js rename to cypress/integration/common/the_first_post_on_the_newsfeed_has_the_title.js diff --git a/cypress/integration/common/the_following_{string}_are_in_the_database.js b/cypress/integration/common/the_following_{string}_are_in_the_database.js index 547166a91..1d17ec686 100644 --- a/cypress/integration/common/the_following_{string}_are_in_the_database.js +++ b/cypress/integration/common/the_following_{string}_are_in_the_database.js @@ -11,7 +11,7 @@ Given("the following {string} are in the database:", (table,data) => { pinned: Boolean(entry.pinned), },{ ...entry, - tagIds: entry.tagIds.split(',').map(item => item.trim()), + tagIds: entry.tagIds ? entry.tagIds.split(',').map(item => item.trim()) : [], }); }) break diff --git a/cypress/integration/moderation/.HidePosts.feature b/cypress/integration/moderation/.HidePosts.feature deleted file mode 100644 index cb748062f..000000000 --- a/cypress/integration/moderation/.HidePosts.feature +++ /dev/null @@ -1,26 +0,0 @@ -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: - | 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 newsfeed - Given I am logged in with a "user" role - Then I should see only 1 post on the newsfeed - And the first post on the newsfeed 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 - Then the page "/post/this-post-is-disabled" returns a 404 error with a message: - """ - This post could not be found - """