diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-15 19:11:06 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-15 19:11:06 +0100 |
| commit | bb2d78e75626a99ce8ccd5be31924bd4dd799faf (patch) | |
| tree | 8f2f24a924d27a7d9b8cf8a81784a3bd157b02b5 /tests/cypress/e2e/search.cy.ts | |
| parent | 26a1e3a7a08e4b0fdb4dfcc3ed6a6cc21bcef104 (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/search.cy.ts')
| -rw-r--r-- | tests/cypress/e2e/search.cy.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/cypress/e2e/search.cy.ts b/tests/cypress/e2e/search.cy.ts index 5f2081d..be9aa9f 100644 --- a/tests/cypress/e2e/search.cy.ts +++ b/tests/cypress/e2e/search.cy.ts @@ -4,21 +4,22 @@ const queryWithArticles = 'Coldark'; const queryWithoutArticles = 'etEtRerum'; describe('Search', () => { - /* eslint-disable max-statements */ it('should open and close search form by clicking on search button', () => { cy.visit('/'); - cy.findByLabelText(/Fermer la recherche/i).should('not.exist'); + // findByLabelText does not return the input but the label... + cy.findByLabelText(/Ouvrir la recherche/i) + .prev() + .should('not.be.checked'); cy.findByRole('searchbox', { name: /Rechercher/i }).should('not.exist'); cy.findByLabelText(/Ouvrir la recherche/i).click(); - cy.findByLabelText(/Ouvrir la recherche/i).should('not.exist'); - cy.findByLabelText(/Fermer la recherche/i).should('exist'); + cy.findByLabelText(/Ouvrir la recherche/i) + .prev() + .should('be.checked'); cy.findByRole('searchbox', { name: /Rechercher/i }).should('exist'); - cy.findByLabelText(/Fermer la recherche/i).click(); - cy.findByLabelText(/Fermer la recherche/i).should('not.exist'); + cy.findByLabelText(/Ouvrir la recherche/i).click(); + cy.findByLabelText(/Ouvrir la recherche/i).should('not.be.checked'); cy.findByRole('searchbox', { name: /Rechercher/i }).should('not.exist'); - cy.findByLabelText(/Ouvrir la recherche/i).should('exist'); }); - /* eslint-enable max-statements */ it('should navigate the search page', () => { cy.visit('/'); @@ -34,8 +35,9 @@ describe('Search', () => { it('should display the total of articles if successful', () => { cy.visit(`${ROUTES.SEARCH}?s=${encodeURIComponent(queryWithArticles)}`); - const dtSiblings = cy.findByRole('term', { name: /Total/i }).siblings(); - dtSiblings.findByRole('definition').contains(/article/i); + const metaList = cy.findByRole('heading', { level: 1 }).next(); + metaList.findByRole('term').contains(/Total/i); + metaList.findByRole('definition').contains(/article/i); }); it('should display a search form if unsuccessful', () => { |
