From 6e13d7449475d4e8ff32fad7bc4484ea267f16d8 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Tue, 13 Jun 2023 11:25:37 +0200 Subject: [PATCH] catalog: fix mocked methods Signed-off-by: Vincenzo Scamporlino --- .../CatalogPage/DefaultCatalogPage.test.tsx | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx index eb79cd048c..4a60b7e6c5 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx @@ -15,12 +15,7 @@ */ import { CatalogApi } from '@backstage/catalog-client'; -import { - Entity, - parseEntityRef, - RELATION_MEMBER_OF, - RELATION_OWNED_BY, -} from '@backstage/catalog-model'; +import { RELATION_OWNED_BY } from '@backstage/catalog-model'; import { TableColumn, TableProps } from '@backstage/core-components'; import { IdentityApi, @@ -67,6 +62,7 @@ describe('DefaultCatalogPage', () => { kind: 'Component', metadata: { name: 'Entity1', + namespace: 'default', }, spec: { owner: 'tools', @@ -101,32 +97,18 @@ describe('DefaultCatalogPage', () => { }, ], }, - ] as Entity[], + ], }), getLocationByRef: () => Promise.resolve({ id: 'id', type: 'url', target: 'url' }), - getEntityFacets: async () => ({ facets: { 'relations.ownedBy': [] } }), - getEntityByRef: async entityRef => { - return { - apiVersion: 'backstage.io/v1alpha1', - kind: 'User', - metadata: { name: parseEntityRef(entityRef).name }, - relations: [ - { - type: RELATION_MEMBER_OF, - targetRef: 'group:default/tools', - target: { namespace: 'default', kind: 'Group', name: 'tools' }, - }, + getEntityFacets: async () => ({ + facets: { + 'relations.ownedBy': [ + { count: 1, value: 'group:default/not-tools' }, + { count: 1, value: 'group:default/tools' }, ], - }; - }, - /** - * For the purposes of this test case, use existing functionality. The picker - * isn't being tested, just needs this method to render correctly. - */ - getEntitiesByRefs: async refs => { - return { items: refs.entityRefs.map(() => undefined) }; - }, + }, + }), }; const testProfile: Partial = { displayName: 'Display Name',