feat: add the ability to provide features or overrides to renderInTestApp

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-08-27 10:34:26 +02:00
parent 5b714ddece
commit ddbdad54e5
@@ -31,6 +31,7 @@ import {
IconComponent,
RouterBlueprint,
NavItemBlueprint,
ExtensionOverrides,
} from '@backstage/frontend-plugin-api';
/**
@@ -60,6 +61,16 @@ export type TestAppOptions = {
* Additional configuration passed to the app when rendering elements inside it.
*/
config?: JsonObject;
/**
* Additional extensions to add to the test app.
*/
extensions?: ExtensionDefinition<any, any>[];
/**
* Additional features to add to the test app.
*/
features?: ExtensionOverrides[];
};
const NavItem = (props: {
@@ -167,12 +178,22 @@ export function renderInTestApp(
}
}
if (options?.extensions) {
extensions.push(...options.extensions);
}
const features = [
createExtensionOverrides({
extensions,
}),
];
if (options?.features) {
features.push(...options.features);
}
const app = createSpecializedApp({
features: [
createExtensionOverrides({
extensions,
}),
],
features,
config: ConfigReader.fromConfigs([
{ context: 'render-config', data: options?.config ?? {} },
]),