diff --git a/public/app/features/plugins/extensions/getPluginExtensions.test.ts b/public/app/features/plugins/extensions/getPluginExtensions.test.ts index 0ad86c5f080..ce106bce5a5 100644 --- a/public/app/features/plugins/extensions/getPluginExtensions.test.ts +++ b/public/app/features/plugins/extensions/getPluginExtensions.test.ts @@ -134,18 +134,30 @@ describe('getPluginExtensions()', () => { expect(extension.category).toBe('Machine Learning'); }); - test('should hide the extension if it tries to override not-allowed properties with the configure() function', () => { + test('should ignore restricted properties passed via the configure() function', () => { link2.configure = jest.fn().mockImplementation(() => ({ // The following props are not allowed to override type: 'unknown-type', pluginId: 'another-plugin', + + // Unknown properties + testing: false, + + // The following props are allowed to override + title: 'test', })); const registry = createPluginExtensionRegistry([{ pluginId, extensionConfigs: [link2] }]); const { extensions } = getPluginExtensions({ registry, extensionPointId: extensionPoint2 }); + const [extension] = extensions; expect(link2.configure).toHaveBeenCalledTimes(1); - expect(extensions).toHaveLength(0); + expect(extensions).toHaveLength(1); + expect(extension.title).toBe('test'); + expect(extension.type).toBe('link'); + expect(extension.pluginId).toBe('grafana-basic-app'); + //@ts-ignore + expect(extension.testing).toBeUndefined(); }); test('should pass a read only context to the configure() function', () => { const context = { title: 'New title from the context!' }; diff --git a/public/app/features/plugins/extensions/getPluginExtensions.ts b/public/app/features/plugins/extensions/getPluginExtensions.ts index e878989ebf1..71acd6a365b 100644 --- a/public/app/features/plugins/extensions/getPluginExtensions.ts +++ b/public/app/features/plugins/extensions/getPluginExtensions.ts @@ -139,10 +139,10 @@ function getLinkExtensionOverrides(pluginId: string, config: PluginExtensionLink assertStringProps({ title, description }, ['title', 'description']); if (Object.keys(rest).length > 0) { - throw new Error( - `Invalid extension "${config.title}". Trying to override not-allowed properties: ${Object.keys(rest).join( + logWarning( + `Extension "${config.title}", is trying to override restricted properties: ${Object.keys(rest).join( ', ' - )}` + )} which will be ignored.` ); }