diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx index ef9bce507e..c3135e5697 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx @@ -169,6 +169,10 @@ describe('DefaultCatalogPage', () => { expect(columnHeaderLabels).toEqual([ 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', 'Description', 'Tags', 'Actions', diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx index cc05bbe2ae..572586b777 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.test.tsx @@ -25,6 +25,7 @@ import { MockEntityListContextProvider, starredEntitiesApiRef, UserListFilter, + EntityKindFilter, MockStarredEntitiesApi, } from '@backstage/plugin-catalog-react'; import { renderInTestApp, TestApiRegistry } from '@backstage/test-utils'; @@ -176,4 +177,137 @@ describe('CatalogTable component', () => { expect(window.open).toHaveBeenCalledWith('https://other.place', '_blank'); }); + + it.each([ + { + kind: 'api', + expectedColumns: [ + 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', + 'Description', + 'Tags', + 'Actions', + ], + }, + { + kind: 'component', + expectedColumns: [ + 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', + 'Description', + 'Tags', + 'Actions', + ], + }, + { + kind: 'domain', + expectedColumns: ['Name', 'Owner', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'group', + expectedColumns: ['Name', 'Type', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'location', + expectedColumns: ['Name', 'Type', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'resource', + expectedColumns: [ + 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', + 'Description', + 'Tags', + 'Actions', + ], + }, + { + kind: 'system', + expectedColumns: ['Name', 'Owner', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'template', + expectedColumns: ['Name', 'Type', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'user', + expectedColumns: ['Name', 'Description', 'Tags', 'Actions'], + }, + { + kind: 'custom', + expectedColumns: [ + 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', + 'Description', + 'Tags', + 'Actions', + ], + }, + { + kind: null, + expectedColumns: [ + 'Name', + 'System', + 'Owner', + 'Type', + 'Lifecycle', + 'Description', + 'Tags', + 'Actions', + ], + }, + ])( + 'should render correct columns with kind filter $kind', + async ({ kind, expectedColumns }) => { + const { getAllByRole } = await renderInTestApp( + + + + + , + { + mountedRoutes: { + '/catalog/:namespace/:kind/:name': entityRouteRef, + }, + }, + ); + + const columnHeader = getAllByRole('button').filter( + c => c.tagName === 'SPAN', + ); + const columnHeaderLabels = columnHeader.map(c => c.textContent); + expect(columnHeaderLabels).toEqual(expectedColumns); + + // expect(columnHeaderLabels).toEqual([ + // 'Name', + // 'System', + // 'Owner', + // 'Type', + // 'Lifecycle', + // 'Description', + // 'Tags', + // 'Actions' + // ]); + }, + 20_000, + ); }); diff --git a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx index addd2af7ec..114c3faab7 100644 --- a/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx +++ b/plugins/catalog/src/components/CatalogTable/CatalogTable.tsx @@ -74,39 +74,22 @@ export const CatalogTable = (props: CatalogTableProps) => { function createEntitySpecificColumns(): TableColumn[] { switch (filters.kind?.value) { - case 'api': - return [ - columnFactories.createSystemColumn(), - columnFactories.createOwnerColumn(), - columnFactories.createSpecTypeColumn(), - columnFactories.createSpecLifecycleColumn(), - ]; - case 'component': - return [ - columnFactories.createSystemColumn(), - columnFactories.createOwnerColumn(), - columnFactories.createSpecTypeColumn(), - columnFactories.createSpecLifecycleColumn(), - ]; + case 'user': + return []; case 'domain': - return [columnFactories.createOwnerColumn()]; - case 'group': - return [columnFactories.createSpecTypeColumn()]; - case 'location': - return [columnFactories.createSpecTypeColumn()]; - case 'resource': - return [ - columnFactories.createSystemColumn(), - columnFactories.createOwnerColumn(), - columnFactories.createSpecTypeColumn(), - columnFactories.createSpecLifecycleColumn(), - ]; case 'system': return [columnFactories.createOwnerColumn()]; + case 'group': + case 'location': case 'template': return [columnFactories.createSpecTypeColumn()]; default: - return []; + return [ + columnFactories.createSystemColumn(), + columnFactories.createOwnerColumn(), + columnFactories.createSpecTypeColumn(), + columnFactories.createSpecLifecycleColumn(), + ]; } } }, [filters.kind?.value]);