mirror of
https://github.com/openclaw/openclaw.git
synced 2026-09-28 05:54:09 +08:00
* refactor: share external harness session coordination * refactor(agents): keep shared session helpers behind private runtime SDK * refactor(agents): share native session admission and attempt execution * refactor(agents): sync private attempt runtime exports * style(agents): format shared harness extraction * refactor(agents): simplify shared harness extraction * style(agents): format simplified harness helpers * fix(agents): align shared harness checks and fixtures * style(agents): format receiver-independent initializer * fix(agents): preserve extension fixture boundaries after extraction * style(test): format shared initializer fixture setup * fix(plugin-sdk): sync generated harness runtime export ordering --------- Co-authored-by: Sarah Fortune <sarah.fortune@gmail.com>
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
// Extension test setup installs extension-specific mocks and cleanup.
|
|
import { afterAll, afterEach, beforeEach, expect, vi } from "vitest";
|
|
import { installSharedTestSetup } from "./setup.shared.js";
|
|
|
|
const testEnv = installSharedTestSetup({ loadProfileEnv: false });
|
|
let restoreUpstreamLinks: (() => void) | undefined;
|
|
|
|
beforeEach(async () => {
|
|
vi.useRealTimers();
|
|
if (
|
|
!expect
|
|
.getState()
|
|
.testPath?.replaceAll("\\", "/")
|
|
.match(
|
|
/\/extensions\/codex\/src\/app-server\/upstream-(?:fork-import|session-fork|session-fork-continuation)\.test\.ts$/,
|
|
)
|
|
) {
|
|
return;
|
|
}
|
|
// Shared initialization calls the core owner; extension fixtures keep their public SDK mocks.
|
|
const [owner, facade] = await Promise.all([
|
|
vi.importActual<typeof import("../src/sessions/session-upstream-links.js")>(
|
|
"../src/sessions/session-upstream-links.js",
|
|
),
|
|
vi.importMock<typeof import("openclaw/plugin-sdk/session-catalog")>(
|
|
"openclaw/plugin-sdk/session-catalog",
|
|
),
|
|
]);
|
|
const upsert = vi
|
|
.spyOn(owner, "upsertSessionUpstreamLink")
|
|
.mockImplementation(facade.upsertSessionUpstreamLink);
|
|
const remove = vi
|
|
.spyOn(owner, "deleteSessionUpstreamLink")
|
|
.mockImplementation(facade.deleteSessionUpstreamLink);
|
|
restoreUpstreamLinks = () => {
|
|
upsert.mockRestore();
|
|
remove.mockRestore();
|
|
};
|
|
});
|
|
|
|
afterEach(() => {
|
|
restoreUpstreamLinks?.();
|
|
restoreUpstreamLinks = undefined;
|
|
});
|
|
|
|
afterAll(async () => {
|
|
const { drainAgentDatabaseResources } = await vi.importActual<
|
|
typeof import("../src/state/openclaw-agent-db-resources.js")
|
|
>("../src/state/openclaw-agent-db-resources.js");
|
|
// File-owned homes must survive until retained Worker leases have been released.
|
|
await drainAgentDatabaseResources({}, async () => {
|
|
testEnv.cleanup();
|
|
});
|
|
});
|