test: verify schema and timing messages

This commit is contained in:
Shakker
2026-05-11 17:18:19 +01:00
parent 8f79e34cbe
commit d4f3d4edad
6 changed files with 11 additions and 10 deletions

View File

@@ -84,7 +84,7 @@ describe("CronService - session reaper runs in finally block (#31946)", () => {
expect(state.running).toBe(false);
// The timer must be re-armed.
expect(state.timer).toEqual(expect.anything());
expect(state.timer).not.toBeNull();
});
});

View File

@@ -1,4 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { VERSION } from "../version.js";
const { fetchWithSsrFGuardMock, shouldUseEnvHttpProxyForUrlMock } = vi.hoisted(() => ({
fetchWithSsrFGuardMock: vi.fn(),
@@ -200,9 +201,9 @@ describe("resolveProviderHttpRequestConfig", () => {
expect(resolved.allowPrivateNetwork).toBe(false);
expect(resolved.headers.get("authorization")).toBe("Bearer override");
expect(resolved.headers.get("x-default")).toBe("1");
expect(resolved.headers.get("user-agent")).toMatch(/^openclaw\//);
expect(resolved.headers.get("user-agent")).toBe(`openclaw/${VERSION}`);
expect(resolved.headers.get("originator")).toBe("openclaw");
expect(resolved.headers.get("version")).toEqual(expect.stringMatching(/\S/u));
expect(resolved.headers.get("version")).toBe(VERSION);
});
it("uses the fallback base URL without enabling private-network access", () => {

View File

@@ -335,7 +335,8 @@ describe("resolveBundledPluginsDir", () => {
expect(resolveSourceCheckoutDependencyDiagnostic()).toEqual({
source: repoRoot,
message: expect.stringContaining("run `pnpm install`"),
message:
"OpenClaw source checkout detected without pnpm workspace dependencies; run `pnpm install` from the repo root so bundled plugins can load package-local dependencies.",
});
process.env.OPENCLAW_DISABLE_BUNDLED_PLUGINS = "1";

View File

@@ -107,7 +107,7 @@ describe("before_agent_reply hook runner (claiming pattern)", () => {
expect(result).toEqual({ handled: true, reply: { text: "ok" } });
expect(logger.error).toHaveBeenCalledWith(
expect.stringContaining("before_agent_reply handler from test-plugin failed: boom"),
"[hooks] before_agent_reply handler from test-plugin failed: boom",
);
});

View File

@@ -28,7 +28,7 @@ function expectIssueMessageIncludes(
issue: ReturnType<typeof expectValidationIssue>,
fragments: readonly string[],
) {
expect(issue.message).toEqual(expect.stringContaining(fragments[0] ?? ""));
expect(issue.message).toContain(fragments[0] ?? "");
fragments.slice(1).forEach((fragment) => {
expect(issue.message).toContain(fragment);
});

View File

@@ -1,4 +1,4 @@
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { afterEach, describe, expect, it } from "vitest";
@@ -118,13 +118,12 @@ describe("check-cli-bootstrap-imports", () => {
it("reports oversized gateway run chunks", () => {
const root = makeTempRoot();
writeGatewayRunChunk(root, "x".repeat(10));
const gatewayRunChunkBytes = statSync(join(root, "dist", "run-gateway.js")).size;
expect(
collectGatewayRunChunkBudgetErrors({ rootDir: root, gatewayRunChunkMaxBytes: 50 }),
).toEqual([
expect.stringMatching(
/^Gateway run chunk dist\/run-gateway\.js is \d+ bytes, above budget 50 bytes\.$/,
),
`Gateway run chunk dist/run-gateway.js is ${gatewayRunChunkBytes} bytes, above budget 50 bytes.`,
]);
});
});