diff --git a/packages/main/src/plugin/extension-loader.spec.ts b/packages/main/src/plugin/extension-loader.spec.ts index 43124f8aa63e2..84e97be1fda54 100644 --- a/packages/main/src/plugin/extension-loader.spec.ts +++ b/packages/main/src/plugin/extension-loader.spec.ts @@ -129,7 +129,9 @@ const configurationRegistry: ConfigurationRegistry = { updateConfigurationValue: configurationRegistryUpdateConfigurationMock, } as unknown as ConfigurationRegistry; -const imageRegistry: ImageRegistry = {} as unknown as ImageRegistry; +const imageRegistry: ImageRegistry = { + registerRegistry: vi.fn(), +} as unknown as ImageRegistry; const apiSender: ApiSenderType = { send: vi.fn() } as unknown as ApiSenderType; @@ -2207,3 +2209,22 @@ test('load extensions sequentially', async () => { expect(loadExtensionMock.mock.calls[1][0]).toBe(analyzedExtension2); expect(loadExtensionMock.mock.calls[2][0]).toBe(analyzedExtension3); }); + +test('when loading registry registerRegistry, do not push to disposables', async () => { + const disposables: IDisposable[] = []; + + const api = extensionLoader.createApi('/path', {}, disposables); + expect(api).toBeDefined(); + + const fakeRegistry = { + source: 'fake', + serverUrl: 'http://fake', + username: 'foo', + password: 'bar', + secret: 'baz', + }; + + api.registry.registerRegistry(fakeRegistry); + + expect(disposables.length).toBe(0); +}); diff --git a/packages/main/src/plugin/extension-loader.ts b/packages/main/src/plugin/extension-loader.ts index e171e425fe8c2..9a013b4556da5 100644 --- a/packages/main/src/plugin/extension-loader.ts +++ b/packages/main/src/plugin/extension-loader.ts @@ -888,9 +888,7 @@ export class ExtensionLoader { const imageRegistry = this.imageRegistry; const registry: typeof containerDesktopAPI.registry = { registerRegistry: (registry: containerDesktopAPI.Registry): Disposable => { - const registration = imageRegistry.registerRegistry(registry); - disposables.push(registration); - return registration; + return imageRegistry.registerRegistry(registry); }, suggestRegistry: (registry: containerDesktopAPI.RegistrySuggestedProvider): Disposable => {