Moderation.ReportContent.feature

This commit is contained in:
Ulf Gebhardt 2021-04-12 02:06:19 +02:00
parent c6bca8d9fb
commit af6f45a399
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
15 changed files with 138 additions and 134 deletions

View File

@ -8,51 +8,47 @@ Feature: Report and Moderate
So I can look into it and decide what to do So I can look into it and decide what to do
Background: Background:
Given we have the following user accounts: Given the following "users" are in the database:
| id | name | | slug | email | password | id | name | role | termsAndConditionsAgreedVersion |
| u67 | David Irving | | user | user@example.org | abcd | user | User-Chad | user | 0.0.4 |
| annoying-user | I'm gonna mute Moderators and Admins HA HA HA | | moderator | moderator@example.org | 1234 | moderator | Mod-Man | moderator | 0.0.4 |
| annoying | annoying@example.org | 1234 | annoying-user | I'm gonna mute Moderators and Admins HA HA HA | user | 0.0.4 |
Given we have the following posts in our database: And the following "posts" are in the database:
| authorId | id | title | content | | authorId | id | title | content |
| u67 | p1 | The Truth about the Holocaust | It never existed! | | annoying-user | p1 | The Truth about the Holocaust | It never existed! |
| annoying-user | p2 | Fake news | This content is demonstratably infactual in some way | | annoying-user | p2 | Fake news | This content is demonstratably infactual in some way |
Scenario Outline: Report a post from various pages Scenario Outline: Report a post from various pages
Given I am logged in with a "user" role When I am logged in as "user"
When I see David Irving's post on the <Page> And I navigate to page "<Page>"
And I click on "Report Post" from the content menu of the post And I click on "Report Post" from the content menu of the post
And I confirm the reporting dialog because it is a criminal act under German law: And I confirm the reporting dialog because it is a criminal act under German law:
""" """
Do you really want to report the contribution "The Truth about the Holocaust"? Do you really want to report the contribution "The Truth about the Holocaust"?
""" """
Then I see a success message: Then I see a toaster with "Thanks for reporting!"
"""
Thanks for reporting!
"""
Examples: Examples:
| Page | | Page |
| newsfeed page| | / |
| post page | | /post/p1 |
Scenario: Report user Scenario: Report user
Given I am logged in with a "user" role Given I am logged in as "user"
And I see David Irving's post on the post page And I navigate to page "/post/the-truth-about-the-holocaust"
When I click on the author When I click on the author
And I click on "Report User" from the content menu in the user info box And I click on "Report User" from the content menu in the user info box
And I confirm the reporting dialog because he is a holocaust denier: And I confirm the reporting dialog because he is a holocaust denier:
""" """
Do you really want to report the user "David Irving"? Do you really want to report the user "I'm gonna mute Moderators and "?
"""
Then I see a success message:
"""
Thanks for reporting!
""" """
Then I see a toaster with "Thanks for reporting!"
Scenario: Review reported content Scenario: Review reported content
Given somebody reported the following posts: Given somebody reported the following posts:
| submitterEmail | resourceId | reasonCategory | reasonDescription | | submitterEmail | resourceId | reasonCategory | reasonDescription |
| p1.submitter@example.org | p1 | discrimination_etc | Offensive content | | p1.submitter@example.org | p1 | discrimination_etc | Offensive content |
And I am logged in with a "moderator" role And I am logged in as "moderator"
And I navigate to page "/"
When I click on the avatar menu in the top right corner When I click on the avatar menu in the top right corner
And I click on "Moderation" And I click on "Moderation"
Then I see all the reported posts including the one from above Then I see all the reported posts including the one from above
@ -62,7 +58,8 @@ Feature: Report and Moderate
Given somebody reported the following posts: Given somebody reported the following posts:
| submitterEmail | resourceId | reasonCategory | reasonDescription | | submitterEmail | resourceId | reasonCategory | reasonDescription |
| p2.submitter@example.org | p2 | other | Offensive content | | p2.submitter@example.org | p2 | other | Offensive content |
And I am logged in with a "moderator" role And I am logged in as "moderator"
And I navigate to page "/"
And there is an annoying user who has muted me And there is an annoying user who has muted me
When I click on the avatar menu in the top right corner When I click on the avatar menu in the top right corner
And I click on "Moderation" And I click on "Moderation"
@ -70,6 +67,7 @@ Feature: Report and Moderate
And I can visit the post page And I can visit the post page
Scenario: Normal user can't see the moderation page Scenario: Normal user can't see the moderation page
Given I am logged in with a "user" role Given I am logged in as "user"
And I navigate to page "/"
When I click on the avatar menu in the top right corner When I click on the avatar menu in the top right corner
Then I can't see the moderation menu item Then I can't see the moderation menu item

