From b0ef2dc0ba5b604bdbf7a87f4026b9975cfd05ba Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 13 Aug 2024 09:12:21 +0200 Subject: [PATCH] chore: restructure tests and fix api-report Signed-off-by: blam --- packages/frontend-plugin-api/api-report.md | 4 +++ .../src/wiring/createPlugin.test.ts | 34 ++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/frontend-plugin-api/api-report.md b/packages/frontend-plugin-api/api-report.md index 6d548e3c26..f841fc2ce2 100644 --- a/packages/frontend-plugin-api/api-report.md +++ b/packages/frontend-plugin-api/api-report.md @@ -356,6 +356,10 @@ export interface BackstagePlugin< readonly id: string; // (undocumented) readonly routes: TRoutes; + // (undocumented) + withOverrides(options: { + extensions: Array>; + }): BackstagePlugin; } export { BackstageUserIdentity }; diff --git a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts index f1a0817c80..f76e4ec9a5 100644 --- a/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts +++ b/packages/frontend-plugin-api/src/wiring/createPlugin.test.ts @@ -273,16 +273,42 @@ describe('createPlugin', () => { }); describe('overrides', () => { + it('should return a plugin instance with the correct namespace', () => { + const plugin = createPlugin({ + id: 'test', + extensions: [Extension1, Extension2], + }); + + expect(plugin.getExtension('test/1')).toMatchInlineSnapshot(` + { + "$$type": "@backstage/ExtensionDefinition", + "attachTo": { + "id": "test/output", + "input": "names", + }, + "configSchema": undefined, + "disabled": false, + "factory": [Function], + "inputs": {}, + "kind": undefined, + "name": "1", + "namespace": "test", + "output": [ + [Function], + ], + "override": [Function], + "toString": [Function], + "version": "v2", + } + `); + }); + it('should allow overriding extensions that have a matching ID, while keeping old extensions that do not have overlapping IDs', async () => { const plugin = createPlugin({ id: 'test', extensions: [Extension1, Extension2, outputExtension], }); - expect(plugin.getExtension('test/1')).toMatchObject({ - namespace: 'test', - }); - await renderWithEffects( createTestAppRoot({ features: [