chore: fixing tests for RouterBlueprint

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-08-27 13:11:00 +02:00
parent 51046f5d27
commit 03e9125c0e
2 changed files with 35 additions and 48 deletions
@@ -274,9 +274,7 @@ export function createSpecializedApp(options?: {
config = new ConfigReader({}, 'empty-config'),
} = options ?? {};
const duplicatedFeatures = [appPlugin, ...featuresWithoutApp];
const features = deduplicateFeatures(duplicatedFeatures);
const features = deduplicateFeatures([appPlugin, ...featuresWithoutApp]);
const tree = resolveAppTree(
'root',
@@ -16,14 +16,17 @@
import React from 'react';
import { RouterBlueprint } from './RouterBlueprint';
import { MemoryRouter } from 'react-router-dom';
import { waitFor } from '@testing-library/react';
import { render, waitFor } from '@testing-library/react';
import {
coreExtensionData,
createExtension,
createExtensionInput,
} from '../wiring';
import { PageBlueprint } from './PageBlueprint';
import { renderInTestApp } from '@backstage/frontend-test-utils';
import {
createExtensionTester,
renderInTestApp,
} from '@backstage/frontend-test-utils';
describe('RouterBlueprint', () => {
it('should return an extension when calling make with sensible defaults', () => {
@@ -70,18 +73,14 @@ describe('RouterBlueprint', () => {
},
});
const { getByTestId } = renderInTestApp(<div />, {
extensions: [
extension,
PageBlueprint.make({
namespace: 'test',
params: {
defaultPath: '/',
loader: async () => <div data-testid="test-contents" />,
},
}),
],
});
const tester = createExtensionTester(extension);
const Component = tester.get(RouterBlueprint.dataRefs.component);
const { getByTestId } = render(
<Component>
<div data-testid="test-contents" />
</Component>,
);
await waitFor(() => {
expect(getByTestId('test-contents')).toBeInTheDocument();
@@ -116,38 +115,28 @@ describe('RouterBlueprint', () => {
},
});
const { getByTestId } = renderInTestApp(<div />, {
extensions: [
extension,
createExtension({
namespace: 'test',
attachTo: {
id: 'app-router-component:test/test',
input: 'children',
},
output: [coreExtensionData.reactElement],
*factory() {
yield coreExtensionData.reactElement(<div />);
},
}),
PageBlueprint.make({
namespace: 'test',
params: {
defaultPath: '/',
loader: async () => <div data-testid="test-contents" />,
},
}),
],
config: {
app: {
extensions: [
{
'app-router-component:test/test': { config: { name: 'Robin' } },
},
],
const tester = createExtensionTester(extension, {
config: { name: 'Robin' },
}).add(
createExtension({
namespace: 'test',
attachTo: {
id: 'app-router-component:test/test',
input: 'children',
},
},
});
output: [coreExtensionData.reactElement],
*factory() {
yield coreExtensionData.reactElement(<div />);
},
}),
);
const Component = tester.get(RouterBlueprint.dataRefs.component);
const { getByTestId } = render(
<Component>
<div data-testid="test-contents" />
</Component>,
);
await waitFor(() => {
expect(getByTestId('test-contents')).toBeInTheDocument();