diff --git a/superset-frontend/src/components/Select/Select.test.tsx b/superset-frontend/src/components/Select/Select.test.tsx index b247950abafb8..37a39204369f6 100644 --- a/superset-frontend/src/components/Select/Select.test.tsx +++ b/superset-frontend/src/components/Select/Select.test.tsx @@ -50,6 +50,10 @@ const OPTIONS = [ { label: 'Cher', value: 22, gender: 'Female' }, { label: 'Her', value: 23, gender: 'Male' }, ].sort((option1, option2) => option1.label.localeCompare(option2.label)); +const NULL_OPTION = { label: '', value: null } as unknown as { + label: string; + value: number; +}; const loadOptions = async (search: string, page: number, pageSize: number) => { const totalCount = OPTIONS.length; @@ -384,6 +388,30 @@ test('does not add a new option if allowNewOptions is false', async () => { expect(await screen.findByText(NO_DATA)).toBeInTheDocument(); }); +test('adds the null option when selected in single mode', async () => { + render(, + ); + await open(); + userEvent.click(await findSelectOption(OPTIONS[0].label)); + userEvent.click(await findSelectOption(NULL_OPTION.label)); + const values = await findAllSelectValues(); + expect(values[0]).toHaveTextContent(OPTIONS[0].label); + expect(values[1]).toHaveTextContent(NULL_OPTION.label); +}); + test('static - renders the select with default props', () => { render(