diff --git a/src/files/domain/models/FileCriteria.ts b/src/files/domain/models/FileCriteria.ts index 8de6c9dab..30720deba 100644 --- a/src/files/domain/models/FileCriteria.ts +++ b/src/files/domain/models/FileCriteria.ts @@ -62,6 +62,15 @@ export class FileCriteria { searchText ) } + + get someFilterApplied(): boolean { + return ( + this.filterByType !== undefined || + this.filterByAccess !== undefined || + this.filterByTag !== undefined || + this.searchText !== undefined + ) + } } export enum FileSortByOption { diff --git a/src/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.tsx b/src/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.tsx index 26194bc35..d2cec669e 100644 --- a/src/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.tsx +++ b/src/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.tsx @@ -19,7 +19,8 @@ export function FileCriteriaForm({ filesCountInfo }: FileCriteriaInputsProps) { const showFileCriteriaInputs = - filesCountInfo && filesCountInfo.total >= MINIMUM_FILES_TO_SHOW_CRITERIA_INPUTS + filesCountInfo && + (filesCountInfo.total >= MINIMUM_FILES_TO_SHOW_CRITERIA_INPUTS || criteria.someFilterApplied) return (
diff --git a/tests/component/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.spec.tsx b/tests/component/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.spec.tsx index 8322b7a71..e40d20a84 100644 --- a/tests/component/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.spec.tsx +++ b/tests/component/sections/dataset/dataset-files/file-criteria-form/FileCriteriaForm.spec.tsx @@ -289,4 +289,23 @@ describe('FileCriteriaForm', () => { cy.findByLabelText('Search').should('have.value', 'test') }) + + it('renders the file criteria if there are less than 2 files but there is a filter applied', () => { + const criteria = new FileCriteria() + .withFilterByTag('document') + .withFilterByAccess(FileAccessOption.PUBLIC) + .withFilterByType('image/png') + + cy.customMount( + + ) + + cy.findByRole('button', { name: 'File Type: PNG Image' }).should('exist') + cy.findByRole('button', { name: 'Access: Public' }).should('exist') + cy.findByRole('button', { name: 'File Tags: Document' }).should('exist') + }) }) diff --git a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx index f76ea7c50..46d3f9a3d 100644 --- a/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx +++ b/tests/e2e-integration/e2e/sections/dataset/Dataset.spec.tsx @@ -367,7 +367,7 @@ describe('Dataset', () => { }) }) - it('applies filters to the Files Table in the correct order', () => { + it.only('applies filters to the Files Table in the correct order', () => { const files = [ FileHelper.create('csv', { description: 'Some description', @@ -470,6 +470,25 @@ describe('Dataset', () => { cy.findByText('blob-3').should('not.exist') cy.get('table > tbody > tr').eq(0).should('contain', 'blob-5') cy.get('table > tbody > tr').eq(1).should('contain', 'blob-4') + + cy.findByLabelText('Search').clear().type('blob-5{enter}', { force: true }) + + cy.findByText('1 to 1 of 1 Files').should('exist') + cy.findByText('blob').should('not.exist') + cy.findByText('blob-1').should('not.exist') + cy.findByText('blob-2').should('not.exist') + cy.findByText('blob-3').should('not.exist') + cy.findByText('blob-4').should('not.exist') + cy.findByText('blob-5').should('exist') + + cy.findByLabelText('Search').clear().type('{enter}', { force: true }) + cy.findByText('1 to 3 of 3 Files').should('exist') + cy.findByText('blob').should('exist') + cy.findByText('blob-1').should('not.exist') + cy.findByText('blob-2').should('not.exist') + cy.findByText('blob-3').should('not.exist') + cy.findByText('blob-4').should('exist') + cy.findByText('blob-5').should('exist') }) })