From ff293e59b93a9bfc27e21be7ad6c9e07f95695de Mon Sep 17 00:00:00 2001 From: rjohanek Date: Tue, 26 Nov 2024 14:01:00 -0500 Subject: [PATCH] pr feedback: simplify anyFiltersSelected and rename response alias in test --- .../DataSearch/dataset_search_table.spec.js | 12 ++++++------ src/components/data_search/DatasetSearchTable.jsx | 11 +++-------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 988b2b1a4..d6aab75c2 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -66,16 +66,16 @@ describe('Dataset Search Table tests', () => { cy.intercept( {method: 'POST', url: '**/search/index'}, (req) => { return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); - }).as('searchIndex1'); + }).as('searchIndex'); mount(); // first clear the default value (100), without clearing first, type('50') would result in input of 10050 cy.get('#participantCountMax-range-input').clear().type('50'); cy.tick(150); // this api call should have had a request that contained the searchText - cy.wait('@searchIndex1').then((response) => { + cy.wait('@searchIndex').then((response) => { expect(response.response.body[0]).to.equal('filtered'); }); - cy.get('@searchIndex1.all').should('have.length', 1); + cy.get('@searchIndex.all').should('have.length', 1); }); @@ -83,14 +83,14 @@ describe('Dataset Search Table tests', () => { cy.intercept({method: 'POST', url: '**/search/index'}, (req) => { // when non-numeric input is entered, the default value (in this case, 100) is used return handler(req, '{"range":{"participantCount":{"gte":100,"lte":null}}}'); - }).as('searchIndex2'); + }).as('searchIndex'); mount(); cy.get('#participantCountMin-range-input').type('test'); cy.tick(150); - cy.wait('@searchIndex2').then((response) => { + cy.wait('@searchIndex').then((response) => { expect(response.response.body[0]).to.equal('filtered'); }); - cy.get('@searchIndex2.all').should('have.length', 1); + cy.get('@searchIndex.all').should('have.length', 1); }); }); diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index 91855db84..d6677887c 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -53,15 +53,10 @@ export const DatasetSearchTable = (props) => { const isFilteredArray = (filter, category) => (filters[category]).indexOf(filter) > -1; - const anyFiltersSelected = (filters) => { - return Object.values(filters).some((filter) => { - if (isArray(filter)) { - return filter.length > 0; - } else { - return filter !== null; - } + const anyFiltersSelected = (filters) => + Object.values(filters).some(filter => { + return isArray(filter) ? filter.length > 0 : filter !== null; }); - }; const getExportableDatasets = async (datasets) => { // Note the dataset identifier is in each sub-table row.