mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:50:43 +00:00
Tests: align pnpm test expectations with main
This commit is contained in:
@@ -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 =
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
renderBundledRootHelpText,
|
||||
writeCliStartupMetadata,
|
||||
} from "../../scripts/write-cli-startup-metadata.ts";
|
||||
import { writeCliStartupMetadata } from "../../scripts/write-cli-startup-metadata.ts";
|
||||
import { createScriptTestHarness } from "./test-helpers.js";
|
||||
|
||||
describe("write-cli-startup-metadata", () => {
|
||||
const { createTempDir } = createScriptTestHarness();
|
||||
|
||||
it("captures bundled root help text from the CLI program", async () => {
|
||||
const rootHelpText = await renderBundledRootHelpText();
|
||||
|
||||
expect(rootHelpText).toContain("Usage:");
|
||||
expect(rootHelpText).toContain("openclaw");
|
||||
});
|
||||
|
||||
it("writes startup metadata with populated root help text", async () => {
|
||||
it("writes startup metadata with populated root help text when dist falls back to source rendering", async () => {
|
||||
const tempRoot = createTempDir("openclaw-startup-metadata-");
|
||||
const distDir = path.join(tempRoot, "dist");
|
||||
const extensionsDir = path.join(tempRoot, "extensions");
|
||||
|
||||
Reference in New Issue
Block a user