Do not create extensionTree during tests

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
Co-authored-by: Camila Belo <camilaibs@gmail.com>
Co-authored-by: Philipp Hugenroth <philipph@spotify.com>
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2023-09-13 15:12:07 +02:00
parent 219b46ae1a
commit 5d4c45580c
2 changed files with 15 additions and 7 deletions
+12 -5
View File
@@ -117,7 +117,10 @@ import { PuppetDbPage } from '@backstage/plugin-puppetdb';
import { DevToolsPage } from '@backstage/plugin-devtools';
import { customDevToolsPage } from './components/devtools/CustomDevToolsPage';
import { CatalogUnprocessedEntitiesPage } from '@backstage/plugin-catalog-unprocessed-entities';
import { createExtensionTree } from '@backstage/frontend-app-api';
import {
createExtensionTree,
ExtensionTree,
} from '@backstage/frontend-app-api';
const app = createApp({
apis,
@@ -165,9 +168,12 @@ const app = createApp({
});
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */
const extensionTree = createExtensionTree({
config: ConfigReader.fromConfigs(await defaultConfigLoader()),
});
let extensionTree: ExtensionTree | undefined;
if (process.env.NODE_ENV === 'test') {
extensionTree = createExtensionTree({
config: ConfigReader.fromConfigs(await defaultConfigLoader()),
});
}
const routes = (
<FlatRoutes>
@@ -283,7 +289,8 @@ const routes = (
element={<TechRadarPage width={1500} height={800} />}
/>
{
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree.getRootRoutes()
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree?.getRootRoutes() ??
null
}
<Route path="/lighthouse" element={<LighthousePage />} />
<Route path="/api-docs" element={<ApiExplorerPage />} />
+3 -2
View File
@@ -85,7 +85,7 @@ const SidebarLogo = () => {
export const Root = ({
children,
extensionTree,
}: PropsWithChildren<{ extensionTree: ExtensionTree }>) => (
}: PropsWithChildren<{ extensionTree?: ExtensionTree }>) => (
<SidebarPage>
<Sidebar>
<SidebarLogo />
@@ -167,7 +167,8 @@ export const Root = ({
text="Cost Insights"
/>
{
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree.getSidebarItems()
/* HIGHLY EXPERIMENTAL. DO NOT USE THIS IN YOUR APP */ extensionTree?.getSidebarItems() ??
null
}
<SidebarItem icon={Score} to="score-board" text="Score board" />
</SidebarScrollWrapper>