Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 62edd83

Browse files
committed
e2e register-login-out and login-out journeys
1 parent 6087a99 commit 62edd83

File tree

9 files changed

+432
-237
lines changed

9 files changed

+432
-237
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ To run the tests
2727
docker-compose run --rm cypress
2828
```
2929

30+
### E2E Tests
31+
The tests in the `/cypress/integration_e2e` folder that are not run as part of the main test in CI.
32+
33+
They are designed to be run manually & locally with the full stack, no endpoints are stubbed.
34+
35+
> NOTE: the register test includes a 5 second pause where you are required to click the recaptcha.
36+
37+
```
38+
yarn cypress:e2e:open
39+
```
40+
3041
## wdio tests
3142
The selenium-based wdio tests are legacy tests, waiting to be migrated to cypress. They are not actively maintained and are there only for reference until migrated.
3243
To run the tests

cypress-e2e.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrationFolder": "cypress/integration_e2e",
3+
"baseUrl": "http://localhost:8000",
4+
"video": false
5+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import page from '../../pages/login';
2+
import homePage from '../../pages/home';
3+
4+
describe('Login & out Smoke', () => {
5+
describe('Successful Login & out', () => {
6+
it('should login successfully without a referrer query param', () => {
7+
cy.visit('/login');
8+
cy.get(page.email).type('[email protected]');
9+
cy.get(page.password).type('test');
10+
cy.get(page.login).click();
11+
12+
cy.url().should('include', '/home');
13+
cy.get(homePage.menuUserName).first().invoke('text').should('eq', 'Namey McNameFace');
14+
});
15+
16+
it('should login successfully with a referrer query param', () => {
17+
cy.visit('/login?referrer=%2Fdashboard%2Ftickets');
18+
cy.get(page.email).type('[email protected]');
19+
cy.get(page.password).type('test');
20+
cy.get(page.login).click();
21+
22+
cy.url().should('include', '/dashboard/tickets');
23+
cy.get(homePage.menuUserName).first().invoke('text').should('eq', 'Namey McNameFace');
24+
});
25+
26+
it('should logout successfully', () => {
27+
cy.visit('/login');
28+
cy.get(page.email).type('[email protected]');
29+
cy.get(page.password).type('test');
30+
cy.get(page.login).click();
31+
32+
cy.url().should('include', '/home');
33+
cy.get(homePage.menuUserName).first().click();
34+
cy.get(homePage.menuLogout).first().click();
35+
36+
cy.get(homePage.menuUserName).should('not.be.visible');
37+
});
38+
});
39+
});
40+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import userPage from '../../pages/register-user';
2+
import profilePage from '../../pages/register-profile';
3+
import loginPage from '../../pages/login';
4+
import homePage from '../../pages/home';
5+
6+
const uniqueEmail = `smoke_${String(Math.random()).slice(2)}@test.com`;
7+
const password = 't3stt3st';
8+
9+
describe('Register, login & out Smoke', () => {
10+
it('should register', () => {
11+
cy.visit('/register/user');
12+
13+
cy.get(userPage.firstName).type('Namey');
14+
cy.get(userPage.surname).type('McNameFace');
15+
cy.get(userPage.emailAddress).type(uniqueEmail);
16+
cy.get(userPage.password).type(password);
17+
cy.get(userPage.passConfirmField).type(password);
18+
cy.get(userPage.termsConditionsAccepted).check();
19+
cy.get(userPage.submit).click();
20+
cy.url().should('include', '/register/profile');
21+
22+
cy.get(profilePage.dobCalendarBtn).click();
23+
cy.get(profilePage.yearButton).first().click();
24+
cy.get(profilePage.monthButton).first().click();
25+
cy.get(profilePage.dayButton).first().click();
26+
cy.get(profilePage.countrySelectOpen).click();
27+
cy.get(profilePage.countryInput).type('united kingdom');
28+
cy.get(profilePage.countryOption).first().click();
29+
cy.wait(5000); // Click the recaptcha!
30+
cy.get(profilePage.submit).click();
31+
32+
cy.url().should('include', '/home');
33+
cy.get(homePage.menuUserName).first().invoke('text').should('eq', 'Namey McNameFace');
34+
});
35+
it('should logout', () => {
36+
cy.get(homePage.menuUserName).first().click();
37+
cy.get(homePage.menuLogout).first().click();
38+
39+
cy.get(homePage.menuUserName).should('not.be.visible');
40+
});
41+
it('should login', () => {
42+
cy.visit('/login');
43+
cy.get(loginPage.email).type(uniqueEmail);
44+
cy.get(loginPage.password).type(password);
45+
cy.get(loginPage.login).click();
46+
47+
cy.url().should('include', '/home');
48+
cy.get(homePage.menuUserName).first().invoke('text').should('eq', 'Namey McNameFace');
49+
});
50+
});
51+

cypress/pages/home.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export default {
2121
statsYouthGenderChart: '.cd-dashboard-stats__circle',
2222
statsUseZenMessage: '.cd-dashboard-stats p',
2323
statsYouthGirlsHint: '.cd-dashboard-stats__chart-pie-hint',
24+
menuUserName: '.cd-menu__profile-name',
25+
menuLogout: '.cd-menu__referer-link',
2426
comms: {
2527
anniversaryLink: '.cd-dashboard__anniversary',
2628
},

cypress/pages/register-profile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
dobCalendarBtn: 'button.btn-default',
3+
yearButton: '.uib-year button',
4+
monthButton: '.uib-month button',
5+
dayButton: '.uib-day button',
6+
countrySelectOpen: 'i[role=button]',
7+
countryInput: '.ui-select-container input[type=search]',
8+
countryOption: '.ui-select-choices-row',
9+
recaptcha: 'iframe[role=presentation]',
10+
submit: 'button[type=submit]',
11+
};

cypress/pages/register-user.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
firstName: 'input[name=firstName]',
3+
surname: 'input[name=surname]',
4+
emailAddress: 'input[name=emailAddress]',
5+
password: 'input[name=password]',
6+
passConfirmField: 'input[name=passConfirmField]',
7+
termsConditionsAccepted: 'input[name=termsConditionsAccepted]',
8+
submit: 'button[type=submit]',
9+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"mock-server": "node ./json-server/server.js",
1919
"cypress": "yarn build && concurrently --kill-others --success first \"http-server dist/ --push-state > /dev/null\" \"cypress run --browser chrome\"",
2020
"cypress:open": "cypress open",
21+
"cypress:e2e": "cypress open --config-file cypress-e2e.json",
2122
"cypress:install": "cypress install"
2223
},
2324
"dependencies": {
@@ -68,7 +69,7 @@
6869
"copy-webpack-plugin": "^4.0.1",
6970
"cross-env": "^4.0.0",
7071
"css-loader": "^0.28.0",
71-
"cypress": "^3.1.5",
72+
"cypress": "^3.7.0",
7273
"eslint": "^3.19.0",
7374
"eslint-config-airbnb-base": "^11.1.3",
7475
"eslint-friendly-formatter": "^2.0.7",

0 commit comments

Comments
 (0)