From 2cbedca353e322da65198ab818efc9f8c603b7be Mon Sep 17 00:00:00 2001 From: rjohanek Date: Thu, 21 Nov 2024 09:49:52 -0500 Subject: [PATCH 01/20] add filter for participant count --- .../data_search/DatasetFilterList.jsx | 40 +++++++++++++--- .../data_search/DatasetSearchTable.jsx | 46 +++++++++++++++---- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 82167f443..51704771a 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -6,7 +6,7 @@ import ListItemButton from '@mui/material/ListItemButton'; import ListItemIcon from '@mui/material/ListItemIcon'; import ListItemText from '@mui/material/ListItemText'; import Divider from '@mui/material/Divider'; -import { Button, Typography } from '@mui/material'; +import { Button, TextField, Typography } from '@mui/material'; import { Checkbox } from '@mui/material'; import { flatten, uniq, compact, capitalize, orderBy } from 'lodash'; @@ -20,7 +20,7 @@ export const FilterItemHeader = (props) => { }; export const FilterItemList = (props) => { - const { category, datasets, filter, filterHandler, isFiltered, filterNameFn } = props; + const { category, filter, filterHandler, isFiltered, filterNameFn } = props; return ( { @@ -28,7 +28,7 @@ export const FilterItemList = (props) => { const filterName = filterNameFn(filter); return ( - filterHandler(event, datasets, category, filter)}> + filterHandler(category, filter)}> @@ -42,13 +42,34 @@ export const FilterItemList = (props) => { ); }; +export const FilterItemRange = (props) => { + const { min, max, filterHandler } = props; + return ( + + filterHandler('participantCountMin', event.target.value === '' ? min : event.target.value)}/> + - + filterHandler('participantCountMax', event.target.value === '' ? max : event.target.value)} + /> + + ); +}; + export const DatasetFilterList = (props) => { - const { datasets, filters, filterHandler, isFiltered, onClear } = props; + const { datasets, filterHandler, isFiltered, onClear } = props; const accessManagementFilters = uniq(compact(datasets.map((dataset) => dataset.accessManagement))); const dataUseFilters = uniq(compact(flatten(datasets.map((dataset) => dataset.dataUse?.primary))).map((dataUse) => dataUse.code)); const dataTypeFilters = uniq(flatten(datasets.map((dataset) => dataset.study.dataTypes))); const dacFilters = orderBy(uniq(compact(datasets.map((dataset) => dataset.dac?.dacName))), (dac) => dac.toLowerCase(), 'asc'); + // some participantCounts are undefined, so filter them out before calculating min and max + const participantCountMax = Math.max(...datasets.filter((dataset) => dataset.participantCount).map((dataset) => dataset.participantCount)); + const participantCountMin = Math.min(...datasets.filter((dataset) => dataset.participantCount).map((dataset) => dataset.participantCount)); return ( @@ -90,15 +111,22 @@ export const DatasetFilterList = (props) => { isFiltered={isFiltered} filterNameFn={(filter) => filter} /> - + filter} /> + + ); }; diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index 989e8dfc6..227b34741 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -4,7 +4,7 @@ import useOnMount from '@mui/utils/useOnMount'; import * as React from 'react'; import { Box, Button } from '@mui/material'; import { useEffect, useRef, useState } from 'react'; -import { isEmpty } from 'lodash'; +import { isArray, isEmpty } from 'lodash'; import { TerraDataRepo } from '../../libs/ajax/TerraDataRepo'; import { DatasetSearchTableDisplay } from './DatasetSearchTableDisplay'; import { datasetSearchTableTabs } from './DatasetSearchTableConstants'; @@ -37,7 +37,9 @@ const defaultFilters = { accessManagement: [], dataUse: [], dataType: [], - dac: [] + dac: [], + participantCountMin: null, + participantCountMax: null, }; export const DatasetSearchTable = (props) => { @@ -49,8 +51,21 @@ export const DatasetSearchTable = (props) => { const [selectedTable, setSelectedTable] = useState(datasetSearchTableTabs.study); const [searchTerm, setSearchTerm] = useState(''); - const isFiltered = (filter, category) => (filters[category]).indexOf(filter) > -1; - const numSelectedFilters = (filters) => Object.values(filters).reduce((sum, array) => sum + array.length, 0); + const isFilteredArray = (filter, category) => (filters[category]).indexOf(filter) > -1; + + const numSelectedFilters = (filters) => { + var sum = 0; + for (const category in filters) { + if (isArray(filters[category])) { + sum += filters[category].length; + } else { + if (filters[category]) { + sum += 1; + } + } + } + return sum; + }; const getExportableDatasets = async (datasets) => { // Note the dataset identifier is in each sub-table row. @@ -155,6 +170,15 @@ export const DatasetSearchTable = (props) => { } }); + filterTerms.push({ + 'range': { + 'participantCount': { + 'gte': filters.participantCountMin, + 'lte': filters.participantCountMax, + } + } + }); + if (filterTerms.length > 0) { filterQuery = [ { @@ -179,12 +203,16 @@ export const DatasetSearchTable = (props) => { }; }; - const filterHandler = (event, data, category, filter) => { + const filterHandler = (category, filter) => { var newFilters = _.clone(filters); - if (!isFiltered(filter, category) && filter !== '') { - newFilters[category] = filters[category].concat(filter); + if (isArray(newFilters[category])) { + if (!isFilteredArray(filter, category) && filter !== '') { + newFilters[category] = filters[category].concat(filter); + } else { + newFilters[category] = filters[category].filter((f) => f !== filter); + } } else { - newFilters[category] = filters[category].filter((f) => f !== filter); + newFilters[category] = filter; } setFilters(newFilters); }; @@ -280,7 +308,7 @@ export const DatasetSearchTable = (props) => { - setFilters(defaultFilters)}/> + setFilters(defaultFilters)}/> {(() => { From 45612b935c3ee3c2de0a965baee567ef478ed06d Mon Sep 17 00:00:00 2001 From: rjohanek Date: Thu, 21 Nov 2024 09:59:15 -0500 Subject: [PATCH 02/20] generalize FilterItemRange --- src/components/data_search/DatasetFilterList.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 51704771a..a171117b2 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -43,18 +43,18 @@ export const FilterItemList = (props) => { }; export const FilterItemRange = (props) => { - const { min, max, filterHandler } = props; + const { min, max, minCategory, maxCategory, filterHandler } = props; return ( filterHandler('participantCountMin', event.target.value === '' ? min : event.target.value)}/> + onChange={(event) => filterHandler(minCategory, event.target.value === '' ? min : event.target.value)}/> - filterHandler('participantCountMax', event.target.value === '' ? max : event.target.value)} + onChange={(event) => filterHandler(maxCategory, event.target.value === '' ? max : event.target.value)} /> ); @@ -124,6 +124,8 @@ export const DatasetFilterList = (props) => { From e2d3e06d5ee3b4c3b6176719450d1f6dc7f0c8a4 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 09:55:22 -0500 Subject: [PATCH 03/20] add unit test --- .../DataSearch/dataset_search_filters.spec.js | 32 ++++++++----------- .../DataSearch/dataset_search_table.spec.js | 30 ++++++++++++++++- .../data_search/DatasetFilterList.jsx | 6 ++-- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_filters.spec.js b/cypress/component/DataSearch/dataset_search_filters.spec.js index d19a0f712..d61ceac93 100644 --- a/cypress/component/DataSearch/dataset_search_filters.spec.js +++ b/cypress/component/DataSearch/dataset_search_filters.spec.js @@ -2,26 +2,22 @@ import { mount } from 'cypress/react'; import React from 'react'; -import {Storage} from '../../../src/libs/storage'; import DatasetFilterList from '../../../src/components/data_search/DatasetFilterList'; -const duosUser = { - isSigningOfficial: false, -}; - describe('Data Library Filters', () => { - // Intercept configuration calls - beforeEach(() => { - cy.intercept({ - method: 'GET', - url: '/config.json', - hostname: 'localhost', - }, { 'env': 'ci' }); - }); + // Intercept configuration calls + beforeEach(() => { + cy.initApplicationConfig(); + }); - it('Renders the data library filters', () => { - const props = { datasets: [], filters: [], filterHandler: () => {}, isFiltered: () => {}}; - mount(); - cy.get('div').should('contain', 'Filters'); - }); + it('Renders the data library filters', () => { + const props = { datasets: [], filterHandler: () => {}, isFiltered: () => {}}; + mount(); + cy.get('div').should('contain', 'Filters'); + cy.get('div').should('contain', 'Access Type'); + cy.get('div').should('contain', 'Data Use'); + cy.get('div').should('contain', 'Data Access Committee'); + cy.get('div').should('contain', 'Data Type'); + cy.get('div').should('contain', 'Participant Count'); + }); }); diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 85c1e92c6..ac4f41aea 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -9,7 +9,9 @@ const datasets = [ datasetId: 123456, datasetIdentifier: `DUOS-123456`, datasetName: 'Some Dataset 1', + participantCount: 100, study: { + studyName: 'Some Study 1', studyId: 1, dataCustodianEmail: ['Some Data Custodian Email 1'], } @@ -23,8 +25,9 @@ const props = { describe('Dataset Search Table tests', () => { - describe('Data library with three datasets', () => { + describe('Data library with one dataset footer tests', () => { beforeEach(() => { + cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); mount(); }); @@ -38,6 +41,31 @@ describe('Dataset Search Table tests', () => { cy.get('#header-checkbox').click(); cy.contains('1 dataset selected from 1 study'); }); + }); + + describe('Data library filter by participant count tests', () => { + beforeEach(() => { + cy.initApplicationConfig(); + cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); + }); + + it('When a participant count filter is applied the query is updated', () => { + var filtered = false; + function handler(request) { + if (JSON.stringify(request.body).includes('{"range":{"participantCount":{"gte":null,"lte":"50"}}}')) { + filtered = true; + } + request.reply({statusCode: 200, body:[]}); + } + + cy.intercept( + {method: 'POST', url: '**/api/dataset/search/index'}, handler).as('searchIndex'); + mount(); + cy.get('#participantCountMax-range-input').clear().type('50'); + cy.wait(1000).then(() => { + expect(filtered).to.be.true; + }); + }); }); }); diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 901adc65e..431702fa1 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -48,13 +48,13 @@ export const FilterItemList = (props) => { export const FilterItemRange = (props) => { const { min, max, minCategory, maxCategory, filterHandler } = props; return ( - - + filterHandler(minCategory, event.target.value === '' ? min : event.target.value)}/> - - filterHandler(maxCategory, event.target.value === '' ? max : event.target.value)} From 37606ba025df3c7920c29d9bd0c3089ee9cb1d6a Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 10:47:27 -0500 Subject: [PATCH 04/20] feedback: update calculation of default values --- .../data_search/DatasetFilterList.jsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 431702fa1..69ca7740a 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -8,8 +8,8 @@ import ListItemText from '@mui/material/ListItemText'; import Divider from '@mui/material/Divider'; import { Button, TextField, Typography } from '@mui/material'; import { Checkbox } from '@mui/material'; -import {flatten, uniq, compact, orderBy} from 'lodash'; -import {getAccessManagementSummary} from '../../types/model'; +import { flatten, uniq, compact, orderBy } from 'lodash'; +import { getAccessManagementSummary } from '../../types/model'; export const FilterItemHeader = (props) => { const { title, headerStyle = { fontFamily: 'Montserrat', fontWeight: '600', marginTop: '1em' } } = props; @@ -70,10 +70,11 @@ export const DatasetFilterList = (props) => { const dataUseFilters = uniq(compact(flatten(datasets.map((dataset) => dataset.dataUse?.primary))).map((dataUse) => dataUse.code)); const dataTypeFilters = uniq(flatten(datasets.map((dataset) => dataset.study.dataTypes))); const dacFilters = orderBy(uniq(compact(datasets.map((dataset) => dataset.dac?.dacName))), (dac) => dac.toLowerCase(), 'asc'); - // some participantCounts are undefined, so filter them out before calculating min and max - const participantCountMax = Math.max(...datasets.filter((dataset) => dataset.participantCount).map((dataset) => dataset.participantCount)); - const participantCountMin = Math.min(...datasets.filter((dataset) => dataset.participantCount).map((dataset) => dataset.participantCount)); - + const defaultValues = datasets.reduce((acc, dataset) => { + return { + max: Math.max(acc.max, dataset.participantCount ? dataset.participantCount : 0), + min: Math.min(acc.min, dataset.participantCount ? dataset.participantCount : Infinity) }; + }, {max: 0, min: Infinity}); return ( @@ -133,8 +134,8 @@ export const DatasetFilterList = (props) => { /> Date: Fri, 22 Nov 2024 11:04:13 -0500 Subject: [PATCH 05/20] feedback: update numSelectedFilters -> anyFiltersSelected --- .../data_search/DatasetSearchTable.jsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index 227b34741..ce6cf90e1 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -53,18 +53,14 @@ export const DatasetSearchTable = (props) => { const isFilteredArray = (filter, category) => (filters[category]).indexOf(filter) > -1; - const numSelectedFilters = (filters) => { - var sum = 0; - for (const category in filters) { + const anyFiltersSelected = (filters) => { + return Object.keys(filters).some((category) => { if (isArray(filters[category])) { - sum += filters[category].length; + return filters[category].length > 0; } else { - if (filters[category]) { - sum += 1; - } + return filters[category] !== null; } - } - return sum; + }); }; const getExportableDatasets = async (datasets) => { @@ -123,7 +119,7 @@ export const DatasetSearchTable = (props) => { } let filterQuery = {}; - if (numSelectedFilters(filters) > 0) { + if (anyFiltersSelected(filters)) { const filterTerms = []; filterTerms.push({ From 0f08b2c26c32e6eb67190c5c16448799eea8bc0d Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 11:07:16 -0500 Subject: [PATCH 06/20] simplify anyFiltersSelected --- src/components/data_search/DatasetSearchTable.jsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index ce6cf90e1..c3cc214f8 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -54,11 +54,11 @@ export const DatasetSearchTable = (props) => { const isFilteredArray = (filter, category) => (filters[category]).indexOf(filter) > -1; const anyFiltersSelected = (filters) => { - return Object.keys(filters).some((category) => { - if (isArray(filters[category])) { - return filters[category].length > 0; + return Object.values(filters).some((filter) => { + if (isArray(filter)) { + return filter.length > 0; } else { - return filters[category] !== null; + return filter !== null; } }); }; From 8dd3cc461a564eb5d9f99e72724e8592fc9fb432 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 11:25:48 -0500 Subject: [PATCH 07/20] Feedback: update filterHandler --- src/components/data_search/DatasetSearchTable.jsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index c3cc214f8..65b7c90b8 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -200,16 +200,18 @@ export const DatasetSearchTable = (props) => { }; const filterHandler = (category, filter) => { - var newFilters = _.clone(filters); - if (isArray(newFilters[category])) { + let newFilter; + if (isArray(filters[category])) { if (!isFilteredArray(filter, category) && filter !== '') { - newFilters[category] = filters[category].concat(filter); + newFilter = filters[category].concat(filter); } else { - newFilters[category] = filters[category].filter((f) => f !== filter); + newFilter = filters[category].filter((f) => f !== filter); } } else { - newFilters[category] = filter; + newFilter = filter; } + const newFilters = _.clone(filters); + newFilters[category] = newFilter; setFilters(newFilters); }; From d03c0bf4717cef8070da249ebca65b94afd517a4 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 11:42:47 -0500 Subject: [PATCH 08/20] Feedback: add validation --- .../DataSearch/dataset_search_table.spec.js | 32 ++++++++++++++----- .../data_search/DatasetFilterList.jsx | 4 +-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index ac4f41aea..c6cf7b5a5 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -44,22 +44,27 @@ describe('Dataset Search Table tests', () => { }); describe('Data library filter by participant count tests', () => { + let searchText; + let filtered; + beforeEach(() => { cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); + filtered = false; }); - it('When a participant count filter is applied the query is updated', () => { - var filtered = false; - function handler(request) { - if (JSON.stringify(request.body).includes('{"range":{"participantCount":{"gte":null,"lte":"50"}}}')) { - filtered = true; - } - request.reply({statusCode: 200, body:[]}); + function handler(request) { + if (JSON.stringify(request.body).includes(searchText)) { + filtered = true; } + request.reply({statusCode: 200, body:[]}); + } + + it('When a participant count filter is applied the query is updated', () => { + searchText ='{"range":{"participantCount":{"gte":null,"lte":"50"}}}'; cy.intercept( - {method: 'POST', url: '**/api/dataset/search/index'}, handler).as('searchIndex'); + {method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMax-range-input').clear().type('50'); cy.wait(1000).then(() => { @@ -67,5 +72,16 @@ describe('Dataset Search Table tests', () => { }); }); + it('When an invalid participant count filter is applied the query represents the default value', () => { + searchText = '{"range":{"participantCount":{"gte":100,"lte":null}}}'; + + cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, handler); + mount(); + cy.get('#participantCountMin-range-input').clear().type('test'); + cy.wait(1000).then(() => { + expect(filtered).to.be.true; + }); + }); + }); }); diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 69ca7740a..64862e2c3 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -52,12 +52,12 @@ export const FilterItemRange = (props) => { filterHandler(minCategory, event.target.value === '' ? min : event.target.value)}/> + onChange={(event) => filterHandler(minCategory, isNaN(parseInt(event.target.value)) ? min : event.target.value)}/> - filterHandler(maxCategory, event.target.value === '' ? max : event.target.value)} + onChange={(event) => filterHandler(maxCategory, isNaN(parseInt(event.target.value)) ? max : event.target.value)} /> ); From d0556f87a2b9ee0d347a51cc8896ca6630cfce6d Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 14:59:11 -0500 Subject: [PATCH 09/20] try to fix test --- cypress/component/DataSearch/dataset_search_table.spec.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index c6cf7b5a5..9687ea18e 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -3,6 +3,7 @@ import {React} from 'react'; import {mount} from 'cypress/react'; import DatasetSearchTable from '../../../src/components/data_search/DatasetSearchTable'; import {TerraDataRepo} from '../../../src/libs/ajax/TerraDataRepo'; +import {DataSet} from '../../../src/libs/ajax/DataSet'; const datasets = [ { @@ -29,6 +30,7 @@ describe('Dataset Search Table tests', () => { beforeEach(() => { cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); + cy.stub(DataSet, 'searchDatasetIndex').returns({}); mount(); }); @@ -67,18 +69,18 @@ describe('Dataset Search Table tests', () => { {method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMax-range-input').clear().type('50'); - cy.wait(1000).then(() => { + cy.wait(1500).then(() => { expect(filtered).to.be.true; }); }); - it('When an invalid participant count filter is applied the query represents the default value', () => { + it('When an invalid participant count filter is applied the query represents the default value', () => { searchText = '{"range":{"participantCount":{"gte":100,"lte":null}}}'; cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMin-range-input').clear().type('test'); - cy.wait(1000).then(() => { + cy.wait(1500).then(() => { expect(filtered).to.be.true; }); }); From c033344b34c71fb613a483fc58c8ca90ba327eac Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 15:22:03 -0500 Subject: [PATCH 10/20] try to fix test --- cypress/component/DataSearch/dataset_search_table.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 9687ea18e..925ab43b4 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -30,7 +30,7 @@ describe('Dataset Search Table tests', () => { beforeEach(() => { cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); - cy.stub(DataSet, 'searchDatasetIndex').returns({}); + cy.stub(DataSet, 'searchDatasetIndex').returns(Promise.resolve([])); mount(); }); From 4cc1ac8738cd66ca9fa3c1b1b05e0e77bd4fcb24 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 15:31:01 -0500 Subject: [PATCH 11/20] try to fix test --- cypress/component/DataSearch/dataset_search_table.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 925ab43b4..b78f8fabb 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -69,7 +69,7 @@ describe('Dataset Search Table tests', () => { {method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMax-range-input').clear().type('50'); - cy.wait(1500).then(() => { + cy.wait(2500).then(() => { expect(filtered).to.be.true; }); }); @@ -80,7 +80,7 @@ describe('Dataset Search Table tests', () => { cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMin-range-input').clear().type('test'); - cy.wait(1500).then(() => { + cy.wait(2500).then(() => { expect(filtered).to.be.true; }); }); From 44e9f1ce00587e970cc7eb6abd675e0ad1abdbb7 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Fri, 22 Nov 2024 16:00:12 -0500 Subject: [PATCH 12/20] try to fix test --- cypress/component/DataSearch/dataset_search_table.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index b78f8fabb..5e098c3c4 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -69,7 +69,7 @@ describe('Dataset Search Table tests', () => { {method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMax-range-input').clear().type('50'); - cy.wait(2500).then(() => { + cy.wait(3000).then(() => { expect(filtered).to.be.true; }); }); @@ -80,7 +80,7 @@ describe('Dataset Search Table tests', () => { cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, handler); mount(); cy.get('#participantCountMin-range-input').clear().type('test'); - cy.wait(2500).then(() => { + cy.wait(3000).then(() => { expect(filtered).to.be.true; }); }); From 2417d78ce3892f2fce1356abc950ee23eb3cb095 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 12:26:46 -0500 Subject: [PATCH 13/20] fix tests? --- .../DataSearch/dataset_search_table.spec.js | 37 +++++++++++-------- .../data_search/DatasetFilterList.jsx | 5 ++- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 5e098c3c4..0af56e69c 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -46,42 +46,47 @@ describe('Dataset Search Table tests', () => { }); describe('Data library filter by participant count tests', () => { - let searchText; - let filtered; beforeEach(() => { cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); - filtered = false; }); - function handler(request) { + function handler(request, searchText) { if (JSON.stringify(request.body).includes(searchText)) { - filtered = true; + request.reply(['filtered']); + } else { + request.reply([]); } - request.reply({statusCode: 200, body:[]}); } - it('When a participant count filter is applied the query is updated', () => { - searchText ='{"range":{"participantCount":{"gte":null,"lte":"50"}}}'; + it('When a participant count filter is applied the query is updated', () => { cy.intercept( - {method: 'POST', url: '**/api/dataset/search/index'}, handler); + {method: 'POST', url: '**/api/dataset/search/index'}, (req) => { + return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); + }).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.wait(3000).then(() => { - expect(filtered).to.be.true; + // ignore first call, caused by .clear() + cy.wait('@searchIndex'); + // this api call, caused by .type('50'), should have had a request that contained the searchText + cy.wait('@searchIndex').then((response) => { + expect(response.response.body[0]).to.equal('filtered'); }); }); it('When an invalid participant count filter is applied the query represents the default value', () => { - searchText = '{"range":{"participantCount":{"gte":100,"lte":null}}}'; - cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, handler); + cy.intercept({method: 'POST', url: '**/api/dataset/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('searchIndex'); mount(); - cy.get('#participantCountMin-range-input').clear().type('test'); - cy.wait(3000).then(() => { - expect(filtered).to.be.true; + cy.get('#participantCountMin-range-input').type('test'); + cy.wait('@searchIndex').then((response) => { + expect(response.response.body[0]).to.equal('filtered'); }); }); diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 64862e2c3..97778c0f3 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -47,17 +47,18 @@ export const FilterItemList = (props) => { export const FilterItemRange = (props) => { const { min, max, minCategory, maxCategory, filterHandler } = props; + const getValue = (val, defaultVal) => isNaN(Number(val)) ? defaultVal : Number(val); return ( filterHandler(minCategory, isNaN(parseInt(event.target.value)) ? min : event.target.value)}/> + onChange={(event) => filterHandler(minCategory, getValue(event.target.value, min))}/> - filterHandler(maxCategory, isNaN(parseInt(event.target.value)) ? max : event.target.value)} + onChange={(event) => filterHandler(maxCategory, getValue(event.target.value, max))} /> ); From af1a5018b092731a599491090ba0753fe16ec17d Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 12:52:07 -0500 Subject: [PATCH 14/20] fails locally, but just curious if it will pass on the server --- cypress/component/DataSearch/dataset_search_table.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 0af56e69c..85b9e0742 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -64,13 +64,12 @@ describe('Dataset Search Table tests', () => { it('When a participant count filter is applied the query is updated', () => { cy.intercept( {method: 'POST', url: '**/api/dataset/search/index'}, (req) => { - return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); + // without clearing the default input, type('50') results in input of 10050 + return handler(req, '{"range":{"participantCount":{"gte":null,"lte":10050}}}'); }).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.get('#participantCountMax-range-input').type('50'); // ignore first call, caused by .clear() - cy.wait('@searchIndex'); // this api call, caused by .type('50'), should have had a request that contained the searchText cy.wait('@searchIndex').then((response) => { expect(response.response.body[0]).to.equal('filtered'); From 24ca3b18a9542ae3fc5a4497bbed4c49e424ee59 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 13:39:41 -0500 Subject: [PATCH 15/20] revert last change --- cypress/component/DataSearch/dataset_search_table.spec.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 85b9e0742..0af56e69c 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -64,12 +64,13 @@ describe('Dataset Search Table tests', () => { it('When a participant count filter is applied the query is updated', () => { cy.intercept( {method: 'POST', url: '**/api/dataset/search/index'}, (req) => { - // without clearing the default input, type('50') results in input of 10050 - return handler(req, '{"range":{"participantCount":{"gte":null,"lte":10050}}}'); + return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); }).as('searchIndex'); mount(); - cy.get('#participantCountMax-range-input').type('50'); + // 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'); // ignore first call, caused by .clear() + cy.wait('@searchIndex'); // this api call, caused by .type('50'), should have had a request that contained the searchText cy.wait('@searchIndex').then((response) => { expect(response.response.body[0]).to.equal('filtered'); From c4ed6ee2e136cdd05bcb6e2f3ac2fe3bf944e3e3 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 14:34:11 -0500 Subject: [PATCH 16/20] reduce URLs and rename parameter --- .../DataSearch/dataset_search_table.spec.js | 4 ++-- src/components/data_search/DatasetFilterList.jsx | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 0af56e69c..560901e05 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -63,7 +63,7 @@ describe('Dataset Search Table tests', () => { it('When a participant count filter is applied the query is updated', () => { cy.intercept( - {method: 'POST', url: '**/api/dataset/search/index'}, (req) => { + {method: 'POST', url: '**/search/index'}, (req) => { return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); }).as('searchIndex'); mount(); @@ -79,7 +79,7 @@ describe('Dataset Search Table tests', () => { it('When an invalid participant count filter is applied the query represents the default value', () => { - cy.intercept({method: 'POST', url: '**/api/dataset/search/index'}, (req) => { + 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('searchIndex'); diff --git a/src/components/data_search/DatasetFilterList.jsx b/src/components/data_search/DatasetFilterList.jsx index 97778c0f3..c8ff3d562 100644 --- a/src/components/data_search/DatasetFilterList.jsx +++ b/src/components/data_search/DatasetFilterList.jsx @@ -25,16 +25,16 @@ export const FilterItemList = (props) => { return ( { - filter.map((filter) => { - const filterName = filterNameFn(filter); + filter.map((filterOption) => { + const filterName = filterNameFn(filterOption); return ( - - filterHandler(category, filter)}> + + filterHandler(category, filterOption)}> - + - {filterDisplayFn ? filterDisplayFn(filter) : filterName} + {filterDisplayFn ? filterDisplayFn(filterOption) : filterName} From 2d3b3ab9d33aa9888770c66437b2c6d977fc79d2 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 15:34:03 -0500 Subject: [PATCH 17/20] remove debounce just to see --- .../data_search/DatasetSearchTable.jsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index 65b7c90b8..a564c664a 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -3,7 +3,7 @@ import Tabs from '@mui/material/Tabs'; import useOnMount from '@mui/utils/useOnMount'; import * as React from 'react'; import { Box, Button } from '@mui/material'; -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useState } from 'react'; import { isArray, isEmpty } from 'lodash'; import { TerraDataRepo } from '../../libs/ajax/TerraDataRepo'; import { DatasetSearchTableDisplay } from './DatasetSearchTableDisplay'; @@ -237,18 +237,21 @@ export const DatasetSearchTable = (props) => { getExportableDatasets(datasets); }); - const searchAndFilter = useRef( - _.debounce((fullQuery) => { - DataSet.searchDatasetIndex(fullQuery).then((filteredDatasets) => { - const newFiltered = datasets.filter(value => filteredDatasets.some(item => _.isEqual(item, value))); - setFiltered(newFiltered); - }); - }, 150)); + // const searchAndFilter = useRef( + // _.debounce((fullQuery) => { + // DataSet.searchDatasetIndex(fullQuery).then((filteredDatasets) => { + // const newFiltered = datasets.filter(value => filteredDatasets.some(item => _.isEqual(item, value))); + // setFiltered(newFiltered); + // }); + // }, 150)); useEffect(() => { const fullQuery = assembleFullQuery(); try { - searchAndFilter.current(fullQuery); + DataSet.searchDatasetIndex(fullQuery).then((filteredDatasets) => { + const newFiltered = datasets.filter(value => filteredDatasets.some(item => _.isEqual(item, value))); + setFiltered(newFiltered); + }); } catch (error) { Notifications.showError({ text: 'Failed to load Elasticsearch index' }); } }, [filters, searchTerm]); // eslint-disable-line From 851879e773f7991f8d9752b9944817f102472c21 Mon Sep 17 00:00:00 2001 From: rjohanek Date: Mon, 25 Nov 2024 16:48:54 -0500 Subject: [PATCH 18/20] add cy.clock and revert remove debounce --- .../DataSearch/dataset_search_table.spec.js | 18 ++++++++++------ .../data_search/DatasetSearchTable.jsx | 21 ++++++++----------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 560901e05..0376b21a3 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -48,6 +48,7 @@ describe('Dataset Search Table tests', () => { describe('Data library filter by participant count tests', () => { beforeEach(() => { + cy.clock(); cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); }); @@ -65,16 +66,19 @@ describe('Dataset Search Table tests', () => { cy.intercept( {method: 'POST', url: '**/search/index'}, (req) => { return handler(req, '{"range":{"participantCount":{"gte":null,"lte":50}}}'); - }).as('searchIndex'); + }).as('searchIndex1'); 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'); - // ignore first call, caused by .clear() - cy.wait('@searchIndex'); + cy.tick(150); + // ignore first call (why are there two? even without clear()) + cy.wait('@searchIndex1'); // this api call, caused by .type('50'), should have had a request that contained the searchText - cy.wait('@searchIndex').then((response) => { + cy.wait('@searchIndex1').then((response) => { expect(response.response.body[0]).to.equal('filtered'); }); + // should be 1? + cy.get('@searchIndex1.all').should('have.length', 2); }); it('When an invalid participant count filter is applied the query represents the default value', () => { @@ -82,12 +86,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('searchIndex'); + }).as('searchIndex2'); mount(); cy.get('#participantCountMin-range-input').type('test'); - cy.wait('@searchIndex').then((response) => { + cy.tick(150); + cy.wait('@searchIndex2').then((response) => { expect(response.response.body[0]).to.equal('filtered'); }); + cy.get('@searchIndex2.all').should('have.length', 1); }); }); diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index a564c664a..91855db84 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -3,7 +3,7 @@ import Tabs from '@mui/material/Tabs'; import useOnMount from '@mui/utils/useOnMount'; import * as React from 'react'; import { Box, Button } from '@mui/material'; -import { useEffect, useState } from 'react'; +import {useEffect, useRef, useState} from 'react'; import { isArray, isEmpty } from 'lodash'; import { TerraDataRepo } from '../../libs/ajax/TerraDataRepo'; import { DatasetSearchTableDisplay } from './DatasetSearchTableDisplay'; @@ -237,21 +237,18 @@ export const DatasetSearchTable = (props) => { getExportableDatasets(datasets); }); - // const searchAndFilter = useRef( - // _.debounce((fullQuery) => { - // DataSet.searchDatasetIndex(fullQuery).then((filteredDatasets) => { - // const newFiltered = datasets.filter(value => filteredDatasets.some(item => _.isEqual(item, value))); - // setFiltered(newFiltered); - // }); - // }, 150)); - - useEffect(() => { - const fullQuery = assembleFullQuery(); - try { + const searchAndFilter = useRef( + _.debounce((fullQuery) => { DataSet.searchDatasetIndex(fullQuery).then((filteredDatasets) => { const newFiltered = datasets.filter(value => filteredDatasets.some(item => _.isEqual(item, value))); setFiltered(newFiltered); }); + }, 150)); + + useEffect(() => { + const fullQuery = assembleFullQuery(); + try { + searchAndFilter.current(fullQuery); } catch (error) { Notifications.showError({ text: 'Failed to load Elasticsearch index' }); } }, [filters, searchTerm]); // eslint-disable-line From 455abe32d09d688859be46a613982c2ea6a4780b Mon Sep 17 00:00:00 2001 From: rjohanek Date: Tue, 26 Nov 2024 12:15:26 -0500 Subject: [PATCH 19/20] add cy.clock to existing tests!! --- .../DataSearch/dataset_search_table.spec.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cypress/component/DataSearch/dataset_search_table.spec.js b/cypress/component/DataSearch/dataset_search_table.spec.js index 0376b21a3..988b2b1a4 100644 --- a/cypress/component/DataSearch/dataset_search_table.spec.js +++ b/cypress/component/DataSearch/dataset_search_table.spec.js @@ -3,7 +3,6 @@ import {React} from 'react'; import {mount} from 'cypress/react'; import DatasetSearchTable from '../../../src/components/data_search/DatasetSearchTable'; import {TerraDataRepo} from '../../../src/libs/ajax/TerraDataRepo'; -import {DataSet} from '../../../src/libs/ajax/DataSet'; const datasets = [ { @@ -30,7 +29,7 @@ describe('Dataset Search Table tests', () => { beforeEach(() => { cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); - cy.stub(DataSet, 'searchDatasetIndex').returns(Promise.resolve([])); + cy.clock(); mount(); }); @@ -45,12 +44,13 @@ describe('Dataset Search Table tests', () => { }); }); + describe('Data library filter by participant count tests', () => { beforeEach(() => { - cy.clock(); cy.initApplicationConfig(); cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); + cy.clock(); }); function handler(request, searchText) { @@ -71,18 +71,15 @@ describe('Dataset Search Table tests', () => { // 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); - // ignore first call (why are there two? even without clear()) - cy.wait('@searchIndex1'); - // this api call, caused by .type('50'), should have had a request that contained the searchText + // this api call should have had a request that contained the searchText cy.wait('@searchIndex1').then((response) => { expect(response.response.body[0]).to.equal('filtered'); }); - // should be 1? - cy.get('@searchIndex1.all').should('have.length', 2); + cy.get('@searchIndex1.all').should('have.length', 1); + }); it('When an invalid participant count filter is applied the query represents the default value', () => { - 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}}}'); From ff293e59b93a9bfc27e21be7ad6c9e07f95695de Mon Sep 17 00:00:00 2001 From: rjohanek Date: Tue, 26 Nov 2024 14:01:00 -0500 Subject: [PATCH 20/20] 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.