test(frontend-app-api): root override and cyclical extensions

Signed-off-by: Camila Belo <camilaibs@gmail.com>
This commit is contained in:
Camila Belo
2023-09-20 09:26:03 +02:00
parent 77485641b0
commit 24fa3afb5f
3 changed files with 68 additions and 0 deletions
+1
View File
@@ -24,6 +24,7 @@
},
"devDependencies": {
"@backstage/cli": "workspace:^",
"@backstage/test-utils": "workspace:^",
"@testing-library/jest-dom": "^5.10.1"
},
"configSchema": "config.d.ts",
@@ -0,0 +1,66 @@
/*
* Copyright 2023 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createExtension, createPlugin } from '@backstage/frontend-plugin-api';
import { createInstances } from './createApp';
import { MockConfigApi } from '@backstage/test-utils';
describe('createInstances', () => {
it('throws an error when a root extension is overridden', () => {
const config = new MockConfigApi({
app: {
extensions: [
{
root: {
at: '',
},
},
],
},
});
const plugins = [
createPlugin({
id: 'plugin',
extensions: [],
}),
];
expect(() => createInstances({ config, plugins })).toThrow(
'There is a root extension in the app config file and root extensions are not configurable',
);
});
it('throws an error when cyclical dependencies are found', () => {
const config = new MockConfigApi({});
const plugins = [
createPlugin({
id: 'plugin',
extensions: [
createExtension({
id: 'root',
at: 'core.routes/route',
inputs: {},
output: {},
factory() {},
}),
],
}),
];
expect(() => createInstances({ config, plugins })).toThrow(
'There is a cyclical dependency with the extension "core.layout": core.layout → core.routes → root → core.layout',
);
});
});
+1
View File
@@ -4213,6 +4213,7 @@ __metadata:
"@backstage/core-plugin-api": "workspace:^"
"@backstage/frontend-plugin-api": "workspace:^"
"@backstage/plugin-graphiql": "workspace:^"
"@backstage/test-utils": "workspace:^"
"@backstage/types": "workspace:^"
"@material-ui/core": ^4.12.4
"@testing-library/jest-dom": ^5.10.1