diff --git a/backend/src/schema/resolvers/users.js b/backend/src/schema/resolvers/users.js index ea9220d5e..057e52435 100644 --- a/backend/src/schema/resolvers/users.js +++ b/backend/src/schema/resolvers/users.js @@ -30,6 +30,7 @@ export const getBlockedByUsers = async context => { .relationship(userModel.relationships().get('blocked')) .to('blocked', userModel) .where('blocked.id', context.user.id) + .where('blocked.user', 'user') .return('user') blockedByUsers = await blockedByUsers.execute() blockedByUsers = blockedByUsers.records.map(r => r.get('user').properties) diff --git a/cypress/integration/common/report.js b/cypress/integration/common/report.js index fb395d361..a60068f04 100644 --- a/cypress/integration/common/report.js +++ b/cypress/integration/common/report.js @@ -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() @@ -143,3 +143,12 @@ Then('each list item links to the post page', () => { cy.contains(davidIrvingPostTitle).click() cy.location('pathname').should('contain', '/post') }) + +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..f04f43b26 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -410,6 +410,21 @@ Given("there is an annoying user called {string}", name => { }); }); +Given("there is an annoying user who has blocked me", () => { + cy.login({ email: 'i-blocked-a-moderator-ha-ha-ha@example.org', password: '1234' }) + .neode() + .first("User", { + role: 'moderator' + }) + .then(blocked => { + cy.neode() + .first("User", { + name + }) + .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..566209346 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 | email | password | + | u67 | David Irving | david-irving@example.org | 1234 | + | annoying-user | I'm gonna block Moderators and Admins HA HA HA | i-blocked-a-moderator-ha-ha-ha@example.org | 1234 | + 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: Even if a user has blocked me, I can see their reported posts + 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 the one from above + And each list item links to 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