diff --git a/cypress/integration/user_profile/.BlockUser.feature b/cypress/integration/User.Block.feature similarity index 61% rename from cypress/integration/user_profile/.BlockUser.feature rename to cypress/integration/User.Block.feature index b5c510286..fa68397da 100644 --- a/cypress/integration/user_profile/.BlockUser.feature +++ b/cypress/integration/User.Block.feature @@ -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 diff --git a/cypress/integration/User.Block/I_block_the_user_{string}.js b/cypress/integration/User.Block/I_block_the_user_{string}.js new file mode 100644 index 000000000..cde1d96b9 --- /dev/null +++ b/cypress/integration/User.Block/I_block_the_user_{string}.js @@ -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"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js b/cypress/integration/User.Block/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js new file mode 100644 index 000000000..f1a859bfe --- /dev/null +++ b/cypress/integration/User.Block/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js @@ -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 + }); + } +); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_follow_the_user_{string}.js b/cypress/integration/User.Block/I_follow_the_user_{string}.js new file mode 100644 index 000000000..56d50a5ae --- /dev/null +++ b/cypress/integration/User.Block/I_follow_the_user_{string}.js @@ -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"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_get_removed_from_his_follower_collection.js b/cypress/integration/User.Block/I_get_removed_from_his_follower_collection.js new file mode 100644 index 000000000..b32ca5961 --- /dev/null +++ b/cypress/integration/User.Block/I_get_removed_from_his_follower_collection.js @@ -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"); + }); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_navigate_to_my_{string}_settings_page.js b/cypress/integration/User.Block/I_navigate_to_my_{string}_settings_page.js new file mode 100644 index 000000000..4d369eab2 --- /dev/null +++ b/cypress/integration/User.Block/I_navigate_to_my_{string}_settings_page.js @@ -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(); +}); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_search_for_{string}.js b/cypress/integration/User.Block/I_search_for_{string}.js new file mode 100644 index 000000000..214cb4e33 --- /dev/null +++ b/cypress/integration/User.Block/I_search_for_{string}.js @@ -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); +}); \ No newline at end of file diff --git a/cypress/integration/User.Block/I_should_not_see_{string}_button.js b/cypress/integration/User.Block/I_should_not_see_{string}_button.js new file mode 100644 index 000000000..5bf0b7a68 --- /dev/null +++ b/cypress/integration/User.Block/I_should_not_see_{string}_button.js @@ -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) +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/I_should_see_no_users_in_my_blocked_users_list.js b/cypress/integration/User.Block/I_should_see_no_users_in_my_blocked_users_list.js new file mode 100644 index 000000000..11161ef2f --- /dev/null +++ b/cypress/integration/User.Block/I_should_see_no_users_in_my_blocked_users_list.js @@ -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.") +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/I_should_see_the_{string}_button.js b/cypress/integration/User.Block/I_should_see_the_{string}_button.js new file mode 100644 index 000000000..373800870 --- /dev/null +++ b/cypress/integration/User.Block/I_should_see_the_{string}_button.js @@ -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) +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/I_{string}_see_{string}_from_the_content_menu_in_the_user_info_box.js b/cypress/integration/User.Block/I_{string}_see_{string}_from_the_content_menu_in_the_user_info_box.js new file mode 100644 index 000000000..0f44b5192 --- /dev/null +++ b/cypress/integration/User.Block/I_{string}_see_{string}_from_the_content_menu_in_the_user_info_box.js @@ -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) +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/a_user_has_blocked_me.js b/cypress/integration/User.Block/a_user_has_blocked_me.js new file mode 100644 index 000000000..d1703407f --- /dev/null +++ b/cypress/integration/User.Block/a_user_has_blocked_me.js @@ -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"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/User.Block/they_should_not_see_the_comment_form.js b/cypress/integration/User.Block/they_should_not_see_the_comment_form.js new file mode 100644 index 000000000..962934994 --- /dev/null +++ b/cypress/integration/User.Block/they_should_not_see_the_comment_form.js @@ -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') +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/they_should_see_a_text_explaining_why_commenting_is_not_possible.js b/cypress/integration/User.Block/they_should_see_a_text_explaining_why_commenting_is_not_possible.js new file mode 100644 index 000000000..d95f3229c --- /dev/null +++ b/cypress/integration/User.Block/they_should_see_a_text_explaining_why_commenting_is_not_possible.js @@ -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.") +}) \ No newline at end of file diff --git a/cypress/integration/User.Block/{string}_wrote_a_post_{string}.js b/cypress/integration/User.Block/{string}_wrote_a_post_{string}.js new file mode 100644 index 000000000..3df7b53a6 --- /dev/null +++ b/cypress/integration/User.Block/{string}_wrote_a_post_{string}.js @@ -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', + }); +}); \ No newline at end of file diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js index 7c49aa3fb..41c9abe34 100644 --- a/cypress/integration/common/.steps.js +++ b/cypress/integration/common/.steps.js @@ -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) -}) +}); \ No newline at end of file diff --git a/cypress/integration/Admin.TagOverview/I_can_see_the_following_table.js b/cypress/integration/common/I_can_see_the_following_table.js similarity index 100% rename from cypress/integration/Admin.TagOverview/I_can_see_the_following_table.js rename to cypress/integration/common/I_can_see_the_following_table.js diff --git a/cypress/integration/Search/I_should_see_the_following_posts_in_the_select_dropdown.js b/cypress/integration/common/I_should_see_the_following_posts_in_the_select_dropdown.js similarity index 100% rename from cypress/integration/Search/I_should_see_the_following_posts_in_the_select_dropdown.js rename to cypress/integration/common/I_should_see_the_following_posts_in_the_select_dropdown.js