test: tighten config validation assertions · openclaw/openclaw@601b705
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -53,10 +53,9 @@ describe("bundled channel config runtime", () => {
|
53 | 53 | "../../test/helpers/config/bundled-channel-config-runtime.js?scope=missing-bundled-list", |
54 | 54 | ); |
55 | 55 | |
56 | | -expect(runtimeModule.getBundledChannelConfigSchemaMap().get("msteams")).toMatchObject({ |
57 | | -schema: { type: "object" }, |
58 | | -runtime: {}, |
59 | | -}); |
| 56 | +const schemaEntry = runtimeModule.getBundledChannelConfigSchemaMap().get("msteams"); |
| 57 | +expect(schemaEntry?.schema).toEqual({ type: "object" }); |
| 58 | +expect(schemaEntry?.runtime).toEqual({}); |
60 | 59 | expect(runtimeModule.getBundledChannelRuntimeMap().get("msteams")).toStrictEqual({}); |
61 | 60 | }); |
62 | 61 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -19,7 +19,13 @@ async function expectRegularFile(filePath: string): Promise<void> {
|
19 | 19 | } |
20 | 20 | |
21 | 21 | async function expectPathMissing(filePath: string): Promise<void> { |
22 | | -await expect(fs.stat(filePath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 22 | +let error: { code?: unknown } | undefined; |
| 23 | +try { |
| 24 | +await fs.stat(filePath); |
| 25 | +} catch (err) { |
| 26 | +error = err as { code?: unknown }; |
| 27 | +} |
| 28 | +expect(error?.code).toBe("ENOENT"); |
23 | 29 | } |
24 | 30 | |
25 | 31 | describe("config backup rotation", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -214,9 +214,9 @@ describe("config schema regressions", () => {
|
214 | 214 | |
215 | 215 | expect(res.ok).toBe(false); |
216 | 216 | if (!res.ok) { |
217 | | -expect(res.issues.map((issue) => issue.path)).toEqual( |
218 | | - expect.arrayContaining(["agents.defaults.pdfMaxBytesMb", "agents.defaults.pdfMaxPages"]), |
219 | | -); |
| 217 | +const issuePaths = res.issues.map((issue) => issue.path); |
| 218 | +expect(issuePaths).toContain("agents.defaults.pdfMaxBytesMb"); |
| 219 | +expect(issuePaths).toContain("agents.defaults.pdfMaxPages"); |
220 | 220 | } |
221 | 221 | }); |
222 | 222 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -27,9 +27,8 @@ describe("ensureControlUiAllowedOriginsForNonLoopbackBind", () => {
|
27 | 27 | ); |
28 | 28 | |
29 | 29 | expect(result.bind).toBe("lan"); |
30 | | -expect(result.seededOrigins).toEqual( |
31 | | -expect.arrayContaining(["http://localhost:18789", "http://127.0.0.1:18789"]), |
32 | | -); |
| 30 | +expect(result.seededOrigins).toContain("http://localhost:18789"); |
| 31 | +expect(result.seededOrigins).toContain("http://127.0.0.1:18789"); |
33 | 32 | }); |
34 | 33 | |
35 | 34 | it("uses runtime loopback before config non-loopback and avoids seeding", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -42,7 +42,7 @@ describe("config io EACCES handling", () => {
|
42 | 42 | expect(snapshot.issues[0].message).toContain("chown"); |
43 | 43 | expect(snapshot.issues[0].message).toContain(configPath); |
44 | 44 | // Should also emit to the logger |
45 | | -expect(errors).toEqual(expect.arrayContaining([expect.stringContaining("chown")])); |
| 45 | +expect(errors.some((message) => message.includes("chown"))).toBe(true); |
46 | 46 | }); |
47 | 47 | |
48 | 48 | it("includes configPath in the chown hint for the correct remediation command", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -78,12 +78,8 @@ describe("session store key normalization", () => {
|
78 | 78 | |
79 | 79 | const store = loadSessionStore(storePath, { skipCache: true }); |
80 | 80 | expect(Object.keys(store)).toEqual([CANONICAL_KEY]); |
81 | | -expect(store[CANONICAL_KEY]).toEqual( |
82 | | -expect.objectContaining({ |
83 | | -lastChannel: "webchat", |
84 | | -lastTo: "webchat:user-1", |
85 | | -}), |
86 | | -); |
| 81 | +expect(store[CANONICAL_KEY]?.lastChannel).toBe("webchat"); |
| 82 | +expect(store[CANONICAL_KEY]?.lastTo).toBe("webchat:user-1"); |
87 | 83 | }); |
88 | 84 | |
89 | 85 | it("migrates legacy mixed-case entries to the canonical key on update", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -147,10 +147,8 @@ describe("talk normalization", () => {
|
147 | 147 | }, |
148 | 148 | }); |
149 | 149 | |
150 | | -expect(payload?.realtime).toMatchObject({ |
151 | | -provider: "openai", |
152 | | -instructions: "Speak with crisp diction.", |
153 | | -}); |
| 150 | +expect(payload?.realtime?.provider).toBe("openai"); |
| 151 | +expect(payload?.realtime?.instructions).toBe("Speak with crisp diction."); |
154 | 152 | }); |
155 | 153 | |
156 | 154 | it("does not report an active provider when the configured speech provider cannot resolve", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,17 +3,16 @@ import { OpenClawSchema } from "./zod-schema.js";
|
3 | 3 | |
4 | 4 | describe("OpenClawSchema cron retention and run-log validation", () => { |
5 | 5 | it("accepts valid cron.sessionRetention and runLog values", () => { |
6 | | -expect( |
7 | | -OpenClawSchema.safeParse({ |
8 | | -cron: { |
9 | | -sessionRetention: "1h30m", |
10 | | -runLog: { |
11 | | -maxBytes: "5mb", |
12 | | -keepLines: 2500, |
13 | | -}, |
| 6 | +const result = OpenClawSchema.safeParse({ |
| 7 | +cron: { |
| 8 | +sessionRetention: "1h30m", |
| 9 | +runLog: { |
| 10 | +maxBytes: "5mb", |
| 11 | +keepLines: 2500, |
14 | 12 | }, |
15 | | -}), |
16 | | -).toMatchObject({ success: true }); |
| 13 | +}, |
| 14 | +}); |
| 15 | +expect(result.success).toBe(true); |
17 | 16 | }); |
18 | 17 | |
19 | 18 | it("rejects invalid cron.sessionRetention", () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。