test: tighten doctor helper assertions · openclaw/openclaw@c6f7e63
steipete
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -295,12 +295,12 @@ describe("maybeRepairGatewayDaemon", () => {
|
295 | 295 | healthOk: false, |
296 | 296 | }); |
297 | 297 | |
298 | | -expect(readGatewayRestartHandoffSync).toHaveBeenCalledWith( |
299 | | - expect.objectContaining({ |
300 | | - OPENCLAW_STATE_DIR: "/tmp/openclaw-service", |
301 | | - OPENCLAW_CONFIG_PATH: "/tmp/openclaw-service/openclaw.json", |
302 | | - }), |
303 | | -); |
| 298 | +expect(readGatewayRestartHandoffSync).toHaveBeenCalledOnce(); |
| 299 | +const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls[0] as unknown as [ |
| 300 | +{ OPENCLAW_STATE_DIR?: string; OPENCLAW_CONFIG_PATH?: string }, |
| 301 | +]; |
| 302 | +expect(handoffEnv?.OPENCLAW_STATE_DIR).toBe("/tmp/openclaw-service"); |
| 303 | +expect(handoffEnv?.OPENCLAW_CONFIG_PATH).toBe("/tmp/openclaw-service/openclaw.json"); |
304 | 304 | expect(note).toHaveBeenCalledWith( |
305 | 305 | expect.stringContaining("Recent restart handoff: full-process via systemd"), |
306 | 306 | "Gateway", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,7 +15,12 @@ vi.mock("../terminal/note.js", () => ({
|
15 | 15 | import { noteSessionLockHealth } from "./doctor-session-locks.js"; |
16 | 16 | |
17 | 17 | async function expectPathMissing(targetPath: string): Promise<void> { |
18 | | -await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" }); |
| 18 | +try { |
| 19 | +await fs.access(targetPath); |
| 20 | +throw new Error(`expected missing path: ${targetPath}`); |
| 21 | +} catch (error) { |
| 22 | +expect((error as NodeJS.ErrnoException).code).toBe("ENOENT"); |
| 23 | +} |
19 | 24 | } |
20 | 25 | |
21 | 26 | describe("noteSessionLockHealth", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -90,12 +90,10 @@ describe("doctor session transcript repair", () => {
|
90 | 90 | |
91 | 91 | const result = await repairBrokenSessionTranscriptFile({ filePath, shouldRepair: true }); |
92 | 92 | |
93 | | -expect(result).toMatchObject({ |
94 | | -broken: true, |
95 | | -repaired: true, |
96 | | -originalEntries: 6, |
97 | | -activeEntries: 3, |
98 | | -}); |
| 93 | +expect(result.broken).toBe(true); |
| 94 | +expect(result.repaired).toBe(true); |
| 95 | +expect(result.originalEntries).toBe(6); |
| 96 | +expect(result.activeEntries).toBe(3); |
99 | 97 | if (result.backupPath === undefined) { |
100 | 98 | throw new Error("expected transcript backup path"); |
101 | 99 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -82,8 +82,7 @@ describe("doctor empty allowlist policy scan", () => {
|
82 | 82 | |
83 | 83 | expect(warnings).toEqual(["extra:channels.signal"]); |
84 | 84 | expect(extraWarningsForAccount).toHaveBeenCalledTimes(1); |
85 | | -expect(extraWarningsForAccount).toHaveBeenCalledWith( |
86 | | -expect.objectContaining({ prefix: "channels.signal" }), |
87 | | -); |
| 85 | +const [warningOptions] = extraWarningsForAccount.mock.calls[0] ?? []; |
| 86 | +expect(warningOptions?.prefix).toBe("channels.signal"); |
88 | 87 | }); |
89 | 88 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -211,9 +211,9 @@ describe("doctor preview warnings", () => {
|
211 | 211 | warning.includes("Telegram allowFrom contains 1") && warning.includes("(e.g. @alice)"), |
212 | 212 | ), |
213 | 213 | ).toBe(true); |
214 | | -expect(warnings).toEqual( |
215 | | -expect.arrayContaining([expect.stringContaining('channels.signal.allowFrom: set to ["*"]')]), |
216 | | -); |
| 214 | +expect( |
| 215 | +warnings.some((warning) => warning.includes('channels.signal.allowFrom: set to ["*"]')), |
| 216 | +).toBe(true); |
217 | 217 | }); |
218 | 218 | |
219 | 219 | it("sanitizes empty-allowlist warning paths before returning preview output", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。