diff --git a/backend/src/schema/types/type/User.gql b/backend/src/schema/types/type/User.gql index 71cc1edb0..ec9bfeba7 100644 --- a/backend/src/schema/types/type/User.gql +++ b/backend/src/schema/types/type/User.gql @@ -68,7 +68,12 @@ type User { RETURN COUNT(u) >= 1 """ ) - + hasBlocked: Boolean! @cypher( + statement: """ + MATCH (this)<-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) + RETURN COUNT(user) >= 1 + """ + ) blocked: Boolean! @cypher( statement: """ MATCH (this)-[:BLOCKED]-(user:User {id: $cypherParams.currentUserId}) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 36dbb50d4..753160b84 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -558,6 +558,20 @@ When("I block the user {string}", name => { }); }); +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"); + }); +}); + When("I log in with:", table => { const [firstRow] = table.hashes(); const { @@ -583,4 +597,20 @@ Then("they should not see the comment from", () => { Then("they should see a text explaining 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 should not see {string} from the content menu in the user info box", link => { + cy.get(".user-content-menu .base-button").click() + cy.get(".popover .ds-menu-item-link") + .should('not.contain', link) +}) + +Then('I should not see {string} button', button => { + cy.get('.ds-card-content') + .should('not.contain', '.action-buttons') }) \ No newline at end of file diff --git a/cypress/integration/user_profile/BlockUser.feature b/cypress/integration/user_profile/BlockUser.feature index 43efe7807..50b90ee62 100644 --- a/cypress/integration/user_profile/BlockUser.feature +++ b/cypress/integration/user_profile/BlockUser.feature @@ -44,3 +44,14 @@ Feature: Block a User 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 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 + And I should not see "Unblock user" from the content menu in the user info box + And I should not see "Unblock user" button \ No newline at end of file diff --git a/webapp/components/ContentMenu/ContentMenu.vue b/webapp/components/ContentMenu/ContentMenu.vue index ee2bd4a62..2be51c6ac 100644 --- a/webapp/components/ContentMenu/ContentMenu.vue +++ b/webapp/components/ContentMenu/ContentMenu.vue @@ -172,7 +172,7 @@ export default { icon: 'microphone-slash', }) } - if (this.resource.blocked) { + if (this.resource.hasBlocked) { routes.push({ label: this.$t(`settings.blocked-users.unblock`), callback: () => { diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index 80471fff4..4d9653dcb 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -67,14 +67,14 @@