mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 22:10:42 +00:00
test: tighten object shape assertions
This commit is contained in:
@@ -156,7 +156,7 @@ describe("AgentRuntimePlan", () => {
|
||||
|
||||
expect(normalized).toHaveLength(1);
|
||||
expect(normalized[0]?.name).toBe("ping");
|
||||
expect(normalized[0]?.parameters).toBeTypeOf("object");
|
||||
expect(normalized[0]?.parameters).toStrictEqual({});
|
||||
});
|
||||
|
||||
it("does not forward OpenAI API-key profiles into the Codex harness auth slot", () => {
|
||||
|
||||
@@ -20,6 +20,15 @@ function createRuntime(): RuntimeEnv {
|
||||
} as unknown as RuntimeEnv;
|
||||
}
|
||||
|
||||
const zeroTaskAuditCounts = {
|
||||
delivery_failed: 0,
|
||||
inconsistent_timestamps: 0,
|
||||
lost: 0,
|
||||
missing_cleanup: 0,
|
||||
stale_queued: 0,
|
||||
stale_running: 0,
|
||||
};
|
||||
|
||||
async function withTaskCommandStateDir(run: () => Promise<void>): Promise<void> {
|
||||
await withOpenClawTestState(
|
||||
{ layout: "state-only", prefix: "openclaw-tasks-command-" },
|
||||
@@ -150,11 +159,9 @@ describe("tasks commands", () => {
|
||||
|
||||
expect(payload.mode).toBe("preview");
|
||||
expect(payload.maintenance.taskFlows.pruned).toBe(1);
|
||||
expect(payload.auditBefore.byCode).toBeTypeOf("object");
|
||||
expect(Array.isArray(payload.auditBefore.byCode)).toBe(false);
|
||||
expect(payload.auditBefore.byCode).toStrictEqual(zeroTaskAuditCounts);
|
||||
expect(payload.auditBefore.taskFlows.byCode.stale_running).toBe(0);
|
||||
expect(payload.auditAfter.byCode).toBeTypeOf("object");
|
||||
expect(Array.isArray(payload.auditAfter.byCode)).toBe(false);
|
||||
expect(payload.auditAfter.byCode).toStrictEqual(zeroTaskAuditCounts);
|
||||
expect(payload.auditAfter.taskFlows.byCode.stale_running).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -128,8 +128,10 @@ describe("CronService read ops while job is running", () => {
|
||||
await isolatedRun.runStarted;
|
||||
expect(isolatedRun.runIsolatedAgentJob).toHaveBeenCalledTimes(1);
|
||||
|
||||
await expect(cron.list({ includeDisabled: true })).resolves.toBeTypeOf("object");
|
||||
await expect(cron.status()).resolves.toBeTypeOf("object");
|
||||
await expect(cron.list({ includeDisabled: true })).resolves.toHaveLength(1);
|
||||
await expect(cron.status()).resolves.toEqual(
|
||||
expect.objectContaining({ enabled: true, storePath: store.storePath }),
|
||||
);
|
||||
|
||||
const running = await cron.list({ includeDisabled: true });
|
||||
expect(running[0]?.state.runningAtMs).toBeTypeOf("number");
|
||||
@@ -197,7 +199,7 @@ describe("CronService read ops while job is running", () => {
|
||||
|
||||
await expect(
|
||||
withTimeout(cron.list({ includeDisabled: true }), 300, "cron.list during cron.run"),
|
||||
).resolves.toBeTypeOf("object");
|
||||
).resolves.toHaveLength(1);
|
||||
await expect(withTimeout(cron.status(), 300, "cron.status during cron.run")).resolves.toEqual(
|
||||
expect.objectContaining({ enabled: true, storePath: store.storePath }),
|
||||
);
|
||||
@@ -258,7 +260,7 @@ describe("CronService read ops while job is running", () => {
|
||||
|
||||
await expect(
|
||||
withTimeout(cron.list({ includeDisabled: true }), 300, "cron.list during startup"),
|
||||
).resolves.toBeTypeOf("object");
|
||||
).resolves.toHaveLength(1);
|
||||
await expect(withTimeout(cron.status(), 300, "cron.status during startup")).resolves.toEqual(
|
||||
expect.objectContaining({ enabled: true, storePath: store.storePath }),
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { StreamFn } from "@mariozechner/pi-agent-core";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { VERSION } from "../version.js";
|
||||
import {
|
||||
composeProviderStreamWrappers as composeProviderStreamWrappersShared,
|
||||
createMoonshotThinkingWrapper as createMoonshotThinkingWrapperShared,
|
||||
@@ -239,8 +240,11 @@ describe("buildProviderStreamFamilyHooks", () => {
|
||||
config: { thinkingConfig: { thinkingBudget: -1 } },
|
||||
service_tier: "flex",
|
||||
});
|
||||
expect(capturedHeaders).toBeTypeOf("object");
|
||||
expect(capturedHeaders).not.toBeNull();
|
||||
expect(capturedHeaders).toEqual({
|
||||
"User-Agent": `openclaw/${VERSION}`,
|
||||
originator: "openclaw",
|
||||
version: VERSION,
|
||||
});
|
||||
|
||||
const openRouterHooks = OPENROUTER_THINKING_STREAM_HOOKS;
|
||||
void requireStreamFn(
|
||||
|
||||
Reference in New Issue
Block a user