frontend-plugin-api: fix and simplify createPlugin tests

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-09-08 17:30:14 +02:00
parent f8669aacfa
commit c2c4ca8767
3 changed files with 9 additions and 13 deletions
@@ -26,6 +26,7 @@
"devDependencies": {
"@backstage/cli": "workspace:^",
"@backstage/frontend-app-api": "workspace:^",
"@backstage/test-utils": "workspace:^",
"@testing-library/jest-dom": "^5.10.1",
"@testing-library/react": "^12.1.3"
},
@@ -23,6 +23,7 @@ import { JsonObject } from '@backstage/types';
import { createExtension } from './createExtension';
import { createExtensionDataRef } from './createExtensionDataRef';
import { coreExtensionData } from './coreExtensionData';
import { MockConfigApi } from '@backstage/test-utils';
const nameExtensionDataRef = createExtensionDataRef<string>('name');
@@ -113,17 +114,10 @@ function createTestAppRoot({
plugins: BackstagePlugin[];
config: JsonObject;
}) {
Object.defineProperty(process.env, 'APP_CONFIG', {
value: [
{
data: config,
context: 'test',
},
],
configurable: true,
});
return createApp({ plugins: plugins }).createRoot();
return createApp({
plugins: plugins,
config: new MockConfigApi(config),
}).createRoot();
}
describe('createPlugin', () => {
@@ -143,7 +137,7 @@ describe('createPlugin', () => {
render(
createTestAppRoot({
plugins: [plugin],
config: { app: { extensions: [{ 'core.routes': false }] } },
config: { app: { extensions: [{ 'core.layout': false }] } },
}),
);
@@ -169,7 +163,7 @@ describe('createPlugin', () => {
config: {
app: {
extensions: [
{ 'core.routes': false },
{ 'core.layout': false },
{
'plugin.catalog.page': {
config: { name: 'CatalogRenamed' },
+1
View File
@@ -4339,6 +4339,7 @@ __metadata:
"@backstage/cli": "workspace:^"
"@backstage/core-plugin-api": "workspace:^"
"@backstage/frontend-app-api": "workspace:^"
"@backstage/test-utils": "workspace:^"
"@backstage/types": "workspace:^"
"@testing-library/jest-dom": ^5.10.1
"@testing-library/react": ^12.1.3