View File

@ -0,0 +1,11 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover')
.find('a[href="/settings"]', 'Settings')
.should('exist') // OK, the dropdown is actually open
cy.get('.avatar-menu-popover')
.find('a[href="/moderation"]', 'Moderation')
.should('not.exist')
})

View File

@ -0,0 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('I can visit the post page', () => {
cy.contains('Fake news').click()
cy.location('pathname').should('contain', '/post')
.get('.base-card .title').should('contain', 'Fake news')
})

View File

@ -0,0 +1,11 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When('I click on "Report Post" from the content menu of the post', () => {
cy.contains('.base-card', 'The Truth about the Holocaust')
.find('.content-menu .base-button')
.click({force: true})
cy.get('.popover .ds-menu-item-link')
.contains('Report Post')
.click()
})

View File

@ -0,0 +1,7 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When('I click on the author', () => {
cy.get('.user-teaser')
.click()
.url().should('include', '/profile/')
})

View File

@ -0,0 +1,5 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When("I click on the avatar menu in the top right corner", () => {
cy.get(".avatar-menu").click();
});

View File

@ -0,0 +1,16 @@
import { When } from "cypress-cucumber-preprocessor/steps";
When(/^I confirm the reporting dialog .*:$/, message => {
cy.contains(message) // wait for element to become visible
cy.get('.ds-modal')
.within(() => {
cy.get('.ds-radio-option-label')
.first()
.click({
force: true
})
cy.get('button')
.contains('Report')
.click()
})
})

View File

@ -0,0 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('I see all the reported posts including from the user who muted me', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', 'Fake news')
})
})

View File

@ -0,0 +1,7 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('I see all the reported posts including the one from above', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', 'The Truth about the Holocaust')
})
})

View File

@ -0,0 +1,6 @@
import { Then } from "cypress-cucumber-preprocessor/steps";
Then('each list item links to the post page', () => {
cy.contains('The Truth about the Holocaust').click();
cy.location('pathname').should('contain', '/post')
})

View File

