From 3859f0d58193c39b77e28e5e3203155d3702d07a Mon Sep 17 00:00:00 2001 From: Jason Lin Date: Mon, 6 Nov 2023 11:52:35 -0500 Subject: [PATCH] Tests caught an oopsie! --- .../FilterDateRange/FilterDateRange.tsx | 12 ++++++++---- .../RateReviewsDashboard/RateReviewsTable.test.tsx | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/services/app-web/src/components/FilterAccordion/FilterDateRange/FilterDateRange.tsx b/services/app-web/src/components/FilterAccordion/FilterDateRange/FilterDateRange.tsx index ce6b08a40f..cd9a075d6c 100644 --- a/services/app-web/src/components/FilterAccordion/FilterDateRange/FilterDateRange.tsx +++ b/services/app-web/src/components/FilterAccordion/FilterDateRange/FilterDateRange.tsx @@ -191,14 +191,18 @@ export const FilterDateRange = forwardRef( const onStartDateChangeValidation = (date?: string) => { if (date && validateDate(date)) { setShowStartDateError(false) - startDatePickerOnChange(formatUserInputDate(date)) + startDatePickerOnChange(formatUserInputDate(date.trimEnd())) + } else if (!date) { + startDatePickerOnChange(date) } } const onEndDateChangeValidation = (date?: string) => { if (date && validateDate(date)) { setShowEndDateError(false) - endDatePickerOnChange(formatUserInputDate(date)) + endDatePickerOnChange(formatUserInputDate(date.trimEnd())) + } else if (!date) { + endDatePickerOnChange(date) } } @@ -206,7 +210,7 @@ export const FilterDateRange = forwardRef( const e = event as React.FocusEvent const date = e.target.value if (date.length > 0) { - setShowStartDateError(!validateDate(date)) + setShowStartDateError(!validateDate(date.trimEnd())) } } @@ -214,7 +218,7 @@ export const FilterDateRange = forwardRef( const e = event as React.FocusEvent const date = e.target.value if (date.length > 0) { - setShowEndDateError(!validateDate(date)) + setShowEndDateError(!validateDate(date.trimEnd())) } } diff --git a/services/app-web/src/pages/CMSDashboard/RateReviewsDashboard/RateReviewsTable.test.tsx b/services/app-web/src/pages/CMSDashboard/RateReviewsDashboard/RateReviewsTable.test.tsx index 0fb4bb73d8..d5087f41a0 100644 --- a/services/app-web/src/pages/CMSDashboard/RateReviewsDashboard/RateReviewsTable.test.tsx +++ b/services/app-web/src/pages/CMSDashboard/RateReviewsDashboard/RateReviewsTable.test.tsx @@ -225,7 +225,9 @@ describe('RateReviewsTable', () => { await userEvent.click(accordionButton) }) - const ratingPeriodFilter = screen.getByTestId('date-range-picker') + const ratingPeriodFilter = screen.getByTestId( + 'filter-date-range-picker' + ) const dateRangePickerInputs = within( ratingPeriodFilter ).queryAllByTestId('date-picker-external-input')