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

Commit bcdfd1b

Browse files
committed
migrate remaining login selenium tests
1 parent e58b94f commit bcdfd1b

File tree

6 files changed

+122
-136
lines changed

6 files changed

+122
-136
lines changed

cypress/fixtures/loginFail.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"ok":false,
3+
"why":"invalid-password"
4+
}

cypress/fixtures/loginSuccess.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"ok": true,
3+
"why": "password",
4+
"user": {},
5+
"login": {}
6+
}
Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,113 @@
11
import page from '../../pages/login';
22

3+
const setupLoggedInServer = () => {
4+
cy.server();
5+
cy.route('POST', '/api/2.0/users/login', 'fx:loginSuccess').as('login');
6+
cy.route('/api/2.0/users/instance', 'fx:parentLoggedIn').as('instance');
7+
cy.route('POST', '/api/2.0/dojos/users', 'fx:userDojosChampion').as('userDojosChampion');
8+
};
9+
310
describe('Login Page', () => {
4-
it('should show the header, login box , and all login box elements', () => {
5-
cy.visit('/login');
6-
cy.get(page.header).should('be.visible');
7-
cy.get(page.loginBox).should('be.visible');
8-
cy.get(page.email).should('be.visible');
9-
cy.get(page.password).should('be.visible');
10-
cy.get(page.login).should('be.visible');
11-
cy.get(page.forgotPassword).should('be.visible');
12-
cy.get(page.register).should('be.visible');
13-
cy.get(page.forgotPasswordLink).should('have.attr', 'href', '/reset');
14-
cy.get(page.registerLink).should('have.attr', 'href', '/register');
11+
describe('Form Validation', () => {
12+
beforeEach(() => {
13+
cy.visit('/login');
14+
});
15+
16+
it('should show the header, login box, and all login box elements', () => {
17+
cy.get(page.header).should('be.visible');
18+
cy.get(page.loginBox).should('be.visible');
19+
cy.get(page.email).should('be.visible');
20+
cy.get(page.password).should('be.visible');
21+
cy.get(page.login).should('be.visible');
22+
cy.get(page.forgotPassword).should('be.visible');
23+
cy.get(page.register).should('be.visible');
24+
cy.get(page.forgotPasswordLink).should('have.attr', 'href', '/reset');
25+
cy.get(page.registerLink).should('have.attr', 'href', '/register');
26+
});
27+
28+
it('should show an error when no email is provided on a blur event', () => {
29+
cy.get(page.emailFormatError).should('not.be.visible'); // TODO: Should be emailReqError?
30+
cy.get(page.email).click();
31+
cy.get(page.email).invoke('text').should('eq', '');
32+
cy.get(page.password).click();
33+
cy.get(page.emailFormatError).should('be.visible');
34+
});
35+
36+
it('should show an error when no password is provided on a blur event', () => {
37+
cy.get(page.passwordReqError).should('not.be.visible');
38+
cy.get(page.password).click();
39+
cy.get(page.password).invoke('text').should('eq', '');
40+
cy.get(page.loginBox).click();
41+
cy.get(page.passwordReqError).should('be.visible');
42+
});
43+
44+
it('should show an error when the email input is not in the correct format', () => {
45+
cy.get(page.emailFormatError).should('not.be.visible');
46+
cy.get(page.email).click();
47+
cy.get(page.email).type('janedoe');
48+
cy.get(page.password).click();
49+
cy.get(page.emailFormatError).should('be.visible');
50+
});
51+
52+
it('should show an error when the login fails (on mock server this is only when the incorrect email is provided)', () => {
53+
cy.server();
54+
cy.route('POST', '/api/2.0/users/login', 'fx:loginFail').as('loginFail');
55+
cy.get(page.loginFailed).should('not.be.visible');
56+
cy.get(page.email).click();
57+
cy.get(page.email).type('[email protected]');
58+
cy.get(page.password).type('wrongpassword');
59+
cy.get(page.login).click();
60+
cy.wait('@loginFail');
61+
cy.get(page.loginFailed).should('be.visible');
62+
});
63+
64+
it('should show both requirement errors when a login is attempted if no email and no password is provided', () => {
65+
cy.get(page.emailFormatError).should('not.be.visible'); // TODO: Should be emailReqError?
66+
cy.get(page.passwordReqError).should('not.be.visible');
67+
cy.get(page.login).click();
68+
cy.get(page.emailFormatError).should('be.visible');
69+
cy.get(page.passwordReqError).should('be.visible');
70+
});
71+
72+
it('should show only the email format error when a login is attempted if no password and incorrect form of email is provided', () => {
73+
cy.get(page.emailFormatError).should('not.be.visible');
74+
cy.get(page.email).type('janedoe');
75+
cy.get(page.login).click();
76+
cy.get(page.emailFormatError).should('be.visible');
77+
});
78+
79+
it('should show password requirement error when a login is attempted if no password but an email is provided', () => {
80+
cy.get(page.passwordReqError).should('not.be.visible');
81+
cy.get(page.email).type('[email protected]');
82+
cy.get(page.login).click();
83+
cy.get(page.passwordReqError).should('be.visible');
84+
});
85+
86+
it('should show email requirement error when a login is attempted if no email but a password is provided', () => {
87+
cy.get(page.emailFormatError).should('not.be.visible'); // TODO: Should be emailReqError?
88+
cy.get(page.password).type('test123');
89+
cy.get(page.login).click();
90+
cy.get(page.emailFormatError).should('be.visible');
91+
});
92+
});
93+
94+
describe('Successful Login', () => {
95+
it('should login successfully without a referrer query param', () => {
96+
cy.visit('/login');
97+
setupLoggedInServer();
98+
cy.get(page.email).type('[email protected]');
99+
cy.get(page.password).type('testparent1');
100+
cy.get(page.login).click();
101+
cy.url().should('include', '/home');
102+
});
103+
104+
it('should login successfully with a referrer query param', () => {
105+
cy.visit('/login?referrer=%2Fdashboard%2Ftickets');
106+
setupLoggedInServer();
107+
cy.get(page.email).type('[email protected]');
108+
cy.get(page.password).type('testparent1');
109+
cy.get(page.login).click();
110+
cy.url().should('include', '/dashboard/tickets');
111+
});
15112
});
16-
})
113+
});

