chore: updating the frontend-* packages
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -30,24 +30,26 @@ import {
|
||||
} from '@backstage/core-plugin-api';
|
||||
import { createRouteRef } from '../routing';
|
||||
import { createExtensionTester } from '@backstage/frontend-test-utils';
|
||||
import { createApiExtension } from '../extensions';
|
||||
import { ApiBlueprint } from '../blueprints';
|
||||
|
||||
const wrapInBoundaryExtension = (element?: JSX.Element) => {
|
||||
const routeRef = createRouteRef();
|
||||
return createExtension({
|
||||
name: 'test',
|
||||
attachTo: { id: 'app/routes', input: 'routes' },
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
path: coreExtensionData.routePath,
|
||||
routeRef: coreExtensionData.routeRef.optional(),
|
||||
},
|
||||
output: [
|
||||
coreExtensionData.reactElement,
|
||||
coreExtensionData.routePath,
|
||||
coreExtensionData.routeRef.optional(),
|
||||
],
|
||||
factory({ node }) {
|
||||
return {
|
||||
routeRef,
|
||||
path: '/',
|
||||
element: <ExtensionBoundary node={node}>{element}</ExtensionBoundary>,
|
||||
};
|
||||
return [
|
||||
coreExtensionData.reactElement(
|
||||
<ExtensionBoundary node={node}>{element}</ExtensionBoundary>,
|
||||
),
|
||||
coreExtensionData.routePath('/'),
|
||||
coreExtensionData.routeRef(routeRef),
|
||||
];
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -134,8 +136,11 @@ describe('ExtensionBoundary', () => {
|
||||
await act(async () => {
|
||||
createExtensionTester(wrapInBoundaryExtension(<Emitter />))
|
||||
.add(
|
||||
createApiExtension({
|
||||
factory: createApiFactory(analyticsApiRef, analyticsApiMock),
|
||||
ApiBlueprint.make({
|
||||
namespace: analyticsApiRef.id,
|
||||
params: {
|
||||
factory: createApiFactory(analyticsApiRef, analyticsApiMock),
|
||||
},
|
||||
}),
|
||||
)
|
||||
.render();
|
||||
|
||||
@@ -41,8 +41,8 @@ describe('createExtensionTester', () => {
|
||||
const defaultDefinition = {
|
||||
namespace: 'test',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { element: coreExtensionData.reactElement },
|
||||
factory: () => ({ element: <div>test</div> }),
|
||||
output: [coreExtensionData.reactElement],
|
||||
factory: () => [coreExtensionData.reactElement(<div>test</div>)],
|
||||
};
|
||||
|
||||
it('should render a simple extension', async () => {
|
||||
@@ -77,23 +77,23 @@ describe('createExtensionTester', () => {
|
||||
it('should render multiple extensions', async () => {
|
||||
const indexPageExtension = createExtension({
|
||||
...defaultDefinition,
|
||||
factory: () => ({
|
||||
element: (
|
||||
factory: () => [
|
||||
coreExtensionData.reactElement(
|
||||
<div>
|
||||
Index page <Link to="/details">See details</Link>
|
||||
</div>
|
||||
</div>,
|
||||
),
|
||||
}),
|
||||
],
|
||||
});
|
||||
const detailsPageExtension = createExtension({
|
||||
...defaultDefinition,
|
||||
name: 'details',
|
||||
attachTo: { id: 'app/routes', input: 'routes' },
|
||||
output: {
|
||||
path: coreExtensionData.routePath,
|
||||
element: coreExtensionData.reactElement,
|
||||
},
|
||||
factory: () => ({ path: '/details', element: <div>Details page</div> }),
|
||||
output: [coreExtensionData.routePath, coreExtensionData.reactElement],
|
||||
factory: () => [
|
||||
coreExtensionData.routePath('/details'),
|
||||
coreExtensionData.reactElement(<div>Details page</div>),
|
||||
],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(indexPageExtension);
|
||||
@@ -112,9 +112,11 @@ describe('createExtensionTester', () => {
|
||||
it('should accepts a custom config', async () => {
|
||||
const indexPageExtension = createExtension({
|
||||
...defaultDefinition,
|
||||
configSchema: createSchemaFromZod(z =>
|
||||
z.object({ title: z.string().optional() }),
|
||||
),
|
||||
config: {
|
||||
schema: {
|
||||
title: z => z.string().optional(),
|
||||
},
|
||||
},
|
||||
factory: ({ config }) => {
|
||||
const Component = () => {
|
||||
const configApi = useApi(configApiRef);
|
||||
@@ -127,9 +129,8 @@ describe('createExtensionTester', () => {
|
||||
</div>
|
||||
);
|
||||
};
|
||||
return {
|
||||
element: <Component />,
|
||||
};
|
||||
|
||||
return [coreExtensionData.reactElement(<Component />)];
|
||||
},
|
||||
});
|
||||
|
||||
@@ -137,17 +138,18 @@ describe('createExtensionTester', () => {
|
||||
...defaultDefinition,
|
||||
name: 'details',
|
||||
attachTo: { id: 'app/routes', input: 'routes' },
|
||||
configSchema: createSchemaFromZod(z =>
|
||||
z.object({ title: z.string().optional() }),
|
||||
),
|
||||
output: {
|
||||
path: coreExtensionData.routePath,
|
||||
element: coreExtensionData.reactElement,
|
||||
config: {
|
||||
schema: {
|
||||
title: z => z.string().optional(),
|
||||
},
|
||||
},
|
||||
factory: ({ config }) => ({
|
||||
path: '/details',
|
||||
element: <div>{config.title ?? 'Details page'}</div>,
|
||||
}),
|
||||
output: [coreExtensionData.routePath, coreExtensionData.reactElement],
|
||||
factory: ({ config }) => [
|
||||
coreExtensionData.routePath('/details'),
|
||||
coreExtensionData.reactElement(
|
||||
<div>{config.title ?? 'Details page'}</div>,
|
||||
),
|
||||
],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(indexPageExtension, {
|
||||
@@ -209,9 +211,7 @@ describe('createExtensionTester', () => {
|
||||
);
|
||||
};
|
||||
|
||||
return {
|
||||
element: <Component />,
|
||||
};
|
||||
return [coreExtensionData.reactElement(<Component />)];
|
||||
},
|
||||
});
|
||||
|
||||
@@ -254,16 +254,16 @@ describe('createExtensionTester', () => {
|
||||
namespace: 'test',
|
||||
name: 'e1',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
factory: () => ({ text: 'test-text' }),
|
||||
output: [stringDataRef],
|
||||
factory: () => [stringDataRef('test-text')],
|
||||
});
|
||||
|
||||
const extension2 = createExtension({
|
||||
namespace: 'test',
|
||||
name: 'e2',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
factory: () => ({ text: 'test-text' }),
|
||||
output: [stringDataRef],
|
||||
factory: () => [stringDataRef('test-text')],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(extension);
|
||||
@@ -278,16 +278,16 @@ describe('createExtensionTester', () => {
|
||||
namespace: 'test',
|
||||
name: 'e1',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
factory: () => ({ text: 'test-text' }),
|
||||
output: [stringDataRef],
|
||||
factory: () => [stringDataRef('test-text')],
|
||||
});
|
||||
|
||||
const extension2 = createExtension({
|
||||
namespace: 'test',
|
||||
name: 'e2',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
factory: () => ({ text: 'test-text' }),
|
||||
output: [stringDataRef],
|
||||
factory: () => [stringDataRef('test-text')],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(extension).add(extension2);
|
||||
@@ -377,26 +377,21 @@ describe('createExtensionTester', () => {
|
||||
namespace: 'test',
|
||||
name: 'e1',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
output: [stringDataRef],
|
||||
inputs: {
|
||||
input: createExtensionInput(
|
||||
{
|
||||
output: stringDataRef,
|
||||
},
|
||||
{ singleton: true },
|
||||
),
|
||||
input: createExtensionInput([stringDataRef], { singleton: true }),
|
||||
},
|
||||
factory: ({ inputs }) => ({
|
||||
text: `nest-${inputs.input.output.output}`,
|
||||
}),
|
||||
factory: ({ inputs }) => [
|
||||
stringDataRef(`nest-${inputs.input.get(stringDataRef)}`),
|
||||
],
|
||||
});
|
||||
|
||||
const extension2 = createExtension({
|
||||
namespace: 'test',
|
||||
name: 'e2',
|
||||
attachTo: { id: 'test/e1', input: 'blob' },
|
||||
output: { text: stringDataRef },
|
||||
factory: () => ({ text: 'test-text' }),
|
||||
output: [stringDataRef],
|
||||
factory: () => [stringDataRef('test-text')],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(extension).add(extension2);
|
||||
@@ -418,18 +413,13 @@ describe('createExtensionTester', () => {
|
||||
namespace: 'test',
|
||||
name: 'e1',
|
||||
attachTo: { id: 'ignored', input: 'ignored' },
|
||||
output: { text: stringDataRef },
|
||||
output: [stringDataRef],
|
||||
inputs: {
|
||||
input: createExtensionInput(
|
||||
{
|
||||
output: stringDataRef,
|
||||
},
|
||||
{ singleton: true },
|
||||
),
|
||||
input: createExtensionInput([stringDataRef], { singleton: true }),
|
||||
},
|
||||
factory: ({ inputs }) => ({
|
||||
text: `nest-${inputs.input.output.output}`,
|
||||
}),
|
||||
factory: ({ inputs }) => [
|
||||
stringDataRef(`nest-${inputs.input.get(stringDataRef)}`),
|
||||
],
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(extension, {
|
||||
|
||||
@@ -152,14 +152,16 @@ export function renderInTestApp(
|
||||
kind: 'test-route',
|
||||
name: path,
|
||||
attachTo: { id: 'app/root', input: 'elements' },
|
||||
output: {
|
||||
element: coreExtensionData.reactElement,
|
||||
path: coreExtensionData.routePath,
|
||||
routeRef: coreExtensionData.routeRef,
|
||||
},
|
||||
factory() {
|
||||
return { element: <React.Fragment />, path, routeRef };
|
||||
},
|
||||
output: [
|
||||
coreExtensionData.reactElement,
|
||||
coreExtensionData.routePath,
|
||||
coreExtensionData.routeRef,
|
||||
],
|
||||
factory: () => [
|
||||
coreExtensionData.reactElement(<React.Fragment />),
|
||||
coreExtensionData.routePath(path),
|
||||
coreExtensionData.routeRef(routeRef),
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user