mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-26 16:41:49 +00:00
fix: finalize facade re-entry landing cleanup (#61180) (thanks @adam91holt)
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user