From c6bca8d9fb3b2bd6698f7ea626c6035a69844671 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 12 Apr 2021 01:04:32 +0200 Subject: [PATCH] User.Mute.feature --- cypress/integration/User.Block.feature | 2 +- .../.Mute.feature => User.Mute.feature} | 39 +++++++++++-------- .../User.Mute/I_mute_the_user_{string}.js | 13 +++++++ ...the_list_of_posts_of_this_user_is_empty.js | 6 +++ ...search_should_contain_the_annoying_user.js | 13 +++++++ ..._not_contain_posts_by_the_annoying_user.js | 10 +++++ cypress/integration/common/.search.js | 20 ---------- cypress/integration/common/.steps.js | 27 ------------- ...m_the_content_menu_in_the_user_info_box.js | 0 .../I_follow_the_user_{string}.js | 0 ...et_removed_from_his_follower_collection.js | 0 ...I_navigate_to_my_{string}_settings_page.js | 0 .../I_search_for_{string}.js | 0 .../{string}_wrote_a_post_{string}.js | 4 +- 14 files changed, 67 insertions(+), 67 deletions(-) rename cypress/integration/{user_profile/mute-users/.Mute.feature => User.Mute.feature} (52%) create mode 100644 cypress/integration/User.Mute/I_mute_the_user_{string}.js create mode 100644 cypress/integration/User.Mute/the_list_of_posts_of_this_user_is_empty.js create mode 100644 cypress/integration/User.Mute/the_search_should_contain_the_annoying_user.js create mode 100644 cypress/integration/User.Mute/the_search_should_not_contain_posts_by_the_annoying_user.js delete mode 100644 cypress/integration/common/.search.js rename cypress/integration/{User.Block => common}/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js (100%) rename cypress/integration/{User.Block => common}/I_follow_the_user_{string}.js (100%) rename cypress/integration/{User.Block => common}/I_get_removed_from_his_follower_collection.js (100%) rename cypress/integration/{User.Block => common}/I_navigate_to_my_{string}_settings_page.js (100%) rename cypress/integration/{User.Block => common}/I_search_for_{string}.js (100%) rename cypress/integration/{User.Block => common}/{string}_wrote_a_post_{string}.js (59%) diff --git a/cypress/integration/User.Block.feature b/cypress/integration/User.Block.feature index fa68397da..9033ab8a9 100644 --- a/cypress/integration/User.Block.feature +++ b/cypress/integration/User.Block.feature @@ -37,7 +37,7 @@ Feature: User - block an user And I "should" see "Unblock user" from the content menu in the user info box Scenario: Posts of blocked users are not filtered from search results - Given "Harassing User" wrote a post "You can still see my posts" + Given "harassing-user" wrote a post "You can still see my posts" And I block the user "Harassing User" When I search for "see" Then I should see the following posts in the select dropdown: diff --git a/cypress/integration/user_profile/mute-users/.Mute.feature b/cypress/integration/User.Mute.feature similarity index 52% rename from cypress/integration/user_profile/mute-users/.Mute.feature rename to cypress/integration/User.Mute.feature index 03ac4370b..d08513694 100644 --- a/cypress/integration/user_profile/mute-users/.Mute.feature +++ b/cypress/integration/User.Mute.feature @@ -2,39 +2,43 @@ Feature: Mute a User As a user I'd like to have a button to mute 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 "Spammy Spammer" - 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 | annoying-user | Annoying User | annoying-user | 0.0.4 | + Given the following "posts" are in the database: + | id | title | content | authorId | + | im-not-muted | Post that should be seen | cause I'm not muted | id-of-peter-pan | + | bWBjpkTKZp | previously created post | previously-created-post | id-of-peter-pan | + And I am logged in as "peter-pan" Scenario: Mute a user - Given I am on the profile page of the annoying user + Given I navigate to page "/profile/annoying-user" When I click on "Mute user" from the content menu in the user info box And I navigate to my "Muted users" settings page Then I can see the following table: | Avatar | Name | - | | Spammy Spammer | + | | Annoying User | Scenario: Mute a previously followed user - Given I follow the user "Spammy Spammer" - And "Spammy Spammer" wrote a post "Spam Spam Spam" - When I visit the profile page of the annoying user + Given I follow the user "Annoying User" + And "annoying-user" wrote a post "Spam Spam Spam" + When I navigate to page "/profile/annoying-user" And I click on "Mute user" from the content menu in the user info box Then the list of posts of this user is empty And I get removed from his follower collection Scenario: Posts of muted users are filtered from search results, users are not - Given we have the following posts in our database: - | id | title | content | - | im-not-muted | Post that should be seen | cause I'm not muted | - Given "Spammy Spammer" wrote a post "Spam Spam Spam" + Given "annoying-user" wrote a post "Spam Spam Spam" When I search for "Spam" Then I should see the following posts in the select dropdown: | title | | Spam Spam Spam | - When I mute the user "Spammy Spammer" + When I mute the user "Annoying User" And I refresh the page - And I search for "Spam" + And I search for "Anno" Then the search should not contain posts by the annoying user But the search should contain the annoying user But I search for "not muted" @@ -43,9 +47,10 @@ Feature: Mute a User | Post that should be seen | Scenario: Muted users can still see my posts - Given I previously created a post - And I mute the user "Spammy Spammer" - And the "muted" user searches for "previously created" + And I mute the user "Annoying User" + And I am logged in as "annoying-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 | diff --git a/cypress/integration/User.Mute/I_mute_the_user_{string}.js b/cypress/integration/User.Mute/I_mute_the_user_{string}.js new file mode 100644 index 000000000..e0ed382cb --- /dev/null +++ b/cypress/integration/User.Mute/I_mute_the_user_{string}.js @@ -0,0 +1,13 @@ +import { When } from "cypress-cucumber-preprocessor/steps"; + +When("I mute the user {string}", name => { + cy.neode() + .first("User", { name }) + .then(mutedUser => { + cy.neode() + .first("User", { + name: "Peter Pan" + }) + .relateTo(mutedUser, "muted"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/User.Mute/the_list_of_posts_of_this_user_is_empty.js b/cypress/integration/User.Mute/the_list_of_posts_of_this_user_is_empty.js new file mode 100644 index 000000000..038ca2168 --- /dev/null +++ b/cypress/integration/User.Mute/the_list_of_posts_of_this_user_is_empty.js @@ -0,0 +1,6 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +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"); +}); \ No newline at end of file diff --git a/cypress/integration/User.Mute/the_search_should_contain_the_annoying_user.js b/cypress/integration/User.Mute/the_search_should_contain_the_annoying_user.js new file mode 100644 index 000000000..d29eafc2f --- /dev/null +++ b/cypress/integration/User.Mute/the_search_should_contain_the_annoying_user.js @@ -0,0 +1,13 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("the search should contain the annoying user", () => { + cy.get(".searchable-input .ds-select-dropdown") + .should($li => { + expect($li).to.have.length(1); + }) + cy.get(".ds-select-dropdown .user-teaser .slug") + .should("contain", '@annoying-user'); + cy.get(".searchable-input .ds-select input") + .focus() + .type("{esc}"); +}) \ No newline at end of file diff --git a/cypress/integration/User.Mute/the_search_should_not_contain_posts_by_the_annoying_user.js b/cypress/integration/User.Mute/the_search_should_not_contain_posts_by_the_annoying_user.js new file mode 100644 index 000000000..a2f0a01d7 --- /dev/null +++ b/cypress/integration/User.Mute/the_search_should_not_contain_posts_by_the_annoying_user.js @@ -0,0 +1,10 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("the search should not contain posts by the annoying user", () => { + cy.get(".searchable-input .ds-select-dropdown").should($li => { + expect($li).to.have.length(1); + }) + cy.get(".ds-select-dropdown") + .should("not.have.class", '.search-post') + .should("not.contain", 'Spam') +}); \ No newline at end of file diff --git a/cypress/integration/common/.search.js b/cypress/integration/common/.search.js deleted file mode 100644 index 387e6c9ca..000000000 --- a/cypress/integration/common/.search.js +++ /dev/null @@ -1,20 +0,0 @@ -import { When, Then } from "cypress-cucumber-preprocessor/steps"; - -Then("the search should not contain posts by the annoying user", () => { - cy.get(".searchable-input .ds-select-dropdown").should($li => { - expect($li).to.have.length(1); - }) - cy.get(".ds-select-dropdown") - .should("not.have.class", '.search-post') - .should("not.contain", 'Spam') -}); - -Then("the search should contain the annoying user", () => { - cy.get(".searchable-input .ds-select-dropdown").should($li => { - expect($li).to.have.length(1); - }) - cy.get(".ds-select-dropdown .user-teaser .slug").should("contain", '@spammy-spammer'); - cy.get(".searchable-input .ds-select input") - .focus() - .type("{esc}"); -}) \ No newline at end of file diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js index 41c9abe34..9736ba094 100644 --- a/cypress/integration/common/.steps.js +++ b/cypress/integration/common/.steps.js @@ -66,19 +66,6 @@ Given("there is an annoying user who has muted me", () => { }); }); -Given("I am on the profile page of the annoying user", name => { - cy.openPage("profile/annoying-user/spammy-spammer"); -}); - -When("I ", name => { - cy.openPage("profile/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"); -}); - Given("I wrote a post {string}", title => { cy.factory() .build("post", { @@ -88,20 +75,6 @@ Given("I wrote a post {string}", title => { }); }); -When("I mute the user {string}", name => { - cy.neode() - .first("User", { - name - }) - .then(mutedUser => { - cy.neode() - .first("User", { - name: narratorParams.name - }) - .relateTo(mutedUser, "muted"); - }); -}); - Then("I see only one post with the title {string}", title => { cy.get(".main-container") .find(".post-link") diff --git a/cypress/integration/User.Block/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js b/cypress/integration/common/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js similarity index 100% rename from cypress/integration/User.Block/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js rename to cypress/integration/common/I_click_on_{string}_from_the_content_menu_in_the_user_info_box.js diff --git a/cypress/integration/User.Block/I_follow_the_user_{string}.js b/cypress/integration/common/I_follow_the_user_{string}.js similarity index 100% rename from cypress/integration/User.Block/I_follow_the_user_{string}.js rename to cypress/integration/common/I_follow_the_user_{string}.js diff --git a/cypress/integration/User.Block/I_get_removed_from_his_follower_collection.js b/cypress/integration/common/I_get_removed_from_his_follower_collection.js similarity index 100% rename from cypress/integration/User.Block/I_get_removed_from_his_follower_collection.js rename to cypress/integration/common/I_get_removed_from_his_follower_collection.js diff --git a/cypress/integration/User.Block/I_navigate_to_my_{string}_settings_page.js b/cypress/integration/common/I_navigate_to_my_{string}_settings_page.js similarity index 100% rename from cypress/integration/User.Block/I_navigate_to_my_{string}_settings_page.js rename to cypress/integration/common/I_navigate_to_my_{string}_settings_page.js diff --git a/cypress/integration/User.Block/I_search_for_{string}.js b/cypress/integration/common/I_search_for_{string}.js similarity index 100% rename from cypress/integration/User.Block/I_search_for_{string}.js rename to cypress/integration/common/I_search_for_{string}.js diff --git a/cypress/integration/User.Block/{string}_wrote_a_post_{string}.js b/cypress/integration/common/{string}_wrote_a_post_{string}.js similarity index 59% rename from cypress/integration/User.Block/{string}_wrote_a_post_{string}.js rename to cypress/integration/common/{string}_wrote_a_post_{string}.js index 3df7b53a6..42ac98028 100644 --- a/cypress/integration/User.Block/{string}_wrote_a_post_{string}.js +++ b/cypress/integration/common/{string}_wrote_a_post_{string}.js @@ -1,10 +1,10 @@ import { Given } from "cypress-cucumber-preprocessor/steps"; -Given('{string} wrote a post {string}', (_, title) => { +Given('{string} wrote a post {string}', (author, title) => { cy.factory() .build("post", { title, }, { - authorId: 'harassing-user', + authorId: author, }); }); \ No newline at end of file