[Cases] Fix recent cases filter (#104826)
This commit is contained in:
parent
3a173656ab
commit
98750a30cc
|
@ -39,6 +39,7 @@ export const RecentCasesFilters = React.memo<{
|
|||
: toggleButtonIcons.filter((x) => x.id !== MY_RECENTLY_REPORTED_ID),
|
||||
[showMyRecentlyReported]
|
||||
);
|
||||
|
||||
const onChange = useCallback(
|
||||
(filterMode: string) => {
|
||||
setFilterBy(filterMode as FilterMode);
|
||||
|
|
|
@ -101,4 +101,21 @@ describe('RecentCases', () => {
|
|||
userEvent.click(element);
|
||||
expect(setFilters).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('it resets the reporters when changing from my recently reported cases to recent cases', () => {
|
||||
const { getByTestId } = render(
|
||||
<TestProviders>
|
||||
<RecentCases {...defaultProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
const myRecentCasesElement = getByTestId('myRecentlyReported');
|
||||
const recentCasesElement = getByTestId('recentlyCreated');
|
||||
userEvent.click(myRecentCasesElement);
|
||||
userEvent.click(recentCasesElement);
|
||||
|
||||
const mockCalls = setFilters.mock.calls;
|
||||
expect(mockCalls[0][0].reporters.length).toBeGreaterThan(0);
|
||||
expect(mockCalls[1][0]).toEqual({ reporters: [] });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ const RecentCasesComponent = ({
|
|||
},
|
||||
],
|
||||
}
|
||||
: {},
|
||||
: { reporters: [] },
|
||||
[currentUser, recentCasesFilterBy]
|
||||
);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ const usePrevious = (value: Partial<FilterOptions>) => {
|
|||
});
|
||||
return ref.current;
|
||||
};
|
||||
|
||||
export const RecentCasesComp = ({
|
||||
caseDetailsNavigation,
|
||||
createCaseNavigation,
|
||||
|
|
Loading…
Reference in a new issue