diff --git a/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.test.tsx b/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.test.tsx
index 94af52f374..0516267041 100644
--- a/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.test.tsx
+++ b/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.test.tsx
@@ -88,6 +88,56 @@ describe('', () => {
});
});
+ it('hides filter if there are no available options', async () => {
+ const mockCatalogApiNoOptions: Partial> = {
+ getEntityFacets: jest.fn().mockResolvedValue({
+ facets: {
+ 'spec.options': [],
+ },
+ }),
+ };
+ render(
+
+
+
+ label="Options"
+ path="spec.options"
+ name="options"
+ Filter={EntityOptionFilter}
+ />
+
+ ,
+ );
+ await waitFor(() => {
+ expect(screen.queryByText('Options')).not.toBeInTheDocument();
+ });
+ });
+
+ it('renders filter if there is one available option', async () => {
+ const mockCatalogApiOneOption: Partial> = {
+ getEntityFacets: jest.fn().mockResolvedValue({
+ facets: {
+ 'spec.options': [{ value: 'option1', count: 1 }],
+ },
+ }),
+ };
+ render(
+
+
+
+ label="Options"
+ path="spec.options"
+ name="options"
+ Filter={EntityOptionFilter}
+ />
+
+ ,
+ );
+ await waitFor(() => {
+ expect(screen.queryByText('Options')).toBeInTheDocument();
+ });
+ });
+
it('renders unique options in alphabetical order', async () => {
render(
diff --git a/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx b/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx
index 5e5bedaceb..a9b96f7e70 100644
--- a/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx
+++ b/plugins/catalog-react/src/components/EntityAutocompletePicker/EntityAutocompletePicker.tsx
@@ -144,8 +144,8 @@ export function EntityAutocompletePicker<
return null;
}
- // Hide if there are 1 or fewer options; nothing to pick from
- if (availableOptions.length <= 1) return null;
+ // Hide if there are no options; nothing to pick from
+ if (availableOptions.length === 0) return null;
return (