diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.test.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.test.tsx
index 4da1c4632c..8e1b1e1ea0 100644
--- a/packages/frontend-test-utils/src/app/renderInTestApp.test.tsx
+++ b/packages/frontend-test-utils/src/app/renderInTestApp.test.tsx
@@ -20,19 +20,15 @@ import {
MockAnalyticsApi,
TestApiProvider,
} from '@backstage/frontend-test-utils';
-import {
- analyticsApiRef,
- PageBlueprint,
- useAnalytics,
-} from '@backstage/frontend-plugin-api';
+import { analyticsApiRef, useAnalytics } from '@backstage/frontend-plugin-api';
+import { Routes, Route } from 'react-router-dom';
import { renderInTestApp } from './renderInTestApp';
-import { Route, Routes } from 'react-router-dom';
describe('renderInTestApp', () => {
it('should render the given component in a page', async () => {
const IndexPage = () =>
Index Page
;
renderInTestApp();
- expect(await screen.findByText('Index Page')).toBeInTheDocument();
+ expect(screen.getByText('Index Page')).toBeInTheDocument();
});
it('should works with apis provider', async () => {
@@ -59,7 +55,7 @@ describe('renderInTestApp', () => {
,
);
- fireEvent.click(await screen.findByRole('link', { name: 'See details' }));
+ fireEvent.click(screen.getByRole('link', { name: 'See details' }));
expect(analyticsApiMock.getEvents()).toEqual(
expect.arrayContaining([
@@ -72,25 +68,16 @@ describe('renderInTestApp', () => {
});
it('should support setting different locations in the history stack', async () => {
- renderInTestApp(Index page
, {
- extensions: [
- PageBlueprint.make({
- name: 'second-page',
- params: defineParams =>
- defineParams({
- path: '/second-page',
- loader: async () => (
-
- Second page} />
- Subpage} />
-
- ),
- }),
- }),
- ],
- initialRouteEntries: ['/second-page/subpage'],
- });
+ renderInTestApp(
+
+ Index Page} />
+ Second Page} />
+ ,
+ {
+ initialRouteEntries: ['/second-page'],
+ },
+ );
- expect(await screen.findByText('Subpage')).toBeInTheDocument();
+ expect(screen.getByText('Second Page')).toBeInTheDocument();
});
});
diff --git a/packages/frontend-test-utils/src/app/renderInTestApp.tsx b/packages/frontend-test-utils/src/app/renderInTestApp.tsx
index 8f52f349fe..e1b35eba6c 100644
--- a/packages/frontend-test-utils/src/app/renderInTestApp.tsx
+++ b/packages/frontend-test-utils/src/app/renderInTestApp.tsx
@@ -31,7 +31,6 @@ import {
NavItemBlueprint,
createFrontendPlugin,
FrontendFeature,
- PageBlueprint,
} from '@backstage/frontend-plugin-api';
import appPlugin from '@backstage/plugin-app';
@@ -108,6 +107,12 @@ const appPluginOverride = appPlugin.withOverrides({
appPlugin.getExtension('sign-in-page:app').override({
disabled: true,
}),
+ appPlugin.getExtension('app/layout').override({
+ disabled: true,
+ }),
+ appPlugin.getExtension('app/routes').override({
+ disabled: true,
+ }),
appPlugin.getExtension('app/nav').override({
output: [coreExtensionData.reactElement],
factory(_originalFactory, { inputs }) {
@@ -147,6 +152,13 @@ export function renderInTestApp(
options?: TestAppOptions,
): RenderResult {
const extensions: Array = [
+ createExtension({
+ attachTo: { id: 'app/root', input: 'children' },
+ output: [coreExtensionData.reactElement],
+ factory: () => {
+ return [coreExtensionData.reactElement(element)];
+ },
+ }),
RouterBlueprint.make({
params: {
component: ({ children }) => (
@@ -185,13 +197,6 @@ export function renderInTestApp(
extensions.push(...options.extensions);
}
- extensions.push(
- PageBlueprint.make({
- name: 'mocked-root-page',
- params: define => define({ path: '/', loader: async () => element }),
- }),
- );
-
const features: FrontendFeature[] = [
createFrontendPlugin({
pluginId: 'test',