From a41709f43dbf4964e76c2f912ae6cfb79c447b0c Mon Sep 17 00:00:00 2001 From: Basile Spaenlehauer Date: Mon, 6 May 2024 16:15:34 +0200 Subject: [PATCH] fix: set default for in-depth search to false (#610) * fix: set default for in-depth search to false * fix: tests * fix: last test --- cypress/e2e/allCollections/allCollections.cy.ts | 14 +++++++------- cypress/e2e/home/search.cy.ts | 3 ++- src/components/pages/AllCollections.tsx | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cypress/e2e/allCollections/allCollections.cy.ts b/cypress/e2e/allCollections/allCollections.cy.ts index e155989c..6c897f34 100644 --- a/cypress/e2e/allCollections/allCollections.cy.ts +++ b/cypress/e2e/allCollections/allCollections.cy.ts @@ -57,19 +57,19 @@ buildPublicAndPrivateEnvironments(PUBLISHED_ITEMS).forEach((environment) => { // 'License', // ); - // verify 6 item cards are displayed (including children) + // verify 2 item cards are displayed (without children) cy.get(`#${ALL_COLLECTIONS_GRID_ID}`); cy.get(`[id^=${buildCollectionCardGridId('')}]`).should( 'have.length', - environment.items.length, + getRootPublishedItems(environment.items).length, ); - // verify 2 item cards are displayed (without children) - cy.get(`#${ENABLE_IN_DEPTH_SEARCH_CHECKBOX_ID}`).uncheck(); + // verify 6 item cards are displayed (including children) + cy.get(`#${ENABLE_IN_DEPTH_SEARCH_CHECKBOX_ID}`).check(); cy.get(`#${ALL_COLLECTIONS_GRID_ID}`); cy.get(`[id^=${buildCollectionCardGridId('')}]`).should( 'have.length', - getRootPublishedItems(environment.items).length, + environment.items.length, ); }); @@ -121,7 +121,7 @@ buildPublicAndPrivateEnvironments(PUBLISHED_ITEMS).forEach((environment) => { cy.wait('@search').then(() => { cy.get(`#${ALL_COLLECTIONS_GRID_ID}`) .children() - .should('have.length', PUBLISHED_ITEMS.length); + .should('have.length', getRootPublishedItems(PUBLISHED_ITEMS).length); }); // bug: popup does not open in cypress @@ -131,7 +131,7 @@ buildPublicAndPrivateEnvironments(PUBLISHED_ITEMS).forEach((environment) => { // check default display, show all published with children cy.get(`#${ALL_COLLECTIONS_GRID_ID}`) .children() - .should('have.length', PUBLISHED_ITEMS.length); + .should('have.length', getRootPublishedItems(PUBLISHED_ITEMS).length); }); }); }); diff --git a/cypress/e2e/home/search.cy.ts b/cypress/e2e/home/search.cy.ts index 56d329f0..dd3e8837 100644 --- a/cypress/e2e/home/search.cy.ts +++ b/cypress/e2e/home/search.cy.ts @@ -9,6 +9,7 @@ import { } from '../../../src/config/selectors'; import { buildPublicAndPrivateEnvironments } from '../../fixtures/environment'; import { PUBLISHED_ITEMS } from '../../fixtures/items'; +import { getRootPublishedItems } from '../../support/utils'; // the text doesn't affect the result: results are set in setUpApi const keywords = 'keywords'; @@ -47,7 +48,7 @@ describe('Search', () => { // verify all items are displayed // eslint-disable-next-line no-restricted-syntax - for (const item of PUBLISHED_ITEMS) { + for (const item of getRootPublishedItems(PUBLISHED_ITEMS)) { cy.get(`#${ALL_COLLECTIONS_GRID_ID}`).contains(item.name); } diff --git a/src/components/pages/AllCollections.tsx b/src/components/pages/AllCollections.tsx index fb6536e9..dda8cd2e 100644 --- a/src/components/pages/AllCollections.tsx +++ b/src/components/pages/AllCollections.tsx @@ -41,7 +41,7 @@ const AllCollections: React.FC = () => { const [filters, setFilters] = useState([]); const [shouldIncludeContent, setShouldIncludeContent] = - useState(true); + useState(false); const [searchKeywords, setSearchKeywords] = useState(''); const [prevResults, setPrevResults] = useState([]); const [page, setPage] = useState(1);