Merge pull request #26233 from backstage/blam/add-extensions-and-features
NFS: Added more options to `renderInTestApp`
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/frontend-test-utils': patch
|
||||
---
|
||||
|
||||
Added the ability to provide additional `extensions` and `features` to `renderInTestApp`
|
||||
@@ -14,6 +14,7 @@ import { ErrorWithContext } from '@backstage/test-utils';
|
||||
import { ExtensionDataRef } from '@backstage/frontend-plugin-api';
|
||||
import { ExtensionDefinition } from '@backstage/frontend-plugin-api';
|
||||
import { ExtensionDefinitionParameters } from '@backstage/frontend-plugin-api';
|
||||
import { FrontendFeature } from '@backstage/frontend-plugin-api';
|
||||
import { JsonObject } from '@backstage/types';
|
||||
import { MockConfigApi } from '@backstage/test-utils';
|
||||
import { MockErrorApi } from '@backstage/test-utils';
|
||||
@@ -134,6 +135,8 @@ export type TestAppOptions = {
|
||||
[path: string]: RouteRef;
|
||||
};
|
||||
config?: JsonObject;
|
||||
extensions?: ExtensionDefinition<any>[];
|
||||
features?: FrontendFeature[];
|
||||
};
|
||||
|
||||
export { withLogCollector };
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
IconComponent,
|
||||
RouterBlueprint,
|
||||
NavItemBlueprint,
|
||||
FrontendFeature,
|
||||
} 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>[];
|
||||
|
||||
/**
|
||||
* Additional features to add to the test app.
|
||||
*/
|
||||
features?: FrontendFeature[];
|
||||
};
|
||||
|
||||
const NavItem = (props: {
|
||||
@@ -167,12 +178,22 @@ export function renderInTestApp(
|
||||
}
|
||||
}
|
||||
|
||||
if (options?.extensions) {
|
||||
extensions.push(...options.extensions);
|
||||
}
|
||||
|
||||
const features: FrontendFeature[] = [
|
||||
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 ?? {} },
|
||||
]),
|
||||
|
||||
Reference in New Issue
Block a user