From e1ea702eca82dd31e285be07f287c2dd8349d1df Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 27 Aug 2024 11:10:49 +0200 Subject: [PATCH] chore: fix some tests Signed-off-by: blam --- .../src/blueprints/RouterBlueprint.test.tsx | 83 +- plugins/app/api-report.md | 872 +++++++++--------- 2 files changed, 477 insertions(+), 478 deletions(-) diff --git a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx index 62b55ec4a6..0ce21b5d6d 100644 --- a/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx +++ b/packages/frontend-plugin-api/src/blueprints/RouterBlueprint.test.tsx @@ -16,17 +16,14 @@ import React from 'react'; import { RouterBlueprint } from './RouterBlueprint'; import { MemoryRouter } from 'react-router-dom'; -import { render, waitFor } from '@testing-library/react'; -import { createSpecializedApp } from '@backstage/frontend-app-api'; +import { waitFor } from '@testing-library/react'; import { coreExtensionData, createExtension, createExtensionInput, - createExtensionOverrides, } from '../wiring'; -import { MockConfigApi } from '@backstage/test-utils'; import { PageBlueprint } from './PageBlueprint'; -import appPlugin from '@backstage/plugin-app'; +import { renderInTestApp } from '@backstage/frontend-test-utils'; describe('RouterBlueprint', () => { it('should return an extension when calling make with sensible defaults', () => { @@ -73,26 +70,19 @@ describe('RouterBlueprint', () => { }, }); - const app = createSpecializedApp({ - features: [ - appPlugin, - createExtensionOverrides({ - extensions: [ - extension, - PageBlueprint.make({ - namespace: 'test', - params: { - defaultPath: '/', - loader: async () =>
, - }, - }), - ], + const { getByTestId } = renderInTestApp(
, { + extensions: [ + extension, + PageBlueprint.make({ + namespace: 'test', + params: { + defaultPath: '/', + loader: async () =>
, + }, }), ], }); - const { getByTestId } = render(app.createRoot()); - await waitFor(() => { expect(getByTestId('test-contents')).toBeInTheDocument(); expect(getByTestId('test-router')).toBeInTheDocument(); @@ -126,34 +116,29 @@ describe('RouterBlueprint', () => { }, }); - const app = createSpecializedApp({ - features: [ - appPlugin, - createExtensionOverrides({ - extensions: [ - extension, - createExtension({ - namespace: 'test', - attachTo: { - id: 'app-router-component:test/test', - input: 'children', - }, - output: [coreExtensionData.reactElement], - *factory() { - yield coreExtensionData.reactElement(
); - }, - }), - PageBlueprint.make({ - namespace: 'test', - params: { - defaultPath: '/', - loader: async () =>
, - }, - }), - ], + const { getByTestId } = renderInTestApp(
, { + extensions: [ + extension, + createExtension({ + namespace: 'test', + attachTo: { + id: 'app-router-component:test/test', + input: 'children', + }, + output: [coreExtensionData.reactElement], + *factory() { + yield coreExtensionData.reactElement(
); + }, + }), + PageBlueprint.make({ + namespace: 'test', + params: { + defaultPath: '/', + loader: async () =>
, + }, }), ], - config: new MockConfigApi({ + config: { app: { extensions: [ { @@ -161,11 +146,9 @@ describe('RouterBlueprint', () => { }, ], }, - }), + }, }); - const { getByTestId } = render(app.createRoot()); - await waitFor(() => { expect(getByTestId('test-contents')).toBeInTheDocument(); expect(getByTestId('test-router-Robin-1')).toBeInTheDocument(); diff --git a/plugins/app/api-report.md b/plugins/app/api-report.md index 32c72d724b..73f5076ef3 100644 --- a/plugins/app/api-report.md +++ b/plugins/app/api-report.md @@ -29,22 +29,18 @@ const appPlugin: BackstagePlugin< {}, {}, { - [x: `component:app/${string}`]: ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef< + [x: `component:app/${string}`]: ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< { ref: ComponentRef; impl: ComponentType; }, 'core.component.component', {} - >, - { + >; + inputs: { [x: string]: ExtensionInput< AnyExtensionDataRef, { @@ -52,22 +48,20 @@ const appPlugin: BackstagePlugin< singleton: boolean; } >; - }, - { - kind: 'component'; - namespace: string; - name: string; - } - >; - app: ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: 'component'; + namespace: string; + name: string; + }>; + app: ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { root: ExtensionInput< ConfigurableExtensionDataRef, { @@ -75,33 +69,33 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: undefined; - namespace: 'app'; - name: undefined; - } - >; - 'api:app/app-language': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'app-language'; - } - >; - 'app/layout': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: undefined; + namespace: 'app'; + name: undefined; + }>; + 'api:app/app-language': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'app-language'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'app/layout': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { nav: ExtensionInput< ConfigurableExtensionDataRef, { @@ -116,22 +110,20 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: undefined; - namespace: 'app'; - name: 'layout'; - } - >; - 'app/nav': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: undefined; + namespace: 'app'; + name: 'layout'; + }>; + 'app/nav': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { items: ExtensionInput< ConfigurableExtensionDataRef< { @@ -161,22 +153,20 @@ const appPlugin: BackstagePlugin< optional: true; } >; - }, - { - kind: undefined; - namespace: 'app'; - name: 'nav'; - } - >; - 'app/root': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: undefined; + namespace: 'app'; + name: 'nav'; + }>; + 'app/root': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { router: ExtensionInput< ConfigurableExtensionDataRef< ComponentType<{ @@ -228,22 +218,20 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: undefined; - namespace: 'app'; - name: 'root'; - } - >; - 'app/routes': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: undefined; + namespace: 'app'; + name: 'root'; + }>; + 'app/routes': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { routes: ExtensionInput< | ConfigurableExtensionDataRef | ConfigurableExtensionDataRef @@ -259,22 +247,20 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: undefined; - namespace: 'app'; - name: 'routes'; - } - >; - 'api:app/app-theme': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: undefined; + namespace: 'app'; + name: 'routes'; + }>; + 'api:app/app-theme': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: { themes: ExtensionInput< ConfigurableExtensionDataRef, { @@ -282,44 +268,38 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: 'api'; - namespace: undefined; - name: 'app-theme'; - } - >; - 'theme:app/light': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'theme'; - namespace: 'app'; - name: 'light'; - } - >; - 'theme:app/dark': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'theme'; - namespace: 'app'; - name: 'dark'; - } - >; - 'api:app/components': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: 'api'; + namespace: undefined; + name: 'app-theme'; + }>; + 'theme:app/light': ExtensionDefinition<{ + kind: 'theme'; + namespace: 'app'; + name: 'light'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef; + inputs: {}; + }>; + 'theme:app/dark': ExtensionDefinition<{ + kind: 'theme'; + namespace: 'app'; + name: 'dark'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef; + inputs: {}; + }>; + 'api:app/components': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: { components: ExtensionInput< ConfigurableExtensionDataRef< { @@ -334,22 +314,20 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: 'api'; - namespace: undefined; - name: 'components'; - } - >; - 'api:app/icons': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: 'api'; + namespace: undefined; + name: 'components'; + }>; + 'api:app/icons': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: { icons: ExtensionInput< ConfigurableExtensionDataRef< { @@ -363,33 +341,33 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: 'api'; - namespace: undefined; - name: 'icons'; - } - >; - 'api:app/feature-flags': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'feature-flags'; - } - >; - 'api:app/translations': ExtensionDefinition< - { - [x: string]: any; - }, - { - [x: string]: any; - }, - ConfigurableExtensionDataRef, - { + }; + kind: 'api'; + namespace: undefined; + name: 'icons'; + }>; + 'api:app/feature-flags': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'feature-flags'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/translations': ExtensionDefinition<{ + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: { translations: ExtensionInput< ConfigurableExtensionDataRef< | TranslationResource @@ -408,33 +386,33 @@ const appPlugin: BackstagePlugin< optional: false; } >; - }, - { - kind: 'api'; - namespace: undefined; - name: 'translations'; - } - >; - 'app-root-element:app/oauth-request-dialog': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'app-root-element'; - namespace: 'app'; - name: 'oauth-request-dialog'; - } - >; - 'app-root-element:app/alert-display': ExtensionDefinition< - { + }; + kind: 'api'; + namespace: undefined; + name: 'translations'; + }>; + 'app-root-element:app/oauth-request-dialog': ExtensionDefinition<{ + kind: 'app-root-element'; + namespace: 'app'; + name: 'oauth-request-dialog'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: {}; + }>; + 'app-root-element:app/alert-display': ExtensionDefinition<{ + config: { transientTimeoutMs: number; anchorOrigin: { horizontal: 'center' | 'left' | 'right'; vertical: 'top' | 'bottom'; }; - }, - { + }; + configInput: { anchorOrigin?: | { horizontal?: 'center' | 'left' | 'right' | undefined; @@ -442,9 +420,13 @@ const appPlugin: BackstagePlugin< } | undefined; transientTimeoutMs?: number | undefined; - }, - ConfigurableExtensionDataRef, - { + }; + output: ConfigurableExtensionDataRef< + JSX_2.Element, + 'core.reactElement', + {} + >; + inputs: { [x: string]: ExtensionInput< AnyExtensionDataRef, { @@ -452,211 +434,245 @@ const appPlugin: BackstagePlugin< singleton: boolean; } >; - }, - { - kind: 'app-root-element'; - namespace: 'app'; - name: 'alert-display'; - } - >; - 'api:app/discovery': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'discovery'; - } - >; - 'api:app/alert': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'alert'; - } - >; - 'api:app/analytics': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'analytics'; - } - >; - 'api:app/error': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'error'; - } - >; - 'api:app/storage': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'storage'; - } - >; - 'api:app/fetch': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'fetch'; - } - >; - 'api:app/oauth-request': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'oauth-request'; - } - >; - 'api:app/google-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'google-auth'; - } - >; - 'api:app/microsoft-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'microsoft-auth'; - } - >; - 'api:app/github-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'github-auth'; - } - >; - 'api:app/okta-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'okta-auth'; - } - >; - 'api:app/gitlab-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'gitlab-auth'; - } - >; - 'api:app/onelogin-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'onelogin-auth'; - } - >; - 'api:app/bitbucket-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'bitbucket-auth'; - } - >; - 'api:app/bitbucket-server-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'bitbucket-server-auth'; - } - >; - 'api:app/atlassian-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'atlassian-auth'; - } - >; - 'api:app/vmware-cloud-auth': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'vmware-cloud-auth'; - } - >; - 'api:app/permission': ExtensionDefinition< - {}, - {}, - ConfigurableExtensionDataRef, - {}, - { - kind: 'api'; - namespace: undefined; - name: 'permission'; - } - >; + }; + kind: 'app-root-element'; + namespace: 'app'; + name: 'alert-display'; + }>; + 'api:app/discovery': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'discovery'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/alert': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'alert'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/analytics': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'analytics'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/error': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'error'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/storage': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'storage'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/fetch': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'fetch'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/oauth-request': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'oauth-request'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/google-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'google-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/microsoft-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'microsoft-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/github-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'github-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/okta-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'okta-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/gitlab-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'gitlab-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/onelogin-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'onelogin-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/bitbucket-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'bitbucket-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/bitbucket-server-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'bitbucket-server-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/atlassian-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'atlassian-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/vmware-cloud-auth': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'vmware-cloud-auth'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; + 'api:app/permission': ExtensionDefinition<{ + kind: 'api'; + namespace: undefined; + name: 'permission'; + config: {}; + configInput: {}; + output: ConfigurableExtensionDataRef< + AnyApiFactory, + 'core.api.factory', + {} + >; + inputs: {}; + }>; } >; export default appPlugin;