Files
Netcatty/electron/plugins/shutdownCoordinator.test.cjs
T
ryan-wong-coder 7a47187e37 feat(plugins): add isolated plugin host runtime (#2303)
* feat(plugins): add isolated plugin host runtime

* test(plugins): build runtime dependencies before tests

* fix(plugins): harden runtime lifecycle and recovery

* fix(plugins): harden runtime extension boundaries

* fix(plugins): enforce runtime integrity boundaries

* fix(plugins): await utility process exit

* fix(plugins): harden utility process containment

* fix(plugins): close runtime recovery gaps

* fix(plugins): harden runtime lifecycle boundaries
2026-07-19 08:22:17 +08:00

27 lines
941 B
JavaScript

"use strict";
const assert = require("node:assert/strict");
const test = require("node:test");
const {
registerPluginShutdown,
resetPluginShutdownForTests,
runPluginShutdown,
} = require("./shutdownCoordinator.cjs");
test("plugin shutdown is idempotent and completes before its quit deadline", async (context) => {
context.after(resetPluginShutdownForTests);
let calls = 0;
registerPluginShutdown(async () => { calls += 1; });
const [first, second] = await Promise.all([runPluginShutdown(), runPluginShutdown()]);
assert.deepEqual(first, { timedOut: false });
assert.deepEqual(second, { timedOut: false });
assert.equal(calls, 1);
});
test("plugin shutdown fails open after the bounded quit deadline", async (context) => {
context.after(resetPluginShutdownForTests);
registerPluginShutdown(async () => new Promise(() => {}));
assert.deepEqual(await runPluginShutdown({ timeoutMs: 5 }), { timedOut: true });
});