diff --git a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx index c5ee176cc..9337fd6b4 100644 --- a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx +++ b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.test.tsx @@ -361,6 +361,19 @@ describe('Download Status Table', () => { expect(screen.queryByText('test-file-4')).toBeNull(); expect(screen.queryByText('test-file-5')).toBeNull(); + // create an invalid range + await user.type(dateFromFilterInput, '2020-02-28 00:00:00'); + + // should display error + expect(await screen.findAllByText('Invalid date-time range')); + + // Should show all files + expect(await screen.findByText('test-file-1')).toBeInTheDocument(); + expect(await screen.findByText('test-file-2')).toBeInTheDocument(); + expect(await screen.findByText('test-file-3')).toBeInTheDocument(); + expect(await screen.findByText('test-file-4')).toBeInTheDocument(); + expect(await screen.findByText('test-file-5')).toBeInTheDocument(); + cleanupDatePickerWorkaround(); }); diff --git a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx index a603c6bed..68cafe642 100644 --- a/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx +++ b/packages/datagateway-download/src/downloadStatus/downloadStatusTable.component.tsx @@ -191,12 +191,22 @@ const DownloadStatusTable: React.FC = ( const endDateFilter = filter.endDate ? toDate(filter.endDate) : null; if (startDateFilter && endDateFilter) { - satisfiedFilters.push( - isWithinInterval(tableDate, { - start: startDateFilter, - end: endDateFilter, - }) - ); + try { + satisfiedFilters.push( + isWithinInterval(tableDate, { + start: startDateFilter, + end: endDateFilter, + }) + ); + } catch (e) { + if (e instanceof RangeError) { + // isWithinInterval throws with RangeError if startDate > endDate + // in the date filter we tell the user this is invalid, + // so handle it there and do nothing here + } else { + throw e; + } + } continue; }