mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-16 18:34:18 +00:00
test: verify infra generated values
This commit is contained in:
@@ -15,7 +15,8 @@ describe("resolveCliAuthEpoch", () => {
|
||||
epoch: Awaited<ReturnType<typeof resolveCliAuthEpoch>>,
|
||||
label = "auth epoch",
|
||||
): asserts epoch is string {
|
||||
expect(epoch, label).toEqual(expect.stringMatching(/\S/));
|
||||
expect(typeof epoch, label).toBe("string");
|
||||
expect(epoch?.trim().length, label).toBeGreaterThan(0);
|
||||
}
|
||||
|
||||
it("returns undefined when no local or auth-profile credentials exist", async () => {
|
||||
|
||||
@@ -180,8 +180,12 @@ describe("diagnostic-trace-context", () => {
|
||||
});
|
||||
});
|
||||
|
||||
expect(createDiagnosticTraceContextFromActiveScope({ spanId: CHILD_SPAN_ID })).toEqual({
|
||||
traceId: expect.stringMatching(/^[0-9a-f]{32}$/),
|
||||
const fallbackScoped = createDiagnosticTraceContextFromActiveScope({ spanId: CHILD_SPAN_ID });
|
||||
expect(typeof fallbackScoped.traceId).toBe("string");
|
||||
expect(fallbackScoped.traceId).toHaveLength(32);
|
||||
expect(/^[0-9a-f]+$/.test(fallbackScoped.traceId)).toBe(true);
|
||||
expect(fallbackScoped).toEqual({
|
||||
traceId: fallbackScoped.traceId,
|
||||
spanId: CHILD_SPAN_ID,
|
||||
traceFlags: "01",
|
||||
});
|
||||
|
||||
@@ -1004,7 +1004,8 @@ describe("Windows rebuildShellCommandFromSource", () => {
|
||||
platform: "win32",
|
||||
});
|
||||
expect(result.ok).toBe(true);
|
||||
expect(result.command).toEqual(expect.stringMatching(/\S/));
|
||||
expect(typeof result.command).toBe("string");
|
||||
expect(result.command?.trim().length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("rejects Windows commands with unsafe tokens", () => {
|
||||
|
||||
@@ -215,7 +215,7 @@ describe("exec-command-resolution", () => {
|
||||
fs.chmodSync(busybox, 0o755);
|
||||
|
||||
const shellResolution = resolveCommandResolutionFromArgv(["sh", "-lc", "echo hi"]);
|
||||
expect(shellResolution?.execution.resolvedPath).toEqual(expect.stringMatching(/sh$/));
|
||||
expect(shellResolution?.execution.resolvedPath.endsWith("sh")).toBe(true);
|
||||
|
||||
const wrappedResolution = resolveCommandResolutionFromArgv([busybox, "sh", "-lc", "echo hi"]);
|
||||
const evalResult = evaluateExecAllowlist({
|
||||
|
||||
@@ -75,7 +75,10 @@ describe("withExtractedArchiveRoot", () => {
|
||||
onExtracted,
|
||||
});
|
||||
|
||||
expect(withTempDirSpy).toHaveBeenCalledWith("openclaw-plugin-", expect.any(Function));
|
||||
expect(withTempDirSpy).toHaveBeenCalledTimes(1);
|
||||
const withTempDirCall = withTempDirSpy.mock.calls[0];
|
||||
expect(withTempDirCall?.[0]).toBe("openclaw-plugin-");
|
||||
expect(typeof withTempDirCall?.[1]).toBe("function");
|
||||
expect(extractSpy).toHaveBeenCalledOnce();
|
||||
expect(extractSpy.mock.calls[0]?.[0]?.archivePath).toBe(archivePath);
|
||||
expect(resolveRootSpy).toHaveBeenCalledWith(extractDir, {
|
||||
|
||||
@@ -241,7 +241,11 @@ describe("startProxy", () => {
|
||||
expect(mockLogInfo).toHaveBeenCalledWith(
|
||||
"proxy: routing process HTTP traffic through external proxy http://127.0.0.1:3128",
|
||||
);
|
||||
expect(mockLogInfo).not.toHaveBeenCalledWith(expect.stringContaining("user:pass"));
|
||||
expect(
|
||||
mockLogInfo.mock.calls.some((call) =>
|
||||
call.some((value) => typeof value === "string" && value.includes("user:pass")),
|
||||
),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("clears NO_PROXY so internal destinations do not bypass the filtering proxy", async () => {
|
||||
|
||||
@@ -163,13 +163,13 @@ describe("connectApnsHttp2Session", () => {
|
||||
expect(tunnelCall?.targetHost).toBe("api.push.apple.com");
|
||||
expect(tunnelCall?.targetPort).toBe(443);
|
||||
expect(tunnelCall?.timeoutMs).toBe(10_000);
|
||||
expect(connectSpy).toHaveBeenCalledWith("https://api.push.apple.com", {
|
||||
createConnection: expect.any(Function),
|
||||
});
|
||||
expect(connectSpy).toHaveBeenCalledTimes(1);
|
||||
const connectCall = connectSpy.mock.calls.at(-1) as
|
||||
| [string, http2.ClientSessionOptions]
|
||||
| undefined;
|
||||
expect(connectCall?.[0]).toBe("https://api.push.apple.com");
|
||||
const createConnection = connectCall?.[1].createConnection;
|
||||
expect(typeof createConnection).toBe("function");
|
||||
expect(createConnection?.(new URL("https://api.push.apple.com"), {})).toBe(fakeTlsSocket);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import { createSuiteTempRootTracker } from "../test-helpers/temp-dir.js";
|
||||
import { captureEnv } from "../test-utils/env.js";
|
||||
import type { UpdateCheckResult } from "./update-check.js";
|
||||
@@ -226,7 +227,7 @@ describe("update-startup", () => {
|
||||
const { log, parsed } = await runUpdateCheckAndReadState(channel);
|
||||
|
||||
expect(log.info).toHaveBeenCalledWith(
|
||||
expect.stringContaining("update available (latest): v2.0.0"),
|
||||
`update available (latest): v2.0.0 (current v1.0.0). Run: ${formatCliCommand("openclaw update")}`,
|
||||
);
|
||||
expect(parsed.lastNotifiedVersion).toBe("2.0.0");
|
||||
expect(parsed.lastAvailableVersion).toBe("2.0.0");
|
||||
|
||||
Reference in New Issue
Block a user