test: dedupe agent tests and session helpers

This commit is contained in:
Peter Steinberger
2026-02-22 17:11:17 +00:00
parent 415686244a
commit ad1072842e
31 changed files with 1021 additions and 1109 deletions

View File

@@ -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);