Skip to content

Commit

Permalink
[Cases] Fix recent cases filter (elastic#104826) (elastic#104846)
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas authored Jul 8, 2021
1 parent 603eb76 commit 672a3dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 17 additions & 0 deletions x-pack/plugins/cases/public/components/recent_cases/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: [] });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const RecentCasesComponent = ({
},
],
}
: {},
: { reporters: [] },
[currentUser, recentCasesFilterBy]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const usePrevious = (value: Partial<FilterOptions>) => {
});
return ref.current;
};

export const RecentCasesComp = ({
caseDetailsNavigation,
createCaseNavigation,
Expand Down

0 comments on commit 672a3dd

Please sign in to comment.