@ -0,0 +1,23 @@
import { Given } from "cypress-cucumber-preprocessor/steps";
import { gql } from '../../../backend/src/helpers/jest'
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
const submitter = {
email: submitterEmail,
password: '1234'
}
cy.factory()
.build('user', {}, submitter)
.authenticateAs(submitter)
.mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
reportId
}
}`, {
resourceId,
reasonCategory,
reasonDescription
})
})
})

View File

@ -0,0 +1,13 @@
Given("there is an annoying user who has muted me", () => {
cy.neode()
.first("User", {
role: 'moderator'
})
.then(mutedUser => {
cy.neode()
.first("User", {
id: 'user'
})
.relateTo(mutedUser, "muted");
});
});

View File

@ -1,6 +1,5 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import { VERSION } from '../../constants/terms-and-conditions-version.js' import { VERSION } from '../../constants/terms-and-conditions-version.js'
import { gql } from '../../../backend/src/helpers/jest'
/* global cy */ /* global cy */
@ -24,11 +23,6 @@ Given("I see David Irving's post on the newsfeed", page => {
cy.openPage('newsfeed') cy.openPage('newsfeed')
}) })
Given("I see David Irving's post on the post page", page => {
cy.visit(`/post/${davidIrvingPostSlug}`)
cy.contains(davidIrvingPostTitle) // wait
})
Given('I am logged in with a {string} role', role => { Given('I am logged in with a {string} role', role => {
cy.factory().build('user', { cy.factory().build('user', {
termsAndConditionsAgreedVersion: VERSION, termsAndConditionsAgreedVersion: VERSION,
@ -50,16 +44,6 @@ Given('I am logged in with a {string} role', role => {
.then(user => cy.login(user)) .then(user => cy.login(user))
}) })
When('I click on "Report Post" from the content menu of the post', () => {
cy.contains('.base-card', davidIrvingPostTitle)
.find('.content-menu .base-button')
.click({force: true})
cy.get('.popover .ds-menu-item-link')
.contains('Report Post')
.click()
})
When('I click on "Report User" from the content menu in the user info box', () => { When('I click on "Report User" from the content menu in the user info box', () => {
cy.contains('.base-card', davidIrvingPostTitle) cy.contains('.base-card', davidIrvingPostTitle)
.get('.user-content-menu .base-button') .get('.user-content-menu .base-button')
@ -70,12 +54,6 @@ When('I click on "Report User" from the content menu in the user info box', () =
.click() .click()
}) })
When('I click on the author', () => {
cy.get('.user-teaser')
.click()
.url().should('include', '/profile/')
})
When('I report the author', () => { When('I report the author', () => {
cy.get('.page-name-profile-id-slug').then(() => { cy.get('.page-name-profile-id-slug').then(() => {
invokeReportOnElement('.base-card').then(() => { invokeReportOnElement('.base-card').then(() => {
@ -104,74 +82,6 @@ Then('I see my reported user', () => {
}) })
}) })
Then(`I can't see the moderation menu item`, () => {
cy.get('.avatar-menu-popover')
.find('a[href="/settings"]', 'Settings')
.should('exist') // OK, the dropdown is actually open
cy.get('.avatar-menu-popover')
.find('a[href="/moderation"]', 'Moderation')
.should('not.exist')
})
When(/^I confirm the reporting dialog .*:$/, message => {
cy.contains(message) // wait for element to become visible
cy.get('.ds-modal').within(() => {
cy.get('.ds-radio-option-label')
.first()
.click({
force: true
})
cy.get('button')
.contains('Report')
.click()
})
})
Given('somebody reported the following posts:', table => {
table.hashes().forEach(({ submitterEmail, resourceId, reasonCategory, reasonDescription }) => {
const submitter = {
email: submitterEmail,
password: '1234'
}
cy.factory()
.build('user', {}, submitter)
.authenticateAs(submitter)
.mutate(gql`mutation($resourceId: ID!, $reasonCategory: ReasonCategory!, $reasonDescription: String!) {
fileReport(resourceId: $resourceId, reasonCategory: $reasonCategory, reasonDescription: $reasonDescription) {
reportId
}
}`, {
resourceId,
reasonCategory,
reasonDescription
})
})
})
Then('I see all the reported posts including the one from above', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', davidIrvingPostTitle)
})
})
Then('I see all the reported posts including from the user who muted me', () => {
cy.get('table tbody').within(() => {
cy.contains('tr', annoyingUserWhoMutedModeratorTitle)
})
})
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(annoyingUserWhoMutedModeratorTitle).click()
cy.location('pathname').should('contain', '/post')
.get('.base-card .title').should('contain', annoyingUserWhoMutedModeratorTitle)
})
When("they have a post someone has reported", () => { When("they have a post someone has reported", () => {
cy.factory() cy.factory()
.build("post", { .build("post", {

View File

@ -40,10 +40,6 @@ Given("we have the following posts in our database:", table => {
}) })
}) })
When("I click on the avatar menu in the top right corner", () => {
cy.get(".avatar-menu").click();
});
Given("there is an annoying user called {string}", name => { Given("there is an annoying user called {string}", name => {
cy.factory().build("user", { cy.factory().build("user", {
id: "annoying-user", id: "annoying-user",
@ -52,20 +48,6 @@ Given("there is an annoying user called {string}", name => {
}, annoyingParams); }, annoyingParams);
}); });
Given("there is an annoying user who has muted me", () => {
cy.neode()
.first("User", {
role: 'moderator'
})
.then(mutedUser => {
cy.neode()
.first("User", {
id: 'annoying-user'
})
.relateTo(mutedUser, "muted");
});
});
Given("I wrote a post {string}", title => { Given("I wrote a post {string}", title => {
cy.factory() cy.factory()
.build("post", { .build("post", {

View File

@ -10,6 +10,7 @@ When("I click on {string}", element => {
'reply button': '.reply-button', 'reply button': '.reply-button',
'security menu': 'a[href="/settings/security"]', 'security menu': 'a[href="/settings/security"]',
'pin post': '.ds-menu-item:first-child', 'pin post': '.ds-menu-item:first-child',
'Moderation': 'a[href="/moderation"]',
} }
cy.get(elementSelectors[element]) cy.get(elementSelectors[element])