From 3605c0034c20edb6fccac78f089a373d0455b39a Mon Sep 17 00:00:00 2001 From: Sammy Teillet Date: Thu, 4 May 2023 14:58:43 +0200 Subject: [PATCH] feature: display only 5 results in filter search (#96) * feature: display only 5 results in filter search * feature: Display laoding in a dropdown item * test: use testid insread of text --- .../components/table/table-header/FilterDropdownButton.tsx | 6 +++++- .../__stories__/FilterDropdownButton.stories.tsx | 2 ++ .../table-header/__tests__/FilterDropdownButton.test.tsx | 4 ++-- front/src/services/search/search.ts | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/front/src/components/table/table-header/FilterDropdownButton.tsx b/front/src/components/table/table-header/FilterDropdownButton.tsx index 5fe6480a0..23a0a6808 100644 --- a/front/src/components/table/table-header/FilterDropdownButton.tsx +++ b/front/src/components/table/table-header/FilterDropdownButton.tsx @@ -65,7 +65,11 @@ export function FilterDropdownButton({ selectedFilter: FilterType, ) => { if (filterSearchResults.loading) { - return 'LOADING'; + return ( + + Loading + + ); } return filterSearchResults.results.map((value, index) => ( { it('Calls the filters when typing a new name', async () => { const setFilters = jest.fn(); - const { getByText, getByPlaceholderText, queryByText } = render( + const { getByText, getByPlaceholderText, queryByText, getByTestId } = render( , ); @@ -100,7 +100,7 @@ it('Calls the filters when typing a new name', async () => { fireEvent.change(filterSearch, { target: { value: 'Jane' } }); await waitFor(() => { - const loadingDiv = getByText('LOADING'); + const loadingDiv = getByTestId('loading-search-results'); expect(loadingDiv).toBeDefined(); }); diff --git a/front/src/services/search/search.ts b/front/src/services/search/search.ts index 9353efbb9..bf0f7e18c 100644 --- a/front/src/services/search/search.ts +++ b/front/src/services/search/search.ts @@ -72,6 +72,7 @@ export const useSearch = (): [ { variables: { where, + limit: 5, }, skip: !filter, },