Moderator.HidePost.feature

This commit is contained in:
Ulf Gebhardt 2021-04-11 20:37:08 +02:00
parent 8a3af923c6
commit d719b0c65c
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
7 changed files with 62 additions and 47 deletions

View File

@ -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
"""

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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",

View File

@ -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

View File

@ -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
"""