From bb2d78e75626a99ce8ccd5be31924bd4dd799faf Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 15 Nov 2023 19:11:06 +0100 Subject: test: fix most of the e2e tests errors * back-to-top test is not working: for some reasons, the link only appears when manually scrolling * search test has failure test: it seems the page meta is too long to load Anyway, the pages will be refactored and the e2e should also be refactored. But the back to top test remains problematic... --- tests/cypress/e2e/nav.cy.ts | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'tests/cypress/e2e/nav.cy.ts') diff --git a/tests/cypress/e2e/nav.cy.ts b/tests/cypress/e2e/nav.cy.ts index 14d4e8c..02d5818 100644 --- a/tests/cypress/e2e/nav.cy.ts +++ b/tests/cypress/e2e/nav.cy.ts @@ -20,14 +20,20 @@ describe( 'should open and close main nav menu by clicking on hamburger button', { viewportWidth: 810, viewportHeight: 1080 }, () => { - cy.findByLabelText(/Fermer le menu/i).should('not.exist'); + // findByLabelText does not return the input but the label... + cy.findByLabelText(/Ouvrir le menu/i) + .prev() + .should('not.be.checked'); cy.findByRole('link', { name: /Blog/i }).should('not.exist'); cy.findByLabelText(/Ouvrir le menu/i).click(); - cy.findByLabelText(/Ouvrir le menu/i).should('not.exist'); - cy.findByLabelText(/Fermer le menu/i).should('exist'); + cy.findByLabelText(/Ouvrir le menu/i) + .prev() + .should('be.checked'); cy.findByRole('link', { name: /Blog/i }).should('exist'); - cy.findByLabelText(/Fermer le menu/i).click(); - cy.findByLabelText(/Fermer le menu/i).should('not.exist'); + cy.findByLabelText(/Ouvrir le menu/i).click(); + cy.findByLabelText(/Ouvrir le menu/i) + .prev() + .should('not.be.checked'); cy.findByRole('link', { name: /Blog/i }).should('not.exist'); cy.findByLabelText(/Ouvrir le menu/i).should('exist'); } @@ -38,25 +44,33 @@ describe( }); it('should navigate to the blog page', () => { - cy.findByRole('link', { name: /Blog/i }).click(); + cy.findByLabelText('Navigation principale').within(() => { + cy.findByRole('link', { name: /Blog/i }).click(); + }); cy.url().should('include', ROUTES.BLOG); cy.findByRole('heading', { level: 1 }).contains('Blog'); }); it('should navigate to the CV page', () => { - cy.findByRole('link', { name: /CV/i }).click(); + cy.findByLabelText('Navigation principale').within(() => { + cy.findByRole('link', { name: /CV/i }).click(); + }); cy.url().should('include', ROUTES.CV); cy.findByRole('heading', { level: 1 }).contains('CV'); }); it('should navigate to the projects page', () => { - cy.findByRole('link', { name: /Projets/i }).click(); + cy.findByLabelText('Navigation principale').within(() => { + cy.findByRole('link', { name: /Projets/i }).click(); + }); cy.url().should('include', ROUTES.PROJECTS); cy.findByRole('heading', { level: 1 }).contains('Projets'); }); it('should navigate to the contact page', () => { - cy.findByRole('link', { name: /Contact/i }).click(); + cy.findByLabelText('Navigation principale').within(() => { + cy.findByRole('link', { name: /Contact/i }).click(); + }); cy.url().should('include', ROUTES.CONTACT); cy.findByRole('heading', { level: 1 }).contains('Contact'); }); -- cgit v1.2.3