User.Block.feature

This commit is contained in:
Ulf Gebhardt 2021-04-12 00:26:20 +02:00
parent 2df140612a
commit ec6a1f1e4e
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
18 changed files with 140 additions and 159 deletions

View File

@ -1,16 +1,21 @@
Feature: Block a User
Feature: User - block an user
As a user
I'd like to have a button to block another user
To prevent him from seeing and interacting with my contributions
Background:
Given I have a user account
And there is an annoying user called "Harassing User"
And I am logged in
Given the following "users" are in the database:
| email | password | id | name | slug | termsAndConditionsAgreedVersion |
| peterpan@example.org | 123 | id-of-peter-pan | Peter Pan | peter-pan | 0.0.4 |
| user@example.org | 123 | harassing-user | Harassing User | harassing-user | 0.0.4 |
And the following "posts" are in the database:
| id | title | slug | authorId |
| bWBjpkTKZp | previously created post | previously-created-post | id-of-peter-pan |
And I am logged in as "peter-pan"
Scenario: Block a user
Given I am on the profile page of the annoying user
When I click on "Block user" from the content menu in the user info box
When I navigate to page "profile/harassing-user"
And I click on "Block user" from the content menu in the user info box
And I "should" see "Unblock user" from the content menu in the user info box
And I navigate to my "Blocked users" settings page
Then I can see the following table:
@ -19,14 +24,14 @@ Feature: Block a User
Scenario: Blocked user cannot interact with my contributions
Given I block the user "Harassing User"
And I previously created a post
And a blocked user visits the post page of one of my authored posts
And I am logged in as "harassing-user"
And I navigate to page "/post/previously-created-post"
Then they should see a text explaining why commenting is not possible
And they should not see the comment form
Scenario: Block a previously followed user
Given I follow the user "Harassing User"
When I visit the profile page of the annoying user
When I navigate to page "/profile/harassing-user"
And I click on "Block user" from the content menu in the user info box
And I get removed from his follower collection
And I "should" see "Unblock user" from the content menu in the user info box
@ -40,21 +45,23 @@ Feature: Block a User
| You can still see my posts |
Scenario: Blocked users can still see my posts
Given I previously created a post
And I block the user "Harassing User"
And the "blocked" user searches for "previously created"
When I block the user "Harassing User"
And I am logged in as "harassing-user"
And I navigate to page "/"
And I search for "previously created"
Then I should see the following posts in the select dropdown:
| title |
| previously created post |
Scenario: Blocked users cannot see they are blocked in their list
Given a user has blocked me
And I navigate to page "/"
And I navigate to my "Blocked users" settings page
Then I should see no users in my blocked users list
Scenario: Blocked users should not see link or button to unblock, only blocking users
Given a user has blocked me
When I visit the profile page of the annoying user
When I navigate to page "/profile/harassing-user"
And I should see the "Follow" button
And I should not see "Unblock user" button
And I "should not" see "Unblock user" from the content menu in the user info box

View File

@ -0,0 +1,11 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I block the user {string}", name => {
cy.neode()
.first("User", { name })
.then(blockedUser => {
cy.neode()
.first("User", {id: "id-of-peter-pan"})
.relateTo(blockedUser, "blocked");
});
});

View File

@ -0,0 +1,12 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I click on {string} from the content menu in the user info box",
button => {
cy.get(".user-content-menu .base-button").click();
cy.get(".popover .ds-menu-item-link")
.contains(button)
.click({
force: true
});
}
);

View File

@ -0,0 +1,11 @@
Given("I follow the user {string}", name => {
cy.neode()
.first("User", {name})
.then(followed => {
cy.neode()
.first("User", {
name: "Peter Pan"
})
.relateTo(followed, "following");
});
});

View File

@ -0,0 +1,8 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("I get removed from his follower collection", () => {
cy.get(".base-card")
.not(".post-link");
cy.get(".main-container")
.contains(".base-card","is not followed by anyone");
});

View File

@ -0,0 +1,10 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I navigate to my {string} settings page", settingsPage => {
cy.get(".avatar-menu-trigger").click();
cy.get(".avatar-menu-popover")
.find("a[href]")
.contains("Settings")
.click();
cy.contains(".ds-menu-item-link", settingsPage).click();
});

View File

@ -0,0 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I search for {string}", postTitle => {
cy.get(".searchable-input .ds-select input")
.focus()
.type(postTitle);
});

View File

@ -0,0 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('I should not see {string} button', button => {
cy.get('.base-card .action-buttons')
.should('have.length', 1)
})

View File

@ -0,0 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("I should see no users in my blocked users list", () => {
cy.get('.ds-placeholder')
.should('contain', "So far, you have not blocked anybody.")
})

View File

@ -0,0 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('I should see the {string} button', button => {
cy.get('.base-card .action-buttons .base-button')
.should('contain', button)
})

View File

@ -0,0 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("I {string} see {string} from the content menu in the user info box", (condition, link) => {
cy.get(".user-content-menu .base-button").click()
cy.get(".popover .ds-menu-item-link")
.should(condition === 'should' ? 'contain' : 'not.contain', link)
})

