From 8232ad4144764cf29f11673c7015bcc187e665a6 Mon Sep 17 00:00:00 2001 From: David An Date: Wed, 29 Mar 2023 16:07:06 -0600 Subject: [PATCH] added a case when there is 1 option available Signed-off-by: David An --- .../EntityNamespacePicker.test.tsx | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/plugins/catalog-react/src/components/EntityNamespacePicker/EntityNamespacePicker.test.tsx b/plugins/catalog-react/src/components/EntityNamespacePicker/EntityNamespacePicker.test.tsx index c92d7f6236..7dd13620c7 100644 --- a/plugins/catalog-react/src/components/EntityNamespacePicker/EntityNamespacePicker.test.tsx +++ b/plugins/catalog-react/src/components/EntityNamespacePicker/EntityNamespacePicker.test.tsx @@ -194,7 +194,7 @@ describe('', () => { const mockCatalogApiRefNoNamespace = { getEntityFacets: async () => ({ facets: { - 'metadata.tags': {}, + 'metadata.namespace': {}, }, }), } as unknown as CatalogApi; @@ -217,4 +217,29 @@ describe('', () => { }), ); }); + it('namespace picker is invisible if there are only 1 available option', async () => { + const defaultNamespaces = ['default', 'default', 'default']; + const mockCatalogApiRefDefaultNamespace = { + getEntityFacets: async () => ({ + facets: { + 'metadata.namespace': defaultNamespaces.map((value, idx) => ({ + value, + count: idx, + })), + }, + }), + } as unknown as CatalogApi; + render( + + + + + , + ); + await waitFor(() => + expect(screen.queryByText('Namespace')).not.toBeInTheDocument(), + ); + }); });