diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-31 23:17:27 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-06-03 11:54:08 +0200 |
| commit | b7d735bc385184c745781af4e6aaa75de111998c (patch) | |
| tree | 01a4b5266aa48cccf93ab14122d77c5604d1a2a1 /tests | |
| parent | d0027d69a921dc43d66807b1698e6b4848bc9b1d (diff) | |
test(e2e): add contact page test
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/cypress/e2e/pages/contact.cy.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/cypress/e2e/pages/contact.cy.ts b/tests/cypress/e2e/pages/contact.cy.ts new file mode 100644 index 0000000..6e1cdb6 --- /dev/null +++ b/tests/cypress/e2e/pages/contact.cy.ts @@ -0,0 +1,41 @@ +const userName = 'Cypress Test'; +const userEmail = 'cypress@testing.com'; +const object = '[Cypress] quos aperiam culpa'; +const message = + 'Asperiores ea nihil. Nam ipsam est sunt porro. Ratione in facilis cum. Voluptatem pariatur rerum.'; + +describe('Contact Page', () => { + beforeEach(() => { + cy.visit('/contact'); + }); + + it('shows a heading and a contact form', () => { + cy.findByRole('heading', { level: 1 }).contains(/Contact/i); + cy.findByRole('form', { name: /Formulaire de contact/i }); + }); + + it('submits the form', async () => { + cy.findByRole('textbox', { name: /Nom/i }) + .type(userName) + .should('have.value', userName); + cy.findByRole('textbox', { name: /E-mail/i }) + .type(userEmail) + .should('have.value', userEmail); + cy.findByRole('textbox', { name: /Sujet/i }) + .type(object) + .should('have.value', object); + cy.findByRole('textbox', { name: /Message/i }) + .type(message) + .should('have.value', message); + cy.findByRole('button', { name: /Envoyer/i }).click(); + cy.findByText(/E-mail en cours d'envoi/i).should('be.visible'); + }); + + it('prevents the form to submit if some fields are missing', async () => { + cy.findByRole('textbox', { name: /E-mail/i }) + .type(userEmail) + .should('have.value', userEmail); + cy.findByRole('button', { name: /Envoyer/i }).click(); + cy.findByText(/E-mail en cours d'envoi/i).should('not.be.visible'); + }); +}); |
