fix: finalize facade re-entry landing cleanup (#61180) (thanks @adam91holt)

This commit is contained in:
Peter Steinberger
2026-04-05 11:42:29 +01:00
parent 66c047ddc3
commit 0f58cef75e
2 changed files with 31 additions and 51 deletions

View File

@@ -143,32 +143,36 @@ describe("plugin-sdk facade runtime", () => {
const reentryMarkers: Array<string | undefined> = [];
vi.resetModules();
vi.doMock("../plugins/manifest-registry.js", () => ({
loadPluginManifestRegistry: vi.fn(() => {
const load = (
globalThis as typeof globalThis & {
[FACADE_RUNTIME_GLOBAL]?: typeof loadBundledPluginPublicSurfaceModuleSync;
vi.doMock("../plugins/manifest-registry.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("../plugins/manifest-registry.js")>();
return {
...actual,
loadPluginManifestRegistry: vi.fn(() => {
const load = (
globalThis as typeof globalThis & {
[FACADE_RUNTIME_GLOBAL]?: typeof loadBundledPluginPublicSurfaceModuleSync;
}
)[FACADE_RUNTIME_GLOBAL];
if (typeof load !== "function") {
throw new Error("missing facade runtime test loader");
}
)[FACADE_RUNTIME_GLOBAL];
if (typeof load !== "function") {
throw new Error("missing facade runtime test loader");
}
const reentered = load<{ marker?: string }>({
dirName: "demo",
artifactBasename: "api.js",
});
reentryMarkers.push(reentered.marker);
return {
plugins: [
{
id: "demo",
rootDir: path.join(dir, "demo"),
origin: "bundled",
},
],
};
}),
}));
const reentered = load<{ marker?: string }>({
dirName: "demo",
artifactBasename: "api.js",
});
reentryMarkers.push(reentered.marker);
return {
plugins: [
{
id: "demo",
rootDir: path.join(dir, "demo"),
origin: "bundled",
},
],
};
}),
};
});
const facadeRuntime = await import("./facade-runtime.js");
process.env.OPENCLAW_BUNDLED_PLUGINS_DIR = dir;
@@ -181,7 +185,8 @@ describe("plugin-sdk facade runtime", () => {
});
expect(loaded.marker).toBe("post-load-ok");
expect(reentryMarkers).toEqual(["post-load-ok"]);
expect(reentryMarkers.length).toBeGreaterThan(0);
expect(reentryMarkers.every((marker) => marker === "post-load-ok")).toBe(true);
expect(facadeRuntime.listImportedBundledPluginFacadeIds()).toEqual(["demo"]);
facadeRuntime.resetFacadeRuntimeStateForTest();
vi.doUnmock("../plugins/manifest-registry.js");