-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangepassword.cy.ts
More file actions
62 lines (56 loc) · 2.44 KB
/
changepassword.cy.ts
File metadata and controls
62 lines (56 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const currentPassword = 'IloveOrangeCones123!';
const newPassword = currentPassword + 'TEST';
const email = 'cypressTestUser@mobilitydata.org';
describe('Change Password Screen', () => {
beforeEach(() => {
cy.visit('/');
cy.get('[data-testid="home-title"]').should('exist');
cy.createNewUserAndSignIn(email, currentPassword);
cy.get('[data-cy="accountHeader"]').should('exist').click(); // assures that the user is signed in
cy.get('[data-cy="accountDetailsHeader"]').should('exist').click();
cy.get('[data-cy="changePasswordButton"]').should('exist').click();
});
it('should render components', () => {
cy.get('input[id="currentPassword"]').should('exist');
cy.get('input[id="newPassword"]').should('exist');
cy.get('input[id="confirmNewPassword"]').should('exist');
});
it('should show error when current password is incorrect', () => {
cy.get('input[id="currentPassword"]').type('wrong');
cy.get('input[id="newPassword"]').type(newPassword);
cy.get('input[id="confirmNewPassword"]').type(newPassword);
cy.get('[data-cy="changePasswordButton"]').click();
cy.contains(
'The password is invalid or the user does not have a password. (auth/wrong-password).',
).should('exist');
});
it('should change password', () => {
cy.intercept('POST', '/retrieveUserInformation', {
statusCode: 200,
body: {
result: {
uid: 'ep4EwJvgNhfEER152EfzLSI0MBG2',
isRegisteredToReceiveAPIAnnouncements: false,
organization: '',
fullName: 'Alessandro',
registrationCompletionTime: '2024-09-24T15:34:55.381Z',
},
},
});
cy.get('input[id="currentPassword"]').type(currentPassword);
cy.get('input[id="newPassword"]').type(newPassword);
cy.get('input[id="confirmNewPassword"]').type(newPassword);
cy.get('[data-cy="changePasswordButton"]').click();
cy.contains('Change Password Succeeded').should('exist');
cy.get('[cy-data="goToAccount"]').click();
cy.location('pathname').should('eq', '/account');
// logout
cy.get('[data-cy="signOutButton"]').click();
cy.get('[data-cy="confirmSignOutButton"]').should('exist').should('not.be.disabled').click();
cy.visit('/sign-in');
cy.get('[data-cy="signInEmailInput"]').type(email);
cy.get('[data-cy="signInPasswordInput"]').type(newPassword);
cy.get('[data-testid="signin"]').click();
cy.location('pathname').should('eq', '/account');
});
});