aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cypress/e2e/nav.cy.ts
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-11-15 19:11:06 +0100
committerArmand Philippot <git@armandphilippot.com>2023-11-15 19:11:06 +0100
commitbb2d78e75626a99ce8ccd5be31924bd4dd799faf (patch)
tree8f2f24a924d27a7d9b8cf8a81784a3bd157b02b5 /tests/cypress/e2e/nav.cy.ts
parent26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104 (diff)
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...
Diffstat (limited to 'tests/cypress/e2e/nav.cy.ts')
-rw-r--r--tests/cypress/e2e/nav.cy.ts32
1 files changed, 23 insertions, 9 deletions
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');
});