From 876a340a20f0fa8389160437f11b5aaf659a55f2 Mon Sep 17 00:00:00 2001 From: jrwpatterson Date: Wed, 9 Aug 2023 08:33:04 +1000 Subject: [PATCH] feat(techdocs) add test Signed-off-by: jrwpatterson --- .../components/AboutCard/AboutCard.test.tsx | 81 ++++++++++++++++--- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/plugins/catalog/src/components/AboutCard/AboutCard.test.tsx b/plugins/catalog/src/components/AboutCard/AboutCard.test.tsx index e8d2657e9f..2e5642ec54 100644 --- a/plugins/catalog/src/components/AboutCard/AboutCard.test.tsx +++ b/plugins/catalog/src/components/AboutCard/AboutCard.test.tsx @@ -14,24 +14,25 @@ * limitations under the License. */ -import { RELATION_OWNED_BY } from '@backstage/catalog-model'; -import { ConfigReader } from '@backstage/core-app-api'; +import { + CatalogApi, + EntityProvider, + catalogApiRef, + entityRouteRef, +} from '@backstage/plugin-catalog-react'; import { ScmIntegrationsApi, scmIntegrationsApiRef, } from '@backstage/integration-react'; -import { - catalogApiRef, - EntityProvider, - CatalogApi, - entityRouteRef, -} from '@backstage/plugin-catalog-react'; -import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; -import userEvent from '@testing-library/user-event'; -import { screen } from '@testing-library/react'; -import React from 'react'; +import { TestApiProvider, renderInTestApp } from '@backstage/test-utils'; import { createFromTemplateRouteRef, viewTechDocRouteRef } from '../../routes'; + import { AboutCard } from './AboutCard'; +import { ConfigReader } from '@backstage/core-app-api'; +import { RELATION_OWNED_BY } from '@backstage/catalog-model'; +import React from 'react'; +import { screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; describe('', () => { const catalogApi: jest.Mocked = { @@ -347,6 +348,62 @@ describe('', () => { ).not.toBeInTheDocument(); }); + it('renders techdocs lin when 3rdparty', async () => { + const entity = { + apiVersion: 'v1', + kind: 'Component', + metadata: { + name: 'software', + annotations: { + 'backstage.io/techdocs-external-ref': 'system:default/example', + }, + }, + spec: { + owner: 'guest', + type: 'service', + lifecycle: 'production', + }, + }; + + await renderInTestApp( + + + + + , + { + mountedRoutes: { + '/docs/:namespace/:kind/:name': viewTechDocRouteRef, + '/catalog/:namespace/:kind/:name': entityRouteRef, + }, + }, + ); + + expect(screen.getByText('View TechDocs').closest('a')).toHaveAttribute( + 'href', + '/docs/default/System/example', + ); + }); + it('renders techdocs link', async () => { const entity = { apiVersion: 'v1',