diff --git a/superset-frontend/src/components/Select/AsyncSelect.test.tsx b/superset-frontend/src/components/Select/AsyncSelect.test.tsx index e5569f1be0..b11dcde017 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.test.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.test.tsx @@ -98,6 +98,11 @@ const findSelectOption = (text: string) => within(getElementByClassName('.rc-virtual-list')).getByText(text), ); +const querySelectOption = (text: string) => + waitFor(() => + within(getElementByClassName('.rc-virtual-list')).queryByText(text), + ); + const findAllSelectOptions = () => waitFor(() => getElementsByClassName('.ant-select-item-option-content')); @@ -736,6 +741,21 @@ test('renders a helper text when one is provided', async () => { expect(screen.queryByText(helperText)).toBeInTheDocument(); }); +test('finds an element with a numeric value and does not duplicate the options', async () => { + const options = jest.fn(async () => ({ + data: [ + { label: 'a', value: 11 }, + { label: 'b', value: 12 }, + ], + totalCount: 2, + })); + render(); + await open(); + await type('11'); + expect(await findSelectOption('a')).toBeInTheDocument(); + expect(await querySelectOption('11')).not.toBeInTheDocument(); +}); + /* TODO: Add tests that require scroll interaction. Needs further investigation. - Fetches more data when scrolling and more data is available diff --git a/superset-frontend/src/components/Select/Select.test.tsx b/superset-frontend/src/components/Select/Select.test.tsx index 0ee1f409e4..06f5f7b8e5 100644 --- a/superset-frontend/src/components/Select/Select.test.tsx +++ b/superset-frontend/src/components/Select/Select.test.tsx @@ -77,6 +77,11 @@ const findSelectOption = (text: string) => within(getElementByClassName('.rc-virtual-list')).getByText(text), ); +const querySelectOption = (text: string) => + waitFor(() => + within(getElementByClassName('.rc-virtual-list')).queryByText(text), + ); + const findAllSelectOptions = () => waitFor(() => getElementsByClassName('.ant-select-item-option-content')); @@ -549,6 +554,18 @@ test('renders a helper text when one is provided', async () => { expect(screen.queryByText(helperText)).toBeInTheDocument(); }); +test('finds an element with a numeric value and does not duplicate the options', async () => { + const options = [ + { label: 'a', value: 11 }, + { label: 'b', value: 12 }, + ]; + render(