diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-09-26 15:54:28 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-10-24 12:23:48 +0200 |
| commit | 70efcfeaa0603415dd992cb662d8efb960e6e49a (patch) | |
| tree | 5d37e98fae9aa7e5c3d8ef30a10db9fed9b63e36 /tests/cypress/e2e/search.cy.ts | |
| parent | 31695306bfed44409f03006ea717fd2cceff8f87 (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/search.cy.ts')
| -rw-r--r-- | tests/cypress/e2e/search.cy.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/tests/cypress/e2e/search.cy.ts b/tests/cypress/e2e/search.cy.ts index f105a5c..5f2081d 100644 --- a/tests/cypress/e2e/search.cy.ts +++ b/tests/cypress/e2e/search.cy.ts @@ -1,7 +1,10 @@ +import { ROUTES } from '../../../src/utils/constants'; + 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'); @@ -15,27 +18,28 @@ describe('Search', () => { 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', async () => { + it('should navigate the search page', () => { cy.visit('/'); cy.findByLabelText(/Ouvrir la recherche/i).click(); cy.findByRole('searchbox', { name: /Rechercher/i }).type( `${queryWithArticles}{enter}` ); - cy.url().should('include', '/blog'); + cy.url().should('include', ROUTES.SEARCH); cy.findByRole('heading', { level: 1 }).contains( /Résultats de la recherche pour/i ); }); - it('should display the total of articles if successful', async () => { - cy.visit(`/recherche?s=${encodeURIComponent(queryWithArticles)}`); + 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); }); it('should display a search form if unsuccessful', () => { - cy.visit(`/recherche?s=${encodeURIComponent(queryWithoutArticles)}`); + cy.visit(`${ROUTES.SEARCH}?s=${encodeURIComponent(queryWithoutArticles)}`); cy.findByRole('searchbox', { name: /Rechercher/i }).should('exist'); }); }); |
