summaryrefslogtreecommitdiffstats
path: root/tests/cypress
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-05-27 17:21:28 +0200
committerArmand Philippot <git@armandphilippot.com>2022-06-02 19:10:28 +0200
commit9004b22d7fb53f9dc98e65e4f450589b5d78cbd5 (patch)
treedc94801e6ed2c4196ea40ba0cf16687314ae26ac /tests/cypress
parentf7cc48495b085fe8f6cfa37e80e968d5b47639df (diff)
test(e2e): add main navigation test
Diffstat (limited to 'tests/cypress')
-rw-r--r--tests/cypress/e2e/nav.cy.ts62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/cypress/e2e/nav.cy.ts b/tests/cypress/e2e/nav.cy.ts
new file mode 100644
index 0000000..cdca0df
--- /dev/null
+++ b/tests/cypress/e2e/nav.cy.ts
@@ -0,0 +1,62 @@
+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 },
+ () => {
+ cy.findByLabelText(/Fermer le menu/i).should('not.exist');
+ 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.findByRole('link', { name: /Blog/i }).should('exist');
+ cy.findByLabelText(/Fermer le menu/i).click();
+ cy.findByLabelText(/Fermer le menu/i).should('not.exist');
+ 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', async () => {
+ cy.findByRole('link', { name: /Blog/i }).click();
+ cy.url().should('include', '/blog');
+ cy.findByRole('heading', { level: 1 }).contains('Blog');
+ });
+
+ it('should navigate to the CV page', async () => {
+ cy.findByRole('link', { name: /CV/i }).click();
+ cy.url().should('include', '/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');
+ cy.findByRole('heading', { level: 1 }).contains('Projets');
+ });
+
+ it('should navigate to the contact page', async () => {
+ cy.findByRole('link', { name: /Contact/i }).click();
+ cy.url().should('include', '/contact');
+ cy.findByRole('heading', { level: 1 }).contains('Contact');
+ });
+ }
+);