diff --git a/www/front_src/src/Resources/Filter/Criterias/Criteria.tsx b/www/front_src/src/Resources/Filter/Criterias/Criteria.tsx index 72938bd6f72..699698fae0f 100644 --- a/www/front_src/src/Resources/Filter/Criterias/Criteria.tsx +++ b/www/front_src/src/Resources/Filter/Criterias/Criteria.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import { useTranslation } from 'react-i18next'; -import { isNil } from 'ramda'; +import { equals, isNil } from 'ramda'; import { PopoverMultiAutocompleteField, @@ -53,6 +53,9 @@ const CriteriaContent = ({ }; if (isNil(options)) { + const getOptionSelected = (option, selectedValue): boolean => + equals(option.name, selectedValue.name); + const getEndpoint = ({ search, page }): string => buildAutocompleteEndpoint({ limit: 10, @@ -63,9 +66,10 @@ const CriteriaContent = ({ return ( { changeCriteria(updatedValue); diff --git a/www/front_src/src/Resources/Filter/index.test.tsx b/www/front_src/src/Resources/Filter/index.test.tsx index af920c5d1f1..e38554bedb1 100644 --- a/www/front_src/src/Resources/Filter/index.test.tsx +++ b/www/front_src/src/Resources/Filter/index.test.tsx @@ -587,14 +587,24 @@ describe(Filter, () => { result: [], }, }) - .mockResolvedValue({ + .mockResolvedValueOnce({ data: { meta: { limit: 30, page: 1, total: 0, }, - result: [], + result: [linuxServersHostGroup], + }, + }) + .mockResolvedValueOnce({ + data: { + meta: { + limit: 30, + page: 1, + total: 0, + }, + result: [webAccessServiceGroup], }, }); @@ -710,14 +720,24 @@ describe(Filter, () => { result: [], }, }) - .mockResolvedValue({ + .mockResolvedValueOnce({ data: { meta: { limit: 30, page: 1, total: 0, }, - result: [], + result: [linuxServersHostGroup], + }, + }) + .mockResolvedValueOnce({ + data: { + meta: { + limit: 30, + page: 1, + total: 0, + }, + result: [webAccessServiceGroup], }, }); @@ -753,6 +773,9 @@ describe(Filter, () => { expect(getByText(labelOk)).toBeInTheDocument(); fireEvent.click(getByText(labelHostGroup)); + + await waitFor(() => expect(mockedAxios.get).toHaveBeenCalled()); + expect(getByText(linuxServersHostGroup.name)).toBeInTheDocument(); await waitFor(() => { @@ -760,6 +783,9 @@ describe(Filter, () => { }); fireEvent.click(getByText(labelServiceGroup)); + + await waitFor(() => expect(mockedAxios.get).toHaveBeenCalled()); + expect(getByText(webAccessServiceGroup.name)).toBeInTheDocument(); await waitFor(() => {