mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:11:24 +00:00
test: dedupe agent tests and session helpers
This commit is contained in:
@@ -17,6 +17,12 @@ const makeFile = (overrides: Partial<WorkspaceBootstrapFile>): WorkspaceBootstra
|
||||
missing: false,
|
||||
...overrides,
|
||||
});
|
||||
|
||||
const createLargeBootstrapFiles = (): WorkspaceBootstrapFile[] => [
|
||||
makeFile({ name: "AGENTS.md", content: "a".repeat(10_000) }),
|
||||
makeFile({ name: "SOUL.md", path: "/tmp/SOUL.md", content: "b".repeat(10_000) }),
|
||||
makeFile({ name: "USER.md", path: "/tmp/USER.md", content: "c".repeat(10_000) }),
|
||||
];
|
||||
describe("buildBootstrapContextFiles", () => {
|
||||
it("keeps missing markers", () => {
|
||||
const files = [makeFile({ missing: true, content: undefined })];
|
||||
@@ -60,11 +66,7 @@ describe("buildBootstrapContextFiles", () => {
|
||||
});
|
||||
|
||||
it("keeps total injected bootstrap characters under the new default total cap", () => {
|
||||
const files = [
|
||||
makeFile({ name: "AGENTS.md", content: "a".repeat(10_000) }),
|
||||
makeFile({ name: "SOUL.md", path: "/tmp/SOUL.md", content: "b".repeat(10_000) }),
|
||||
makeFile({ name: "USER.md", path: "/tmp/USER.md", content: "c".repeat(10_000) }),
|
||||
];
|
||||
const files = createLargeBootstrapFiles();
|
||||
const result = buildBootstrapContextFiles(files);
|
||||
const totalChars = result.reduce((sum, entry) => sum + entry.content.length, 0);
|
||||
expect(totalChars).toBeLessThanOrEqual(DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS);
|
||||
@@ -73,11 +75,7 @@ describe("buildBootstrapContextFiles", () => {
|
||||
});
|
||||
|
||||
it("caps total injected bootstrap characters when totalMaxChars is configured", () => {
|
||||
const files = [
|
||||
makeFile({ name: "AGENTS.md", content: "a".repeat(10_000) }),
|
||||
makeFile({ name: "SOUL.md", path: "/tmp/SOUL.md", content: "b".repeat(10_000) }),
|
||||
makeFile({ name: "USER.md", path: "/tmp/USER.md", content: "c".repeat(10_000) }),
|
||||
];
|
||||
const files = createLargeBootstrapFiles();
|
||||
const result = buildBootstrapContextFiles(files, { totalMaxChars: 24_000 });
|
||||
const totalChars = result.reduce((sum, entry) => sum + entry.content.length, 0);
|
||||
expect(totalChars).toBeLessThanOrEqual(24_000);
|
||||
|
||||
Reference in New Issue
Block a user