From de40fe86e9099cf22626518fef2a6972ff1b09d4 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Fri, 7 May 2021 16:30:38 +0200 Subject: [PATCH] test(e2e): more settings tests (#42046) --- .github/workflows/cypress.yml | 7 +++++- cypress/integration/settings/email-change.js | 9 +++++-- cypress/integration/settings/settings.js | 13 +++++++--- cypress/integration/user/report-user.js | 25 ++++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 cypress/integration/user/report-user.js diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 597e3509d7..9a1b48232e 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -1,5 +1,5 @@ name: Cypress -on: +on: push: branches-ignore: - 'renovate/**' @@ -18,6 +18,11 @@ jobs: image: mongo:3.6.19 ports: - 27017:27017 + # We need mailhog to catch any emails the api tries to send. + mailhog: + image: mailhog/mailhog + ports: + - 1025:1025 steps: # We use .npmrc to set the default version to 0, and prevents download during development. diff --git a/cypress/integration/settings/email-change.js b/cypress/integration/settings/email-change.js index fae05c4725..4d3af67451 100644 --- a/cypress/integration/settings/email-change.js +++ b/cypress/integration/settings/email-change.js @@ -1,6 +1,7 @@ /* global cy */ describe('Email input field', () => { - before(() => { + beforeEach(() => { + cy.exec('npm run seed'); cy.login(); cy.visit('/settings'); }); @@ -17,10 +18,14 @@ describe('Email input field', () => { cy.get('[id=form-update-email]').within(() => { cy.contains('Save').click(); }); + cy.contains( + 'Check your email and click the link we sent you to confirm your new email address.' + ); }); it('Displays an error message when there are problems with the submitted emails', () => { - cy.get('[id=confirm-email]').clear().type('foo@bar.com'); + cy.get('[id=new-email]').type('bar@foo.com'); + cy.get('[id=confirm-email]').type('foo@bar.com'); cy.get('[class=help-block]').contains( 'Both new email addresses must be the same' diff --git a/cypress/integration/settings/settings.js b/cypress/integration/settings/settings.js index f9eb37bc1b..7a057ac5ad 100644 --- a/cypress/integration/settings/settings.js +++ b/cypress/integration/settings/settings.js @@ -1,8 +1,15 @@ -/* global cy */ +/* global cy expect */ + describe('Settings', () => { - it('should be possible to visit the settings page', () => { + it('should be possible to reset your progress', () => { cy.visit('/'); - cy.contains("Get started (it's free)").click({ force: true }); + cy.contains("Get started (it's free)").click(); cy.visit('/settings'); + cy.contains('Reset all of my progress').click(); + cy.contains('Reset everything. I want to start from the beginning').click(); + cy.location().should(loc => { + expect(loc.pathname).to.eq('/'); + }); + cy.contains('Your progress has been reset'); }); }); diff --git a/cypress/integration/user/report-user.js b/cypress/integration/user/report-user.js new file mode 100644 index 0000000000..0b0469b1d0 --- /dev/null +++ b/cypress/integration/user/report-user.js @@ -0,0 +1,25 @@ +/* global cy expect */ + +describe('Report User', () => { + beforeEach(() => { + cy.exec('npm run seed'); + cy.login(); + }); + it('should be possible to report a user from their profile page', () => { + // Since going to a user page intially generates a 404, we have to ignore + // status codes on that request + cy.visit('/twaha', { failOnStatusCode: false }); + // The following line is only required if you want to test it in development + // cy.contains('Preview custom 404 page').click(); + cy.contains("Flag This User's Account for Abuse").click(); + cy.contains("Do you want to report twaha's portfolio for abuse?"); + cy.get('[id=report-user-textarea]').type('Some details'); + cy.contains('Submit the report').click(); + cy.location().should(loc => { + expect(loc.pathname).to.eq('/learn'); + }); + cy.contains('A report was sent to the team with foo@bar.com in copy'); + }); +}); + +// A report was sent to the team with foo@bar.com in copy