perf(test): consolidate pi-embedded helpers e2e suites

This commit is contained in:
Peter Steinberger
2026-02-16 00:57:47 +00:00
parent efe530acdd
commit 00e79ac897
25 changed files with 778 additions and 871 deletions

View File

@@ -1,8 +1,11 @@
import { describe, expect, it } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import {
buildBootstrapContextFiles,
DEFAULT_BOOTSTRAP_MAX_CHARS,
DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS,
resolveBootstrapMaxChars,
resolveBootstrapTotalMaxChars,
} from "./pi-embedded-helpers.js";
import { DEFAULT_AGENTS_FILENAME } from "./workspace.js";
@@ -100,3 +103,39 @@ describe("buildBootstrapContextFiles", () => {
expect(result[0]?.content.startsWith("[MISSING]")).toBe(true);
});
});
describe("resolveBootstrapMaxChars", () => {
it("returns default when unset", () => {
expect(resolveBootstrapMaxChars()).toBe(DEFAULT_BOOTSTRAP_MAX_CHARS);
});
it("uses configured value when valid", () => {
const cfg = {
agents: { defaults: { bootstrapMaxChars: 12345 } },
} as OpenClawConfig;
expect(resolveBootstrapMaxChars(cfg)).toBe(12345);
});
it("falls back when invalid", () => {
const cfg = {
agents: { defaults: { bootstrapMaxChars: -1 } },
} as OpenClawConfig;
expect(resolveBootstrapMaxChars(cfg)).toBe(DEFAULT_BOOTSTRAP_MAX_CHARS);
});
});
describe("resolveBootstrapTotalMaxChars", () => {
it("returns default when unset", () => {
expect(resolveBootstrapTotalMaxChars()).toBe(DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS);
});
it("uses configured value when valid", () => {
const cfg = {
agents: { defaults: { bootstrapTotalMaxChars: 12345 } },
} as OpenClawConfig;
expect(resolveBootstrapTotalMaxChars(cfg)).toBe(12345);
});
it("falls back when invalid", () => {
const cfg = {
agents: { defaults: { bootstrapTotalMaxChars: -1 } },
} as OpenClawConfig;
expect(resolveBootstrapTotalMaxChars(cfg)).toBe(DEFAULT_BOOTSTRAP_TOTAL_MAX_CHARS);
});
});