Merge pull request #1788 from Human-Connection/1663-moderators-admins-always-see-posts

Update Post query for blockedByUsers
This commit is contained in:
Robert Schäfer 2019-10-02 15:50:55 +02:00 committed by GitHub
commit 9a08de347c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 8 deletions

View File

@ -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

View File

@ -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,
});
})

View File

@ -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");
});

View File

@ -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 <Page>
@ -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