diff --git a/packages/server/src/server/plugins/index.posix.test.ts b/packages/server/src/server/plugins/index.posix.test.ts index 364e24e40b..c529bd37d3 100644 --- a/packages/server/src/server/plugins/index.posix.test.ts +++ b/packages/server/src/server/plugins/index.posix.test.ts @@ -1075,23 +1075,29 @@ export default function contribute(plugin: unknown) { const service = bindTestSessionHost( new PluginService(pino({ level: "silent" }), store, "0.4.0"), ); - await service.start(); - await service.installDirectory({ path: first }); - await service.installDirectory({ path: second }); + try { + await service.start(); + await service.installDirectory({ path: first }); + await service.installDirectory({ path: second }); + expect(catalogIds(service)).toEqual(["first", "second"]); + await store.patch({ pluginsEnabled: false }); - await store.patch({ pluginsEnabled: false }); - - expect(service.catalog()).toEqual([]); - await expect(service.invokePluginRpc("second", "anything", {})).rejects.toThrow( - "Plugin is not available", - ); - await store.patch({ pluginsEnabled: true }); - await service.reloadPlugin("first"); - expect((await service.listPlugins()).map(({ id, status }) => ({ id, status }))).toEqual([ - { id: "first", status: "running" }, - { id: "second", status: "running" }, - ]); - await service.stopAllPlugins(); + expect(service.catalog()).toEqual([]); + await expect(service.invokePluginRpc("second", "anything", {})).rejects.toThrow( + "Plugin is not available", + ); + await store.patch({ pluginsEnabled: true }); + // Observe recovery itself. Reloading here restarts a healthy plugin and + // would also conceal a failure to restart it after the global enable. + await expect + .poll(() => service.listPlugins(), { timeout: 10_000 }) + .toMatchObject([ + { id: "first", status: "running" }, + { id: "second", status: "running" }, + ]); + } finally { + await service.stopAllPlugins(); + } }, 20_000); it("does not publish an in-flight start after a later global disable", async () => {