diff --git a/plugins/github-release-manager/src/features/CreateRc/CreateRc.test.tsx b/plugins/github-release-manager/src/features/CreateRc/CreateRc.test.tsx index 3c4a324b25..5f0ccaa20c 100644 --- a/plugins/github-release-manager/src/features/CreateRc/CreateRc.test.tsx +++ b/plugins/github-release-manager/src/features/CreateRc/CreateRc.test.tsx @@ -25,8 +25,10 @@ import { mockReleaseVersionCalver, mockSemverProject, } from '../../test-helpers/test-helpers'; +import { CreateRc } from './CreateRc'; import { TEST_IDS } from '../../test-helpers/test-ids'; import { useCreateRc } from './hooks/useCreateRc'; +import { useProjectContext } from '../../contexts/ProjectContext'; jest.mock('../../contexts/ProjectContext', () => ({ useProjectContext: jest.fn(() => ({ @@ -46,9 +48,6 @@ jest.mock('./hooks/useCreateRc', () => ({ } as ReturnType), })); -import { useProjectContext } from '../../contexts/ProjectContext'; -import { CreateRc } from './CreateRc'; - describe('CreateRc', () => { it('should display CTA', () => { const { getByTestId } = render( diff --git a/plugins/github-release-manager/src/features/CreateRc/hooks/useCreateRc.test.tsx b/plugins/github-release-manager/src/features/CreateRc/hooks/useCreateRc.test.tsx index cf4fa0f5ed..adbbe3b9f6 100644 --- a/plugins/github-release-manager/src/features/CreateRc/hooks/useCreateRc.test.tsx +++ b/plugins/github-release-manager/src/features/CreateRc/hooks/useCreateRc.test.tsx @@ -26,10 +26,9 @@ import { } from '../../../test-helpers/test-helpers'; import { useCreateRc } from './useCreateRc'; -jest.mock('../../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); describe('useCreateRc', () => { diff --git a/plugins/github-release-manager/src/features/Features.test.tsx b/plugins/github-release-manager/src/features/Features.test.tsx index d53f542cef..e2f5428331 100644 --- a/plugins/github-release-manager/src/features/Features.test.tsx +++ b/plugins/github-release-manager/src/features/Features.test.tsx @@ -17,13 +17,17 @@ import React from 'react'; import { render, act, waitFor } from '@testing-library/react'; +import { Features } from './Features'; import { mockApiClient, mockCalverProject } from '../test-helpers/test-helpers'; import { TEST_IDS } from '../test-helpers/test-ids'; -jest.mock('../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), + ErrorBoundary: ({ children }: { children: React.ReactNode }) => ( + <>{children} + ), + InfoCard: ({ children }: { children: React.ReactNode }) => <>{children}, })); jest.mock('../contexts/ProjectContext', () => ({ useProjectContext: () => ({ @@ -31,8 +35,6 @@ jest.mock('../contexts/ProjectContext', () => ({ }), })); -import { Features } from './Features'; - describe('Features', () => { it('should omit features omitted via configuration', async () => { const { getByTestId } = render( @@ -52,7 +54,7 @@ describe('Features', () => { expect(getByTestId(TEST_IDS.info.info)).toMatchInlineSnapshot(`
({ useProjectContext: () => ({ @@ -29,8 +30,6 @@ jest.mock('../../contexts/ProjectContext', () => ({ }), })); -import { Info } from './Info'; - describe('Info', () => { it('should return early if no latestRelease exists', async () => { const { findByText } = render( diff --git a/plugins/github-release-manager/src/features/Patch/Patch.test.tsx b/plugins/github-release-manager/src/features/Patch/Patch.test.tsx index 2f7f170d9f..458861c802 100644 --- a/plugins/github-release-manager/src/features/Patch/Patch.test.tsx +++ b/plugins/github-release-manager/src/features/Patch/Patch.test.tsx @@ -22,6 +22,7 @@ import { mockCalverProject, } from '../../test-helpers/test-helpers'; import { TEST_IDS } from '../../test-helpers/test-ids'; +import { Patch } from './Patch'; jest.mock('../../contexts/ProjectContext', () => ({ useProjectContext: () => ({ @@ -29,8 +30,6 @@ jest.mock('../../contexts/ProjectContext', () => ({ }), })); -import { Patch } from './Patch'; - describe('Patch', () => { it('should return early if no latestRelease exists', () => { const { getByTestId } = render( diff --git a/plugins/github-release-manager/src/features/Patch/PatchBody.test.tsx b/plugins/github-release-manager/src/features/Patch/PatchBody.test.tsx index be9ea1ce45..38c09ab943 100644 --- a/plugins/github-release-manager/src/features/Patch/PatchBody.test.tsx +++ b/plugins/github-release-manager/src/features/Patch/PatchBody.test.tsx @@ -26,11 +26,12 @@ import { mockReleaseVersionCalver, mockTagParts, } from '../../test-helpers/test-helpers'; +import { PatchBody } from './PatchBody'; +import { TEST_IDS } from '../../test-helpers/test-ids'; -jest.mock('../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); jest.mock('../../contexts/ProjectContext', () => ({ useProjectContext: () => ({ @@ -45,9 +46,6 @@ jest.mock('./hooks/usePatch', () => ({ }), })); -import { PatchBody } from './PatchBody'; -import { TEST_IDS } from '../../test-helpers/test-ids'; - describe('PatchBody', () => { beforeEach(jest.clearAllMocks); diff --git a/plugins/github-release-manager/src/features/Patch/hooks/usePatch.test.ts b/plugins/github-release-manager/src/features/Patch/hooks/usePatch.test.ts index be25b84809..5fe1614e42 100644 --- a/plugins/github-release-manager/src/features/Patch/hooks/usePatch.test.ts +++ b/plugins/github-release-manager/src/features/Patch/hooks/usePatch.test.ts @@ -27,10 +27,9 @@ import { } from '../../../test-helpers/test-helpers'; import { usePatch } from './usePatch'; -jest.mock('../../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); describe('patch', () => { diff --git a/plugins/github-release-manager/src/features/PromoteRc/PromoteRc.test.tsx b/plugins/github-release-manager/src/features/PromoteRc/PromoteRc.test.tsx index f4e7c1fb41..089b626da3 100644 --- a/plugins/github-release-manager/src/features/PromoteRc/PromoteRc.test.tsx +++ b/plugins/github-release-manager/src/features/PromoteRc/PromoteRc.test.tsx @@ -22,6 +22,7 @@ import { mockReleaseVersionCalver, } from '../../test-helpers/test-helpers'; import { TEST_IDS } from '../../test-helpers/test-ids'; +import { PromoteRc } from './PromoteRc'; jest.mock('./PromoteRcBody', () => ({ PromoteRcBody: () => ( @@ -29,8 +30,6 @@ jest.mock('./PromoteRcBody', () => ({ ), })); -import { PromoteRc } from './PromoteRc'; - describe('PromoteRc', () => { it('return early if no latest release present', () => { const { getByTestId } = render(); diff --git a/plugins/github-release-manager/src/features/PromoteRc/PromoteRcBody.test.tsx b/plugins/github-release-manager/src/features/PromoteRc/PromoteRcBody.test.tsx index 2d67832587..14b294e581 100644 --- a/plugins/github-release-manager/src/features/PromoteRc/PromoteRcBody.test.tsx +++ b/plugins/github-release-manager/src/features/PromoteRc/PromoteRcBody.test.tsx @@ -19,6 +19,7 @@ import { render } from '@testing-library/react'; import { mockReleaseCandidateCalver } from '../../test-helpers/test-helpers'; import { TEST_IDS } from '../../test-helpers/test-ids'; +import { PromoteRcBody } from './PromoteRcBody'; jest.mock('./hooks/usePromoteRc', () => ({ usePromoteRc: () => ({ @@ -28,8 +29,6 @@ jest.mock('./hooks/usePromoteRc', () => ({ }), })); -import { PromoteRcBody } from './PromoteRcBody'; - describe('PromoteRcBody', () => { it('should display CTA', () => { const { getByTestId } = render( diff --git a/plugins/github-release-manager/src/features/PromoteRc/hooks/usePromoteRc.test.ts b/plugins/github-release-manager/src/features/PromoteRc/hooks/usePromoteRc.test.ts index 4b7149ba7b..d682476d33 100644 --- a/plugins/github-release-manager/src/features/PromoteRc/hooks/usePromoteRc.test.ts +++ b/plugins/github-release-manager/src/features/PromoteRc/hooks/usePromoteRc.test.ts @@ -24,10 +24,9 @@ import { } from '../../../test-helpers/test-helpers'; import { usePromoteRc } from './usePromoteRc'; -jest.mock('../../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); jest.mock('../../../contexts/ProjectContext', () => ({ useProjectContext: () => ({ diff --git a/plugins/github-release-manager/src/features/RepoDetailsForm/Owner.test.tsx b/plugins/github-release-manager/src/features/RepoDetailsForm/Owner.test.tsx index da95f5fa50..aed6fe3496 100644 --- a/plugins/github-release-manager/src/features/RepoDetailsForm/Owner.test.tsx +++ b/plugins/github-release-manager/src/features/RepoDetailsForm/Owner.test.tsx @@ -23,6 +23,8 @@ import { mockSearchCalver, } from '../../test-helpers/test-helpers'; import { TEST_IDS } from '../../test-helpers/test-ids'; +import { useProjectContext } from '../../contexts/ProjectContext'; +import { Owner } from './Owner'; jest.mock('react-router', () => ({ useNavigate: jest.fn(), @@ -30,10 +32,9 @@ jest.mock('react-router', () => ({ search: mockSearchCalver, })), })); -jest.mock('../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); jest.mock('../../contexts/ProjectContext', () => ({ useProjectContext: jest.fn(() => ({ @@ -41,9 +42,6 @@ jest.mock('../../contexts/ProjectContext', () => ({ })), })); -import { useProjectContext } from '../../contexts/ProjectContext'; -import { Owner } from './Owner'; - describe('Owner', () => { beforeEach(jest.clearAllMocks); diff --git a/plugins/github-release-manager/src/features/RepoDetailsForm/Repo.test.tsx b/plugins/github-release-manager/src/features/RepoDetailsForm/Repo.test.tsx index ab6c98ea5f..9b087d47e2 100644 --- a/plugins/github-release-manager/src/features/RepoDetailsForm/Repo.test.tsx +++ b/plugins/github-release-manager/src/features/RepoDetailsForm/Repo.test.tsx @@ -23,6 +23,8 @@ import { mockSearchCalver, } from '../../test-helpers/test-helpers'; import { TEST_IDS } from '../../test-helpers/test-ids'; +import { useProjectContext } from '../../contexts/ProjectContext'; +import { Repo } from './Repo'; jest.mock('react-router', () => ({ useNavigate: jest.fn(), @@ -30,10 +32,9 @@ jest.mock('react-router', () => ({ search: mockSearchCalver, })), })); -jest.mock('../../contexts/PluginApiClientContext', () => ({ - usePluginApiClientContext: () => ({ - pluginApiClient: mockApiClient, - }), +jest.mock('@backstage/core', () => ({ + useApi: () => mockApiClient, + createApiRef: jest.fn(), })); jest.mock('../../contexts/ProjectContext', () => ({ useProjectContext: jest.fn(() => ({ @@ -41,9 +42,6 @@ jest.mock('../../contexts/ProjectContext', () => ({ })), })); -import { useProjectContext } from '../../contexts/ProjectContext'; -import { Repo } from './Repo'; - describe('Repo', () => { beforeEach(jest.clearAllMocks); diff --git a/plugins/github-release-manager/src/features/RepoDetailsForm/VersioningStrategy.test.tsx b/plugins/github-release-manager/src/features/RepoDetailsForm/VersioningStrategy.test.tsx index 4d36b26ed6..42a17f9b43 100644 --- a/plugins/github-release-manager/src/features/RepoDetailsForm/VersioningStrategy.test.tsx +++ b/plugins/github-release-manager/src/features/RepoDetailsForm/VersioningStrategy.test.tsx @@ -21,6 +21,7 @@ import { mockSemverProject, mockSearchCalver, } from '../../test-helpers/test-helpers'; +import { VersioningStrategy } from './VersioningStrategy'; const mockNavigate = jest.fn(); @@ -36,8 +37,6 @@ jest.mock('../../contexts/ProjectContext', () => ({ }), })); -import { VersioningStrategy } from './VersioningStrategy'; - describe('Repo', () => { beforeEach(jest.clearAllMocks); diff --git a/plugins/github-release-manager/src/helpers/tagParts/getTagParts.test.ts b/plugins/github-release-manager/src/helpers/tagParts/getTagParts.test.ts index fc1ab1479b..825d23c001 100644 --- a/plugins/github-release-manager/src/helpers/tagParts/getTagParts.test.ts +++ b/plugins/github-release-manager/src/helpers/tagParts/getTagParts.test.ts @@ -18,6 +18,9 @@ import { mockCalverProject, mockSemverProject, } from '../../test-helpers/test-helpers'; +import { getCalverTagParts } from './getCalverTagParts'; +import { getSemverTagParts } from './getSemverTagParts'; +import { getTagParts } from './getTagParts'; jest.mock('./getCalverTagParts', () => ({ getCalverTagParts: jest.fn(), @@ -26,10 +29,6 @@ jest.mock('./getSemverTagParts', () => ({ getSemverTagParts: jest.fn(), })); -import { getCalverTagParts } from './getCalverTagParts'; -import { getSemverTagParts } from './getSemverTagParts'; -import { getTagParts } from './getTagParts'; - describe('getTagParts', () => { beforeEach(jest.resetAllMocks); diff --git a/plugins/github-release-manager/src/hooks/useQueryHandler.test.tsx b/plugins/github-release-manager/src/hooks/useQueryHandler.test.tsx index a80fa3df04..4024e37054 100644 --- a/plugins/github-release-manager/src/hooks/useQueryHandler.test.tsx +++ b/plugins/github-release-manager/src/hooks/useQueryHandler.test.tsx @@ -18,6 +18,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { mockSearchSemver } from '../test-helpers/test-helpers'; +import { useQueryHandler } from './useQueryHandler'; jest.mock('react-router', () => ({ useLocation: jest.fn(() => ({ @@ -25,8 +26,6 @@ jest.mock('react-router', () => ({ })), })); -import { useQueryHandler } from './useQueryHandler'; - const TEST_ID = 'grm--use-query-handler'; const MockComponent = () => {