View File

@ -0,0 +1,15 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("a user has blocked me", () => {
cy.neode()
.first("User", {
name: "Peter Pan"
})
.then(blockedUser => {
cy.neode()
.first("User", {
name: 'Harassing User'
})
.relateTo(blockedUser, "blocked");
});
});

View File

@ -0,0 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("they should not see the comment form", () => {
cy.get(".base-card").children().should('not.have.class', 'comment-form')
})

View File

@ -0,0 +1,5 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then("they should see a text explaining why commenting is not possible", () => {
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
})

View File

@ -0,0 +1,10 @@
import { Given } from "cypress-cucumber-preprocessor/steps";
Given('{string} wrote a post {string}', (_, title) => {
cy.factory()
.build("post", {
title,
}, {
authorId: 'harassing-user',
});
});

View File

@ -17,40 +17,8 @@ const annoyingParams = {
password: "1234",
};
Given("the {string} user searches for {string}", (_, postTitle) => {
cy.logout()
cy.neode()
.first("User", {
id: "annoying-user"
})
.then(user => {
return new Cypress.Promise((resolve, reject) => {
return user.toJson().then((user) => resolve(user))
})
})
.then(user => cy.login(user))
cy.get(".searchable-input .ds-select input")
.focus()
.type(postTitle);
});
When("I log out", cy.logout);
When("a blocked user visits the post page of one of my authored posts", () => {
cy.logout()
cy.neode()
.first("User", {
name: 'Harassing User'
})
.then(user => {
return new Cypress.Promise((resolve, reject) => {
return user.toJson().then((user) => resolve(user))
})
})
.then(user => cy.login(user))
cy.openPage('post/previously-created-post')
})
When(`I click on the menu item {string}`, linkOrButton => {
cy.contains(".ds-menu-item", linkOrButton).click();
});
@ -102,71 +70,15 @@ Given("I am on the profile page of the annoying user", name => {
cy.openPage("profile/annoying-user/spammy-spammer");
});
When("I visit the profile page of the annoying user", name => {
cy.openPage("profile/annoying-user");
});
When("I ", name => {
cy.openPage("profile/annoying-user");
});
When(
"I click on {string} from the content menu in the user info box",
button => {
cy.get(".user-content-menu .base-button").click();
cy.get(".popover .ds-menu-item-link")
.contains(button)
.click({
force: true
});
}
);
When("I navigate to my {string} settings page", settingsPage => {
cy.get(".avatar-menu-trigger").click();
cy.get(".avatar-menu-popover")
.find("a[href]")
.contains("Settings")
.click();
cy.contains(".ds-menu-item-link", settingsPage).click();
});
Given("I follow the user {string}", name => {
cy.neode()
.first("User", {
name
})
.then(followed => {
cy.neode()
.first("User", {
name: narratorParams.name
})
.relateTo(followed, "following");
});
});
Given('{string} wrote a post {string}', (_, title) => {
cy.factory()
.build("post", {
title,
}, {
authorId: 'annoying-user',
});
});
Then("the list of posts of this user is empty", () => {
cy.get(".base-card").not(".post-link");
cy.get(".main-container").find(".ds-space.hc-empty");
});
Then("I get removed from his follower collection", () => {
cy.get(".base-card").not(".post-link");
cy.get(".main-container").contains(
".base-card",
"is not followed by anyone"
);
});
Given("I wrote a post {string}", title => {
cy.factory()
.build("post", {
@ -190,66 +102,9 @@ When("I mute the user {string}", name => {
});
});
When("I block the user {string}", name => {
cy.neode()
.first("User", {
name
})
.then(blockedUser => {
cy.neode()
.first("User", {
id: narratorParams.id
})
.relateTo(blockedUser, "blocked");
});
});
When("a user has blocked me", () => {
cy.neode()
.first("User", {
name: narratorParams.name
})
.then(blockedUser => {
cy.neode()
.first("User", {
name: 'Harassing User'
})
.relateTo(blockedUser, "blocked");
});
});
Then("I see only one post with the title {string}", title => {
cy.get(".main-container")
.find(".post-link")
.should("have.length", 1);
cy.get(".main-container").contains(".post-link", title);
});
Then("they should not see the comment form", () => {
cy.get(".base-card").children().should('not.have.class', 'comment-form')
})
Then("they should see a text explaining why commenting is not possible", () => {
cy.get('.ds-placeholder').should('contain', "Commenting is not possible at this time on this post.")
})
Then("I should see no users in my blocked users list", () => {
cy.get('.ds-placeholder')
.should('contain', "So far, you have not blocked anybody.")
})
Then("I {string} see {string} from the content menu in the user info box", (condition, link) => {
cy.get(".user-content-menu .base-button").click()
cy.get(".popover .ds-menu-item-link")
.should(condition === 'should' ? 'contain' : 'not.contain', link)
})
Then('I should not see {string} button', button => {
cy.get('.base-card .action-buttons')
.should('have.length', 1)
})
Then('I should see the {string} button', button => {
cy.get('.base-card .action-buttons .base-button')
.should('contain', button)
})
});