aboutsummaryrefslogtreecommitdiffstats
path: root/tests/cypress
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-12-04 19:36:34 +0100
committerArmand Philippot <git@armandphilippot.com>2023-12-07 19:11:59 +0100
commite9d5a40432c451090e17859c764e52a96120b712 (patch)
treeff1723110920385e3888d327231c61b781921868 /tests/cypress
parent53b63ac27c2275262db9a04be02210a3287aa71d (diff)
refactor(pages): refine Search page
* extract NoResults component to improve readability * provide a different message when the url does not contain a query * use hooks to refresh Thematics and Topics lists * remove useDataFromApi hook
Diffstat (limited to 'tests/cypress')
-rw-r--r--tests/cypress/e2e/pages/search.cy.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/cypress/e2e/pages/search.cy.ts b/tests/cypress/e2e/pages/search.cy.ts
new file mode 100644
index 0000000..bde592e
--- /dev/null
+++ b/tests/cypress/e2e/pages/search.cy.ts
@@ -0,0 +1,28 @@
+import { ROUTES } from '../../../../src/utils/constants';
+
+describe('Search Page', () => {
+ beforeEach(() => {
+ cy.visit(ROUTES.SEARCH);
+ });
+
+ it('successfully loads', () => {
+ cy.findByRole('heading', { level: 1 }).should('exist');
+ });
+
+ it('contains a breadcrumbs', () => {
+ cy.findByRole('navigation', { name: 'Fil d’Ariane' }).should('exist');
+ });
+
+ it('contains a thematics list widget and a topics list widget', () => {
+ cy.findByRole('heading', { level: 2, name: 'Thématiques' }).should('exist');
+ cy.findByRole('heading', { level: 2, name: 'Sujets' }).should('exist');
+ });
+
+ it('provides a form to search for keywords', () => {
+ const keywords = 'coldark';
+
+ cy.findByRole('searchbox').type(keywords);
+ cy.findByRole('button', { name: /Rechercher/ }).click();
+ cy.findByRole('heading', { level: 1 }).should('contain.text', keywords);
+ });
+});