From 70efcfeaa0603415dd992cb662d8efb960e6e49a Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Tue, 26 Sep 2023 15:54:28 +0200 Subject: refactor(routes): replace hardcoded routes with constants It makes it easier to change a route if needed and it avoid typo mistakes. I also refactored a bit the concerned files to be complient with the new ESlint config. However, I should rewrite the pages to reduce the number of statements. --- tests/cypress/e2e/nav.cy.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 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 5851058..14d4e8c 100644 --- a/tests/cypress/e2e/nav.cy.ts +++ b/tests/cypress/e2e/nav.cy.ts @@ -1,3 +1,5 @@ +import { ROUTES } from '../../../src/utils/constants'; + describe( 'Main navigation', { viewportWidth: 1280, viewportHeight: 720 }, @@ -35,27 +37,27 @@ describe( cy.findByLabelText(/Ouvrir le menu/i).should('be.hidden'); }); - it('should navigate to the blog page', async () => { + it('should navigate to the blog page', () => { cy.findByRole('link', { name: /Blog/i }).click(); - cy.url().should('include', '/blog'); + cy.url().should('include', ROUTES.BLOG); cy.findByRole('heading', { level: 1 }).contains('Blog'); }); - it('should navigate to the CV page', async () => { + it('should navigate to the CV page', () => { cy.findByRole('link', { name: /CV/i }).click(); - cy.url().should('include', '/cv'); + cy.url().should('include', ROUTES.CV); cy.findByRole('heading', { level: 1 }).contains('CV'); }); - it('should navigate to the projects page', async () => { - cy.findByRole('link', { name: /Projects/i }).click(); - cy.url().should('include', '/projets'); + it('should navigate to the projects page', () => { + 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', async () => { + it('should navigate to the contact page', () => { cy.findByRole('link', { name: /Contact/i }).click(); - cy.url().should('include', '/contact'); + cy.url().should('include', ROUTES.CONTACT); cy.findByRole('heading', { level: 1 }).contains('Contact'); }); } @@ -66,9 +68,9 @@ describe('Footer navigation', () => { cy.visit('/'); }); - it('should navigate to the legal notice page', async () => { + it('should navigate to the legal notice page', () => { cy.findByRole('link', { name: /Mentions légales/i }).click(); - cy.url().should('include', '/mentions-legales'); + cy.url().should('include', ROUTES.LEGAL_NOTICE); cy.findByRole('heading', { level: 1 }).contains('Mentions légales'); }); }); -- cgit v1.2.3