From 5877409e33ea7a640b9e02f38e575de97b69572f Mon Sep 17 00:00:00 2001 From: secustor Date: Fri, 21 Feb 2025 12:45:15 +0100 Subject: [PATCH] tests(techdocs-modules): fix errors in the test Signed-off-by: secustor --- plugins/techdocs-module-addons-contrib/package.json | 1 + .../src/LigthBox/LightBox.test.tsx | 12 ++++++++++++ yarn.lock | 1 + 3 files changed, 14 insertions(+) diff --git a/plugins/techdocs-module-addons-contrib/package.json b/plugins/techdocs-module-addons-contrib/package.json index 52d74439ce..b6b8391264 100644 --- a/plugins/techdocs-module-addons-contrib/package.json +++ b/plugins/techdocs-module-addons-contrib/package.json @@ -43,6 +43,7 @@ "@backstage/core-plugin-api": "workspace:^", "@backstage/integration": "workspace:^", "@backstage/integration-react": "workspace:^", + "@backstage/plugin-catalog-react": "workspace:^", "@backstage/plugin-techdocs-react": "workspace:^", "@material-ui/core": "^4.12.2", "@material-ui/icons": "^4.9.1", diff --git a/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.test.tsx b/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.test.tsx index b63aed8777..2d8cb9592d 100644 --- a/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.test.tsx +++ b/plugins/techdocs-module-addons-contrib/src/LigthBox/LightBox.test.tsx @@ -19,13 +19,24 @@ import { TechDocsAddonTester } from '@backstage/plugin-techdocs-addons-test-util import React from 'react'; import { LightBox } from '../plugin'; +import { entityPresentationApiRef } from '@backstage/plugin-catalog-react'; describe('LightBox', () => { + const entityPresentationApiMock = { + forEntity: jest.fn(), + }; + entityPresentationApiMock.forEntity.mockReturnValue({ + snapshot: { + primaryTitle: 'Test Entity', + }, + }); + it('renders without exploding', async () => { const { getByText } = await TechDocsAddonTester.buildAddonsInTechDocs([ , ]) .withDom(TEST_CONTENT) + .withApis([[entityPresentationApiRef, entityPresentationApiMock]]) .renderWithEffects(); expect(getByText('TEST_CONTENT')).toBeInTheDocument(); @@ -42,6 +53,7 @@ describe('LightBox', () => { alt="dog" />, ) + .withApis([[entityPresentationApiRef, entityPresentationApiMock]]) .renderWithEffects(); expect(getByTestId('fixture').onclick).not.toBeUndefined(); diff --git a/yarn.lock b/yarn.lock index d8da8eface..ce76862715 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8115,6 +8115,7 @@ __metadata: "@backstage/core-plugin-api": "workspace:^" "@backstage/integration": "workspace:^" "@backstage/integration-react": "workspace:^" + "@backstage/plugin-catalog-react": "workspace:^" "@backstage/plugin-techdocs-addons-test-utils": "workspace:^" "@backstage/plugin-techdocs-react": "workspace:^" "@backstage/test-utils": "workspace:^"