test: tighten crestodian assertions · openclaw/openclaw@511d706
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,11 +29,10 @@ describe("Crestodian audit log", () => {
|
29 | 29 | expect(auditPath).toBe(resolveCrestodianAuditPath()); |
30 | 30 | const lines = (await fs.readFile(auditPath, "utf8")).trim().split("\n"); |
31 | 31 | expect(lines).toHaveLength(1); |
32 | | -expect(JSON.parse(lines[0] ?? "{}")).toMatchObject({ |
33 | | -operation: "config.setDefaultModel", |
34 | | -summary: "Set default model to openai/gpt-5.2", |
35 | | -configHashBefore: "before", |
36 | | -configHashAfter: "after", |
37 | | -}); |
| 32 | +const entry = JSON.parse(lines[0] ?? "{}") as Record<string, unknown>; |
| 33 | +expect(entry.operation).toBe("config.setDefaultModel"); |
| 34 | +expect(entry.summary).toBe("Set default model to openai/gpt-5.2"); |
| 35 | +expect(entry.configHashBefore).toBe("before"); |
| 36 | +expect(entry.configHashAfter).toBe("after"); |
38 | 37 | }); |
39 | 38 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,19 +52,15 @@ describe("loadCrestodianOverview", () => {
|
52 | 52 | }, |
53 | 53 | }); |
54 | 54 | |
55 | | -expect(overview.config).toMatchObject({ |
56 | | -exists: true, |
57 | | -valid: true, |
58 | | -}); |
| 55 | +expect(overview.config.exists).toBe(true); |
| 56 | +expect(overview.config.valid).toBe(true); |
59 | 57 | expect(overview.defaultAgentId).toBe("main"); |
60 | 58 | expect(overview.defaultModel).toBe("openai/gpt-5.2"); |
61 | 59 | expect(overview.agents.map((agent) => agent.id)).toEqual(["main", "work"]); |
62 | 60 | expect(overview.tools.codex.found).toBe(true); |
63 | 61 | expect(overview.tools.claude.found).toBe(false); |
64 | | -expect(overview.gateway).toMatchObject({ |
65 | | -url: "ws://127.0.0.1:19001", |
66 | | -reachable: false, |
67 | | -}); |
| 62 | +expect(overview.gateway.url).toBe("ws://127.0.0.1:19001"); |
| 63 | +expect(overview.gateway.reachable).toBe(false); |
68 | 64 | expect(overview.references.docsPath).toMatch(/docs$/); |
69 | 65 | expect(overview.references.sourceUrl).toBe("https://github.com/openclaw/openclaw"); |
70 | 66 | expect(formatCrestodianOverview(overview)).toContain( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -98,11 +98,14 @@ describeLive("Crestodian live rescue channel smoke", () => {
|
98 | 98 | ); |
99 | 99 | |
100 | 100 | const config = JSON.parse(await fs.readFile(configPath, "utf8")) as OpenClawConfig; |
101 | | -expect(config.agents?.defaults?.model).toMatchObject({ primary: "openai/gpt-5.5" }); |
| 101 | +const defaultModel = config.agents?.defaults?.model; |
| 102 | +expect(typeof defaultModel).toBe("object"); |
| 103 | +expect(defaultModel).not.toBeNull(); |
| 104 | +expect((defaultModel as { primary?: unknown }).primary).toBe("openai/gpt-5.5"); |
102 | 105 | const auditPath = path.join(tempDir, "audit", "crestodian.jsonl"); |
103 | 106 | const auditLines = (await fs.readFile(auditPath, "utf8")).trim().split("\n"); |
104 | | -expect(auditLines).toEqual( |
105 | | -expect.arrayContaining([expect.stringContaining('"operation":"config.setDefaultModel"')]), |
| 107 | +expect(auditLines.some((line) => line.includes('"operation":"config.setDefaultModel"'))).toBe( |
| 108 | +true, |
106 | 109 | ); |
107 | 110 | }); |
108 | 111 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -55,13 +55,20 @@ describe("runCrestodianTui", () => {
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | expect(runTuiCalls).toBe(1); |
58 | | -expect(runTuiOptions).toMatchObject({ |
59 | | -local: true, |
60 | | -session: "agent:crestodian:main", |
61 | | -historyLimit: 200, |
62 | | -config: {}, |
63 | | -title: "openclaw crestodian", |
64 | | -}); |
65 | | -expect(runTuiOptions).toMatchObject({ backend: expect.any(Object) }); |
| 58 | +const options = runTuiOptions as { |
| 59 | +local?: boolean; |
| 60 | +session?: string; |
| 61 | +historyLimit?: number; |
| 62 | +config?: unknown; |
| 63 | +title?: string; |
| 64 | +backend?: unknown; |
| 65 | +}; |
| 66 | +expect(options.local).toBe(true); |
| 67 | +expect(options.session).toBe("agent:crestodian:main"); |
| 68 | +expect(options.historyLimit).toBe(200); |
| 69 | +expect(options.config).toEqual({}); |
| 70 | +expect(options.title).toBe("openclaw crestodian"); |
| 71 | +expect(typeof options.backend).toBe("object"); |
| 72 | +expect(options.backend).not.toBeNull(); |
66 | 73 | }); |
67 | 74 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。