From 073185d424cad35e5c979706c0d1e42f2799ff91 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 13 Aug 2019 19:46:01 +0200 Subject: [PATCH] All cucumbers implemented --- cypress/integration/common/search.js | 7 +++ cypress/integration/common/steps.js | 28 +++++++++++- .../user_profile/BlockedUser.feature | 44 ------------------- .../blocked-users/Blocking.feature | 36 +++++++++++++++ .../blocked-users/Content.feature | 22 ++++++++++ cypress/support/factories.js | 1 - 6 files changed, 92 insertions(+), 46 deletions(-) delete mode 100644 cypress/integration/user_profile/BlockedUser.feature create mode 100644 cypress/integration/user_profile/blocked-users/Blocking.feature create mode 100644 cypress/integration/user_profile/blocked-users/Content.feature diff --git a/cypress/integration/common/search.js b/cypress/integration/common/search.js index 5a3819a9d..35b2d1346 100644 --- a/cypress/integration/common/search.js +++ b/cypress/integration/common/search.js @@ -11,6 +11,13 @@ Then("I should have one post in the select dropdown", () => { }); }); +Then("the search has no results", () => { + cy.get(".input .ds-select-dropdown").should($li => { + expect($li).to.have.length(1); + }); + cy.get(".ds-select-dropdown").should("contain", 'Nothing found'); +}); + Then("I should see the following posts in the select dropdown:", table => { table.hashes().forEach(({ title }) => { cy.get(".ds-select-dropdown").should("contain", title); diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index f0446fcc6..e1eab98c1 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -376,7 +376,7 @@ Given("there is an annoying user called {string}", (name) => { }) Given("I am on the profile page of the annoying user", (name) => { - cy.openPage('/profile/annoying-user'); + cy.openPage('/profile/annoying-user/spammy-spammer'); }) When("I visit the profile page of the annoying user", (name) => { @@ -429,3 +429,29 @@ Then("nobody is following the user profile anymore", () => { cy.get('.ds-card-content').not('.post-link') cy.get('.main-container').contains('.ds-card-content', 'is not followed by anyone') }) + +Given("I wrote a post {string}", (title) => { + cy.factory() + .authenticateAs(loginCredentials) + .create("Post", { title }) +}) + +When("I block the user {string}", (name) => { + cy.neode() + .first('User', { name }).then((blocked) => { + cy.neode() + .first('User', {name: narratorParams.name}) + .relateTo(blocked, 'blocked') + }) +}) + +When("I log in with:", (table) => { + const [firstRow] = table.hashes() + const { Email, Password } = firstRow + cy.login({email: Email, password: Password}) +}) + +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) +}) diff --git a/cypress/integration/user_profile/BlockedUser.feature b/cypress/integration/user_profile/BlockedUser.feature deleted file mode 100644 index 41d88226f..000000000 --- a/cypress/integration/user_profile/BlockedUser.feature +++ /dev/null @@ -1,44 +0,0 @@ -Feature: Block another user - As a user - I'd like to have a button to block another user - To prevent him to see and interact with my contributions and also to avoid to see his/her posts - - Background: - Given I have a user account - And there is an annoying user called "Spammy Spammer" - And I am logged in - - 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 - And I navigate to my "Blocked users" settings page - Then I can see the following table: - | Avatar | Name | - | | Spammy Spammer | - - Scenario Outline: Blocked users cannot see each others posts - Given "Spammy Spammer" wrote a post "Spam Spam Spam" - And I wrote a post "I hate spammers" - And I block the user "Spammy Spammer" - When I log in with - Then I see only one post with the title - Examples: - | accout | expected_title | - | my own account | I hate spammers | - | spammy spammers account | Spam Spam Spam | - - Scenario: Block a previously followed user - Given I follow the user "Spammy Spammer" - When I visit the profile page of the annoying user - And I click on "Block User" from the content menu in the user info box - Then the list of posts of this user is empty - And nobody is following the user profile anymore - - Scenario: Posts of blocked users are filtered from search results - Given "Spammy Spammer" 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 | - But if I block the user "Spammy Spammer" - Then the search has no results diff --git a/cypress/integration/user_profile/blocked-users/Blocking.feature b/cypress/integration/user_profile/blocked-users/Blocking.feature new file mode 100644 index 000000000..6a106fc9e --- /dev/null +++ b/cypress/integration/user_profile/blocked-users/Blocking.feature @@ -0,0 +1,36 @@ +Feature: Block a User + As a user + I'd like to have a button to block another user + To prevent him to see and interact with my contributions and also to avoid to see his/her posts + + Background: + Given I have a user account + And there is an annoying user called "Spammy Spammer" + And I am logged in + + 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 + And I navigate to my "Blocked users" settings page + Then I can see the following table: + | Avatar | Name | + | | Spammy Spammer | + + Scenario: Block 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 + And I click on "Block User" from the content menu in the user info box + Then the list of posts of this user is empty + And nobody is following the user profile anymore + + Scenario: Posts of blocked users are filtered from search results + Given "Spammy Spammer" 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 block the user "Spammy Spammer" + And I refresh the page + And I search for "Spam" + Then the search has no results diff --git a/cypress/integration/user_profile/blocked-users/Content.feature b/cypress/integration/user_profile/blocked-users/Content.feature new file mode 100644 index 000000000..8bbad7e8c --- /dev/null +++ b/cypress/integration/user_profile/blocked-users/Content.feature @@ -0,0 +1,22 @@ +Feature: Block a User + As a user + I'd like to have a button to block another user + To prevent him to see and interact with my contributions and also to avoid to see his/her posts + + Background: + Given I have a user account + And there is an annoying user called "Spammy Spammer" + + Scenario Outline: Blocked users cannot see each others posts + Given "Spammy Spammer" wrote a post "Spam Spam Spam" + And I wrote a post "I hate spammers" + And I block the user "Spammy Spammer" + When I log in with: + | Email | Password | + | | | + Then I see only one post with the title "" + Examples: + | email | password | expected_title | + | peterpan@example.org | 1234 | I hate spammers | + | spammy-spammer@example.org | 1234 | Spam Spam Spam | + diff --git a/cypress/support/factories.js b/cypress/support/factories.js index 237d057cf..20a4d4c77 100644 --- a/cypress/support/factories.js +++ b/cypress/support/factories.js @@ -23,7 +23,6 @@ Cypress.Commands.add( 'first', { prevSubject: true }, async (neode, model, properties) => { - console.log(neode) return neode.first(model, properties) } )