diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index ea9220d5e..b5df8111e 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -22,6 +22,7 @@ export const getBlockedUsers = async context => { } export const getBlockedByUsers = async context => { + if (context.user.role === 'moderator' || context.user.role === 'admin') return [] const { neode } = context const userModel = neode.model('User') let blockedByUsers = neode diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index fb395d361..c51c6b42e 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -5,7 +5,7 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' let lastReportTitle let davidIrvingPostTitle = 'The Truth about the Holocaust' let davidIrvingPostSlug = 'the-truth-about-the-holocaust' -let davidIrvingName = 'David Irving' +let annoyingUserWhoBlockedModeratorTitle = 'Fake news' const savePostTitle = $post => { return $post @@ -116,7 +116,7 @@ When(/^I confirm the reporting dialog .*:$/, message => { Given('somebody reported the following posts:', table => { table.hashes().forEach(({ id }) => { const submitter = { - email: `submitter${id}@example.org`, + email: `submitter${id}@example.org`, password: '1234' } cy.factory() @@ -139,7 +139,28 @@ Then('I see all the reported posts including the one from above', () => { }) }) +Then('I see all the reported posts including from the user who blocked me', () => { + cy.get('table tbody').within(() => { + cy.contains('tr', annoyingUserWhoBlockedModeratorTitle) + }) +}) + Then('each list item links to the post page', () => { cy.contains(davidIrvingPostTitle).click() cy.location('pathname').should('contain', '/post') }) + +Then('I can visit the post page', () => { + cy.contains(annoyingUserWhoBlockedModeratorTitle).click() + cy.location('pathname').should('contain', '/post') + .get('h3').should('contain', annoyingUserWhoBlockedModeratorTitle) +}) + +When("they have a post someone has reported", () => { + cy.factory() + .create("Post", { + authorId: 'annnoying-user', + title, + }); + +}) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index a25200667..ab1790756 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -410,6 +410,20 @@ Given("there is an annoying user called {string}", name => { }); }); +Given("there is an annoying user who has blocked me", () => { + cy.neode() + .first("User", { + role: 'moderator' + }) + .then(blocked => { + cy.neode() + .first("User", { + id: 'annoying-user' + }) + .relateTo(blocked, "blocked"); + }); +}); + Given("I am on the profile page of the annoying user", name => { cy.openPage("/profile/annoying-user/spammy-spammer"); }); diff --git a/cypress/integration/moderation/ReportContent.feature b/cypress/integration/moderation/ReportContent.feature index 0181dc7a6..0f8eec0e3 100644 --- a/cypress/integration/moderation/ReportContent.feature +++ b/cypress/integration/moderation/ReportContent.feature @@ -8,13 +8,15 @@ Feature: Report and Moderate So I can look into it and decide what to do Background: - Given we have this user in our database: - | id | name | - | u67 | David Irving| + Given we have the following user accounts: + | id | name | + | u67 | David Irving | + | annoying-user | I'm gonna block Moderators and Admins HA HA HA | + Given we have the following posts in our database: - | authorId | id | title | content | - | u67 | p1 | The Truth about the Holocaust | It never existed! | - + | authorId | id | title | content | + | u67 | p1 | The Truth about the Holocaust | It never existed! | + | annoying-user | p2 | Fake news | This content is demonstratably infactual in some way | Scenario Outline: Report a post from various pages Given I am logged in with a "user" role When I see David Irving's post on the @@ -56,6 +58,18 @@ Feature: Report and Moderate Then I see all the reported posts including the one from above And each list item links to the post page + Scenario: Review reported posts of a user who's blocked a moderator + Given somebody reported the following posts: + | id | + | p2 | + And my user account has the role "moderator" + And there is an annoying user who has blocked me + And I am logged in + When I click on the avatar menu in the top right corner + And I click on "Moderation" + Then I see all the reported posts including from the user who blocked me + And I can visit the post page + Scenario: Normal user can't see the moderation page Given I am logged in with a "user" role When I click on the avatar menu in the top right corner