From af6f45a3992ebee25d3ce59940264527772a0be1 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 12 Apr 2021 02:06:19 +0200 Subject: [PATCH] Moderation.ReportContent.feature --- ...ature => Moderation.ReportContent.feature} | 50 +++++------ .../I_can_t_see_the_moderation_menu_item.js | 11 +++ .../I_can_visit_the_post_page.js | 7 ++ ..._Post_from_the_content_menu_of_the_post.js | 11 +++ .../I_click_on_the_author.js | 7 ++ ...the_avatar_menu_in_the_top_right_corner.js | 5 ++ .../I_confirm_the_reporting_dialog.js | 16 ++++ ...ts_including_from_the_user_who_muted_me.js | 7 ++ ...rted_posts_including_the_one_from_above.js | 7 ++ .../each_list_item_links_to_the_post_page.js | 6 ++ .../somebody_reported_the_following_posts.js | 23 +++++ ...re_is_an_annoying_user_who_has_muted_me.js | 13 +++ cypress/integration/common/.report.js | 90 ------------------- cypress/integration/common/.steps.js | 18 ---- .../integration/common/I_click_on_{string}.js | 1 + 15 files changed, 138 insertions(+), 134 deletions(-) rename cypress/integration/{moderation/.ReportContent.feature => Moderation.ReportContent.feature} (61%) create mode 100644 cypress/integration/Moderation.ReportContent/I_can_t_see_the_moderation_menu_item.js create mode 100644 cypress/integration/Moderation.ReportContent/I_can_visit_the_post_page.js create mode 100644 cypress/integration/Moderation.ReportContent/I_click_on_Report_Post_from_the_content_menu_of_the_post.js create mode 100644 cypress/integration/Moderation.ReportContent/I_click_on_the_author.js create mode 100644 cypress/integration/Moderation.ReportContent/I_click_on_the_avatar_menu_in_the_top_right_corner.js create mode 100644 cypress/integration/Moderation.ReportContent/I_confirm_the_reporting_dialog.js create mode 100644 cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_from_the_user_who_muted_me.js create mode 100644 cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js create mode 100644 cypress/integration/Moderation.ReportContent/each_list_item_links_to_the_post_page.js create mode 100644 cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js create mode 100644 cypress/integration/Moderation.ReportContent/there_is_an_annoying_user_who_has_muted_me.js diff --git a/cypress/integration/moderation/.ReportContent.feature b/cypress/integration/Moderation.ReportContent.feature similarity index 61% rename from cypress/integration/moderation/.ReportContent.feature rename to cypress/integration/Moderation.ReportContent.feature index 90a203c9c..518020bd0 100644 --- a/cypress/integration/moderation/.ReportContent.feature +++ b/cypress/integration/Moderation.ReportContent.feature @@ -8,51 +8,47 @@ Feature: Report and Moderate So I can look into it and decide what to do Background: - Given we have the following user accounts: - | id | name | - | u67 | David Irving | - | annoying-user | I'm gonna mute Moderators and Admins HA HA HA | - - Given we have the following posts in our database: + Given the following "users" are in the database: + | slug | email | password | id | name | role | termsAndConditionsAgreedVersion | + | user | user@example.org | abcd | user | User-Chad | user | 0.0.4 | + | 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 | + And the following "posts" are in the database: | 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 | + 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 + When I am logged in as "user" + And I navigate to page "" 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: """ Do you really want to report the contribution "The Truth about the Holocaust"? """ - Then I see a success message: - """ - Thanks for reporting! - """ + Then I see a toaster with "Thanks for reporting!" Examples: - | Page | - | newsfeed page| - | post page | + | Page | + | / | + | /post/p1 | Scenario: Report user - Given I am logged in with a "user" role - And I see David Irving's post on the post page + Given I am logged in as "user" + And I navigate to page "/post/the-truth-about-the-holocaust" When I click on the author 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: """ - Do you really want to report the user "David Irving"? - """ - Then I see a success message: - """ - Thanks for reporting! + Do you really want to report the user "I'm gonna mute Moderators and …"? """ + Then I see a toaster with "Thanks for reporting!" Scenario: Review reported content Given somebody reported the following posts: | submitterEmail | resourceId | reasonCategory | reasonDescription | | 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 And I click on "Moderation" 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: | submitterEmail | resourceId | reasonCategory | reasonDescription | | 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 When I click on the avatar menu in the top right corner And I click on "Moderation" @@ -70,6 +67,7 @@ Feature: Report and Moderate 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 + Given I am logged in as "user" + And I navigate to page "/" When I click on the avatar menu in the top right corner Then I can't see the moderation menu item diff --git a/cypress/integration/Moderation.ReportContent/I_can_t_see_the_moderation_menu_item.js b/cypress/integration/Moderation.ReportContent/I_can_t_see_the_moderation_menu_item.js new file mode 100644 index 000000000..96706281a --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_can_t_see_the_moderation_menu_item.js @@ -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') +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_can_visit_the_post_page.js b/cypress/integration/Moderation.ReportContent/I_can_visit_the_post_page.js new file mode 100644 index 000000000..8ca69da50 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_can_visit_the_post_page.js @@ -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') +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_click_on_Report_Post_from_the_content_menu_of_the_post.js b/cypress/integration/Moderation.ReportContent/I_click_on_Report_Post_from_the_content_menu_of_the_post.js new file mode 100644 index 000000000..30682b009 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_click_on_Report_Post_from_the_content_menu_of_the_post.js @@ -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() +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_click_on_the_author.js b/cypress/integration/Moderation.ReportContent/I_click_on_the_author.js new file mode 100644 index 000000000..3a6600ff6 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_click_on_the_author.js @@ -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/') +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_click_on_the_avatar_menu_in_the_top_right_corner.js b/cypress/integration/Moderation.ReportContent/I_click_on_the_avatar_menu_in_the_top_right_corner.js new file mode 100644 index 000000000..27830b239 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_click_on_the_avatar_menu_in_the_top_right_corner.js @@ -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(); +}); \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_confirm_the_reporting_dialog.js b/cypress/integration/Moderation.ReportContent/I_confirm_the_reporting_dialog.js new file mode 100644 index 000000000..4009fa4e8 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_confirm_the_reporting_dialog.js @@ -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() + }) +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_from_the_user_who_muted_me.js b/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_from_the_user_who_muted_me.js new file mode 100644 index 000000000..522cd6c78 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_from_the_user_who_muted_me.js @@ -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') + }) +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js b/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js new file mode 100644 index 000000000..66c9baf61 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/I_see_all_the_reported_posts_including_the_one_from_above.js @@ -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') + }) +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/each_list_item_links_to_the_post_page.js b/cypress/integration/Moderation.ReportContent/each_list_item_links_to_the_post_page.js new file mode 100644 index 000000000..9ce69d6de --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/each_list_item_links_to_the_post_page.js @@ -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') +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js b/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js new file mode 100644 index 000000000..ce876a081 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/somebody_reported_the_following_posts.js @@ -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 + }) + }) +}) \ No newline at end of file diff --git a/cypress/integration/Moderation.ReportContent/there_is_an_annoying_user_who_has_muted_me.js b/cypress/integration/Moderation.ReportContent/there_is_an_annoying_user_who_has_muted_me.js new file mode 100644 index 000000000..8d475ee43 --- /dev/null +++ b/cypress/integration/Moderation.ReportContent/there_is_an_annoying_user_who_has_muted_me.js @@ -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"); + }); +}); \ No newline at end of file diff --git a/cypress/integration/common/.report.js b/cypress/integration/common/.report.js index b8a199967..07ae554e4 100644 --- a/cypress/integration/common/.report.js +++ b/cypress/integration/common/.report.js @@ -1,6 +1,5 @@ import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' import { VERSION } from '../../constants/terms-and-conditions-version.js' -import { gql } from '../../../backend/src/helpers/jest' /* global cy */ @@ -24,11 +23,6 @@ Given("I see David Irving's post on the newsfeed", page => { 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 => { cy.factory().build('user', { termsAndConditionsAgreedVersion: VERSION, @@ -50,16 +44,6 @@ Given('I am logged in with a {string} role', role => { .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', () => { cy.contains('.base-card', davidIrvingPostTitle) .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() }) -When('I click on the author', () => { - cy.get('.user-teaser') - .click() - .url().should('include', '/profile/') -}) - When('I report the author', () => { cy.get('.page-name-profile-id-slug').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", () => { cy.factory() .build("post", { diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js index 9736ba094..416195d56 100644 --- a/cypress/integration/common/.steps.js +++ b/cypress/integration/common/.steps.js @@ -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 => { cy.factory().build("user", { id: "annoying-user", @@ -52,20 +48,6 @@ Given("there is an annoying user called {string}", name => { }, 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 => { cy.factory() .build("post", { diff --git a/cypress/integration/common/I_click_on_{string}.js b/cypress/integration/common/I_click_on_{string}.js index 275b5febf..5f43eb912 100644 --- a/cypress/integration/common/I_click_on_{string}.js +++ b/cypress/integration/common/I_click_on_{string}.js @@ -10,6 +10,7 @@ When("I click on {string}", element => { 'reply button': '.reply-button', 'security menu': 'a[href="/settings/security"]', 'pin post': '.ds-menu-item:first-child', + 'Moderation': 'a[href="/moderation"]', } cy.get(elementSelectors[element])