diff --git a/cypress/e2e/seededFlows/articleFlows/commentModerationTools.spec.js b/cypress/e2e/seededFlows/articleFlows/commentModerationTools.spec.js index 4dd53ad57..3b488a886 100644 --- a/cypress/e2e/seededFlows/articleFlows/commentModerationTools.spec.js +++ b/cypress/e2e/seededFlows/articleFlows/commentModerationTools.spec.js @@ -1,11 +1,4 @@ describe('Moderation Tools for Comments', () => { - const navigateToCommentFlagPage = () => { - return cy.get('#comments').within(() => { - cy.findByRole('button', { name: 'Toggle dropdown menu' }).click(); - cy.findByRole('link', { name: 'Moderate' }).click(); - }); - }; - const findButton = (labelText, { as }) => { cy.get('.reaction-button') .filter(`:contains("${labelText}")`) @@ -30,83 +23,81 @@ describe('Moderation Tools for Comments', () => { cy.get('@trustedUser').then((trustedUser) => { cy.loginAndVisit(trustedUser, '/series_user/series-test-article-slug'); - }); - }); - - it.skip('flags and unflags only the comment when clicked', () => { - navigateToCommentFlagPage().then(() => { - cy.get('@questionableUser').then(({ username }) => { - cy.intercept('POST', '/reactions').as('flagRequest'); - - findButton('Flag to Admins', { as: 'contentFlag' }); - findButton(`Flag ${username}`, { as: 'userFlag' }); - - clickButton('@contentFlag'); - - cy.get('@contentFlag').should('have.class', 'reacted'); - cy.get('@userFlag').should('not.have.class', 'reacted'); - - clickButton('@contentFlag'); - - cy.get('@contentFlag').should('not.have.class', 'reacted'); - cy.get('@userFlag').should('not.have.class', 'reacted'); + cy.intercept('/notifications/counts').as('notificationCount'); + cy.intercept('/async_info/base_data').as('baseData'); + cy.intercept('/ahoy/visits').as('ahoy'); + cy.get('#comments').within(() => { + cy.findByRole('button', { name: 'Toggle dropdown menu' }).click(); + cy.findByRole('link', { name: 'Moderate' }).click(); }); + cy.wait(['@notificationCount', '@baseData', '@ahoy']); }); }); - it.skip('flags and unflags only the user when clicked', () => { - navigateToCommentFlagPage().then(() => { - cy.get('@questionableUser').then(({ username }) => { - cy.intercept('POST', '/reactions').as('flagRequest'); + it('flags and unflags only the comment when clicked', () => { + cy.intercept('POST', '/reactions').as('flagRequest'); - findButton('Flag to Admins', { as: 'contentFlag' }); - findButton(`Flag ${username}`, { as: 'userFlag' }); + findButton('Flag to Admins', { as: 'contentFlag' }); + findButton(`Flag questionable_user`, { as: 'userFlag' }); - clickButton('@userFlag'); + clickButton('@contentFlag'); - cy.get('@contentFlag').should('not.have.class', 'reacted'); - cy.get('@userFlag').should('have.class', 'reacted'); + cy.get('@contentFlag').should('have.class', 'reacted'); + cy.get('@userFlag').should('not.have.class', 'reacted'); - clickButton('@userFlag'); + clickButton('@contentFlag'); - cy.get('@contentFlag').should('not.have.class', 'reacted'); - cy.get('@userFlag').should('not.have.class', 'reacted'); - }); - }); + cy.get('@contentFlag').should('not.have.class', 'reacted'); + cy.get('@userFlag').should('not.have.class', 'reacted'); }); - it.skip('visually toggles contradictory mod reactions off', () => { - navigateToCommentFlagPage().then(() => { - cy.intercept('POST', '/reactions').as('flagRequest'); + it('flags and unflags only the user when clicked', () => { + cy.intercept('POST', '/reactions').as('flagRequest'); - findButton('High Quality', { as: 'thumbsUp' }); - findButton('Low Quality', { as: 'thumbsDown' }); - findButton('Flag to Admins', { as: 'vomit' }); + findButton('Flag to Admins', { as: 'contentFlag' }); + findButton(`Flag questionable_user`, { as: 'userFlag' }); - clickButton('@thumbsUp'); + clickButton('@userFlag'); - cy.get('@thumbsUp').should('have.class', 'reacted'); - cy.get('@thumbsDown').should('not.have.class', 'reacted'); - cy.get('@vomit').should('not.have.class', 'reacted'); + cy.get('@contentFlag').should('not.have.class', 'reacted'); + cy.get('@userFlag').should('have.class', 'reacted'); - clickButton('@thumbsDown'); + clickButton('@userFlag'); - cy.get('@thumbsUp').should('not.have.class', 'reacted'); - cy.get('@thumbsDown').should('have.class', 'reacted'); - cy.get('@vomit').should('not.have.class', 'reacted'); + cy.get('@contentFlag').should('not.have.class', 'reacted'); + cy.get('@userFlag').should('not.have.class', 'reacted'); + }); - clickButton('@vomit'); + it('visually toggles contradictory mod reactions off', () => { + cy.intercept('POST', '/reactions').as('flagRequest'); - cy.get('@thumbsUp').should('not.have.class', 'reacted'); - cy.get('@thumbsDown').should('have.class', 'reacted'); - cy.get('@vomit').should('have.class', 'reacted'); + findButton('High Quality', { as: 'thumbsUp' }); + findButton('Low Quality', { as: 'thumbsDown' }); + findButton('Flag to Admins', { as: 'vomit' }); - clickButton('@thumbsUp'); + clickButton('@thumbsUp'); - cy.get('@thumbsUp').should('have.class', 'reacted'); - cy.get('@thumbsDown').should('not.have.class', 'reacted'); - cy.get('@vomit').should('not.have.class', 'reacted'); - }); + cy.get('@thumbsUp').should('have.class', 'reacted'); + cy.get('@thumbsDown').should('not.have.class', 'reacted'); + cy.get('@vomit').should('not.have.class', 'reacted'); + + clickButton('@thumbsDown'); + + cy.get('@thumbsUp').should('not.have.class', 'reacted'); + cy.get('@thumbsDown').should('have.class', 'reacted'); + cy.get('@vomit').should('not.have.class', 'reacted'); + + clickButton('@vomit'); + + cy.get('@thumbsUp').should('not.have.class', 'reacted'); + cy.get('@thumbsDown').should('have.class', 'reacted'); + cy.get('@vomit').should('have.class', 'reacted'); + + clickButton('@thumbsUp'); + + cy.get('@thumbsUp').should('have.class', 'reacted'); + cy.get('@thumbsDown').should('not.have.class', 'reacted'); + cy.get('@vomit').should('not.have.class', 'reacted'); }); }); @@ -116,20 +107,22 @@ describe('Moderation Tools for Comments', () => { cy.get('@admin').then((admin) => { cy.loginAndVisit(admin, '/series_user/series-test-article-slug'); + cy.get('#comments').within(() => { + cy.findByRole('button', { name: 'Toggle dropdown menu' }).click(); + cy.findByRole('link', { name: 'Moderate' }).click(); + }); }); }); it('also permits deleting comment with confirmation', () => { cy.findByText('Comment deleted').should('not.exist'); - navigateToCommentFlagPage().then(() => { - cy.on('window:confirm', () => true); + cy.on('window:confirm', () => true); - cy.findByRole('button', { name: /Delete Comment/ }).click(); + cy.findByRole('button', { name: /Delete Comment/ }).click(); - cy.url().should('include', '/series_user/series-test-article-slug'); - cy.findByText('Comment deleted').should('exist'); - }); + cy.url().should('include', '/series_user/series-test-article-slug'); + cy.findByText('Comment deleted').should('exist'); }); }); });