test(agents): dedupe shared bootstrap and tool-id test setup

This commit is contained in:
Peter Steinberger
2026-02-18 14:01:24 +00:00
parent 33f30367e1
commit 33b0b38f65
3 changed files with 44 additions and 91 deletions

View File

@@ -9,23 +9,27 @@ import { makeTempWorkspace } from "../test-helpers/workspace.js";
import { resolveBootstrapContextForRun, resolveBootstrapFilesForRun } from "./bootstrap-files.js";
import type { WorkspaceBootstrapFile } from "./workspace.js";
function registerExtraBootstrapFileHook() {
registerInternalHook("agent:bootstrap", (event) => {
const context = event.context as AgentBootstrapHookContext;
context.bootstrapFiles = [
...context.bootstrapFiles,
{
name: "EXTRA.md",
path: path.join(context.workspaceDir, "EXTRA.md"),
content: "extra",
missing: false,
} as unknown as WorkspaceBootstrapFile,
];
});
}
describe("resolveBootstrapFilesForRun", () => {
beforeEach(() => clearInternalHooks());
afterEach(() => clearInternalHooks());
it("applies bootstrap hook overrides", async () => {
registerInternalHook("agent:bootstrap", (event) => {
const context = event.context as AgentBootstrapHookContext;
context.bootstrapFiles = [
...context.bootstrapFiles,
{
name: "EXTRA.md",
path: path.join(context.workspaceDir, "EXTRA.md"),
content: "extra",
missing: false,
} as unknown as WorkspaceBootstrapFile,
];
});
registerExtraBootstrapFileHook();
const workspaceDir = await makeTempWorkspace("openclaw-bootstrap-");
const files = await resolveBootstrapFilesForRun({ workspaceDir });
@@ -39,18 +43,7 @@ describe("resolveBootstrapContextForRun", () => {
afterEach(() => clearInternalHooks());
it("returns context files for hook-adjusted bootstrap files", async () => {
registerInternalHook("agent:bootstrap", (event) => {
const context = event.context as AgentBootstrapHookContext;
context.bootstrapFiles = [
...context.bootstrapFiles,
{
name: "EXTRA.md",
path: path.join(context.workspaceDir, "EXTRA.md"),
content: "extra",
missing: false,
} as unknown as WorkspaceBootstrapFile,
];
});
registerExtraBootstrapFileHook();
const workspaceDir = await makeTempWorkspace("openclaw-bootstrap-");
const result = await resolveBootstrapContextForRun({ workspaceDir });