Skip to content

Commit aad279d

Browse files
committed
tests
1 parent 56938bc commit aad279d

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
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+
110
describe('Check newsletter subribe', () => {
211
it('Test empty input', () => {
312
cy.visit('/')
413
cy.get('#newsletter-validate-detail button[type="submit"]').click();
514
cy.get('#advice-required-entry-newsletter').should('include.text', 'This is a required field.');
615
})
716

8-
it('Test invalid input', () => {
17+
it('Test valid input twice', () => {
18+
const randomEmail = generateRandomEmail();
919
cy.visit('/')
10-
cy.get('#newsletter').type('notvalidemail');
20+
cy.get('#newsletter').type(randomEmail);
1121
cy.get('#newsletter-validate-detail button[type="submit"]').click();
12-
cy.get('.success-msg').should('include.text', 'Please enter a valid email address.');
13-
})
22+
cy.get('.success-msg').should('include.text', 'Thank you for your subscription.');
1423

15-
it('Test valid input', () => {
16-
cy.visit('/')
17-
cy.get('#newsletter').type('[email protected]');
24+
cy.get('#newsletter').type(randomEmail);
1825
cy.get('#newsletter-validate-detail button[type="submit"]').click();
19-
cy.get('.success-msg').should('include.text', 'Thank you for your subscription.');
26+
cy.get('.success-msg').should('include.text', 'There was a problem with the subscription: This email address is already registered.');
2027
})
2128
})

0 commit comments

Comments
 (0)