cypress/integration/dashboard/communications_spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import moment from 'moment';
2-
import eventPage from '../../pages/events';
32
import homePage from '../../pages/home';
43

54
describe('Homepage comms', () => {

cypress/integration/dashboard/news_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('Dashboard news', () => {
1313
cy.wait('@blogArticles');
1414
cy.get(homePage.newsTitle).invoke('text').should('eq', 'News');
1515
});
16-
16+
1717
it('should display the latest 6 news', () => {
1818
cy.visit('/home');
1919
cy.wait('@loggedIn');
@@ -26,7 +26,7 @@ describe('Dashboard news', () => {
2626
cy.wait('@loggedIn');
2727
cy.wait('@blogArticles');
2828
cy.get(homePage.newsEntries).first()
29-
.within((el) => {
29+
.within(() => {
3030
cy.get(homePage.newsEntryTitle).invoke('text').should('eq', 'What we discussed on the July Open Community Call');
3131
cy.get(homePage.newsEntryDate).invoke('text').should('eq', '09/08/2018');
3232
// cy.get(homePage.newsEntryCategory).invoke('text').should('eq', 'News');
@@ -37,7 +37,7 @@ describe('Dashboard news', () => {
3737
cy.wait('@loggedIn');
3838
cy.wait('@blogArticles');
3939
cy.get(homePage.newsEntries).last()
40-
.within((el) => {
40+
.within(() => {
4141
cy.get(homePage.newsEntryDate).invoke('text').should('eq', '17/07/2018');
4242
});
4343
});

test/e2e/specs/login.js

Lines changed: 0 additions & 120 deletions
This file was deleted.

0 commit comments

Comments
 (0)