aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cypress/e2e/nav.cy.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-09-26 15:54:28 +0200
committerArmand Philippot <git@armandphilippot.com>2023-10-24 12:23:48 +0200
commit70efcfeaa0603415dd992cb662d8efb960e6e49a (patch)
tree5d37e98fae9aa7e5c3d8ef30a10db9fed9b63e36 /tests/cypress/e2e/nav.cy.ts
parent31695306bfed44409f03006ea717fd2cceff8f87 (diff)
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.
Diffstat (limited to 'tests/cypress/e2e/nav.cy.ts')
-rw-r--r--tests/cypress/e2e/nav.cy.ts24
1 files changed, 13 insertions, 11 deletions
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');
});
});