Tests: align pnpm test expectations with main (#67001)

Merged via squash.

Prepared head SHA: 29c8068053
Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
Reviewed-by: @hxy91819
This commit is contained in:
Mason Huang
2026-04-15 18:31:23 +08:00
committed by GitHub
parent 8dd1abedec
commit edfa074e0f
15 changed files with 301 additions and 44 deletions

View File

@@ -6,8 +6,10 @@ import "./test-helpers/fast-openclaw-tools.js";
import { createOpenClawCodingTools } from "./pi-tools.js";
describe("createOpenClawCodingTools", () => {
const testConfig: OpenClawConfig = {};
it("preserves action enums in normalized schemas", () => {
const defaultTools = createOpenClawCodingTools({ senderIsOwner: true });
const defaultTools = createOpenClawCodingTools({ config: testConfig, senderIsOwner: true });
const toolNames = ["canvas", "nodes", "cron", "gateway", "message"];
const missingNames = toolNames.filter(
(name) => !defaultTools.some((candidate) => candidate.name === name),
@@ -56,18 +58,20 @@ describe("createOpenClawCodingTools", () => {
}
});
it("enforces apply_patch availability and canonical names across model/provider constraints", () => {
const defaultTools = createOpenClawCodingTools({ senderIsOwner: true });
const defaultTools = createOpenClawCodingTools({ config: testConfig, senderIsOwner: true });
expect(defaultTools.some((tool) => tool.name === "exec")).toBe(true);
expect(defaultTools.some((tool) => tool.name === "process")).toBe(true);
expect(defaultTools.some((tool) => tool.name === "apply_patch")).toBe(false);
const openAiTools = createOpenClawCodingTools({
config: testConfig,
modelProvider: "openai",
modelId: "gpt-5.4",
});
expect(openAiTools.some((tool) => tool.name === "apply_patch")).toBe(true);
const codexTools = createOpenClawCodingTools({
config: testConfig,
modelProvider: "openai-codex",
modelId: "gpt-5.4",
});
@@ -116,6 +120,7 @@ describe("createOpenClawCodingTools", () => {
expect(denied.some((tool) => tool.name === "apply_patch")).toBe(false);
const oauthTools = createOpenClawCodingTools({
config: testConfig,
modelProvider: "anthropic",
modelAuthMode: "oauth",
});
@@ -127,7 +132,7 @@ describe("createOpenClawCodingTools", () => {
expect(names.has("apply_patch")).toBe(false);
});
it("provides top-level object schemas for all tools", () => {
const tools = createOpenClawCodingTools();
const tools = createOpenClawCodingTools({ config: testConfig });
const offenders = tools
.map((tool) => {
const schema =

View File

@@ -120,6 +120,8 @@ describe("skills-install fallback edge cases", () => {
});
it("handles sudo probe failures for go install without apt fallback", async () => {
vi.spyOn(process, "getuid").mockReturnValue(1000);
for (const testCase of [
{
label: "sudo returns password required",
@@ -130,8 +132,9 @@ describe("skills-install fallback edge cases", () => {
stderr: "sudo: a password is required",
}),
assert: (result: { message: string; stderr: string }) => {
expect(result.message).toContain("sudo");
expect(result.message).toContain("sudo is not usable");
expect(result.message).toContain("https://go.dev/doc/install");
expect(result.stderr).toContain("sudo: a password is required");
},
},
{
@@ -142,6 +145,7 @@ describe("skills-install fallback edge cases", () => {
),
assert: (result: { message: string; stderr: string }) => {
expect(result.message).toContain("sudo is not usable");
expect(result.message).toContain("https://go.dev/doc/install");
expect(result.stderr).toContain("Executable not found");
},
},
@@ -167,6 +171,7 @@ describe("skills-install fallback edge cases", () => {
});
it("status-selected go installer fails gracefully when apt fallback needs sudo", async () => {
vi.spyOn(process, "getuid").mockReturnValue(1000);
mockAvailableBinaries(["apt-get", "sudo"]);
runCommandWithTimeoutMock.mockResolvedValueOnce({
@@ -187,6 +192,7 @@ describe("skills-install fallback edge cases", () => {
expect(result.ok).toBe(false);
expect(result.message).toContain("sudo is not usable");
expect(result.stderr).toContain("sudo: a password is required");
});
it("uv not installed and no brew returns helpful error without curl auto-install", async () => {

View File

@@ -339,7 +339,7 @@ describe("timestampOptsFromConfig", () => {
{
name: "falls back gracefully with empty config",
cfg: {} as any,
expected: Intl.DateTimeFormat().resolvedOptions().timeZone,
expected: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC",
},
])("$name", ({ cfg, expected }) => {
expect(timestampOptsFromConfig(cfg).timezone).toBe(expected);

View File

@@ -1355,8 +1355,8 @@ describe("installPluginFromArchive", () => {
expect(result.ok).toBe(false);
if (!result.ok) {
expect(result.code).toBe(PLUGIN_INSTALL_ERROR_CODE.SECURITY_SCAN_FAILED);
expect(result.error).toContain("manifest dependency scan could not read");
expect(result.code).toBe(PLUGIN_INSTALL_ERROR_CODE.SECURITY_SCAN_BLOCKED);
expect(result.error).toContain("plain-crypto-js");
expect(result.error).toContain("vendor/sealed");
}
} finally {