aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cypress/e2e/nav.cy.ts
blob: 02d5818b4d14cac4b9dcc4ccdfcac967bb86fe45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { ROUTES } from '../../../src/utils/constants';

describe(
  'Main navigation',
  { viewportWidth: 1280, viewportHeight: 720 },
  () => {
    beforeEach(() => {
      cy.visit('/');
    });

    it(
      'should show hamburger button on small devices',
      { viewportWidth: 810, viewportHeight: 1080 },
      () => {
        cy.findByLabelText(/Ouvrir le menu/i).should('exist');
      }
    );

    it(
      'should open and close main nav menu by clicking on hamburger button',
      { viewportWidth: 810, viewportHeight: 1080 },
      () => {
        // 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)
          .prev()
          .should('be.checked');
        cy.findByRole('link', { name: /Blog/i }).should('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');
      }
    );

    it('should hide hamburger button on large devices', () => {
      cy.findByLabelText(/Ouvrir le menu/i).should('be.hidden');
    });

    it('should navigate to the blog page', () => {
      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.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.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.findByLabelText('Navigation principale').within(() => {
        cy.findByRole('link', { name: /Contact/i }).click();
      });
      cy.url().should('include', ROUTES.CONTACT);
      cy.findByRole('heading', { level: 1 }).contains('Contact');
    });
  }
);

describe('Footer navigation', () => {
  beforeEach(() => {
    cy.visit('/');
  });

  it('should navigate to the legal notice page', () => {
    cy.findByRole('link', { name: /Mentions légales/i }).click();
    cy.url().should('include', ROUTES.LEGAL_NOTICE);
    cy.findByRole('heading', { level: 1 }).contains('Mentions légales');
  });
});