Skip to content

Commit 8822c0b

Browse files
committed
tests
1 parent 96d9592 commit 8822c0b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
function generateRandomEmail() {
2+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
3+
let email = '';
4+
for (let i = 0; i < 16; i++) {
5+
email += chars.charAt(Math.floor(Math.random() * chars.length));
6+
}
7+
return email + '@example.com';
8+
}
9+
10+
describe('Checks admin cms routes', () => {
11+
beforeEach('Log in the user', () => {
12+
cy.visit('/customer/account/create');
13+
});
14+
15+
it('Checks the Create Account page title', () => {
16+
cy.get('h1').should('include.text', 'Create an Account');
17+
});
18+
19+
it('Submits empty form', () => {
20+
cy.get('#form-validate button[type="submit"]').click();
21+
cy.get('#advice-required-entry-firstname').should('include.text', 'This is a required field.');
22+
cy.get('#advice-required-entry-lastname').should('include.text', 'This is a required field.');
23+
cy.get('#advice-required-entry-email_address').should('include.text', 'This is a required field.');
24+
cy.get('#advice-required-entry-password').should('include.text', 'This is a required field.');
25+
cy.get('#advice-required-entry-confirmation').should('include.text', 'This is a required field.');
26+
});
27+
28+
it('Submits form with short password and wrong confirmation', () => {
29+
cy.get('#password').type('123');
30+
cy.get('#confirmation').type('abc');
31+
cy.get('#form-validate button[type="submit"]').click();
32+
cy.get('#advice-validate-password-password').should('include.text', 'Please enter more characters or clean leading or trailing spaces.');
33+
cy.get('#advice-validate-cpassword-confirmation').should('include.text', 'Please make sure your passwords match.');
34+
});
35+
36+
it('Submits valid form', () => {
37+
const randomEmail = generateRandomEmail();
38+
cy.get('#firstname').type('John');
39+
cy.get('#lastname').type('Doe');
40+
cy.get('#email_address').type(randomEmail);
41+
cy.get('#password').type('12345678');
42+
cy.get('#confirmation').type('12345678');
43+
cy.get('#form-validate button[type="submit"]').click();
44+
cy.get('#advice-validate-password-password').should('include.text', 'Please enter more characters or clean leading or trailing spaces.');
45+
cy.get('#advice-validate-cpassword-confirmation').should('include.text', 'Please make sure your passwords match.');
46+
});
47+
});

0 commit comments

Comments
 (0)