























@@ -73,6 +73,10 @@ vi.mock("./status.gather.js", () => ({
7373}));
74747575describe("printDaemonStatus", () => {
76+function expectMockLineContains(mock: typeof runtime.log, expected: string) {
77+expect(mock.mock.calls.some(([line]) => line.includes(expected))).toBe(true);
78+}
79+7680beforeEach(() => {
7781runtime.log.mockReset();
7882runtime.error.mockReset();
@@ -117,12 +121,8 @@ describe("printDaemonStatus", () => {
117121{ json: false },
118122);
119123120-expect(runtime.error).toHaveBeenCalledWith(
121-expect.stringContaining("Gateway runtime PID does not own the listening port"),
122-);
123-expect(runtime.error).toHaveBeenCalledWith(
124-expect.stringContaining(formatCliCommand("openclaw gateway restart")),
125-);
124+expectMockLineContains(runtime.error, "Gateway runtime PID does not own the listening port");
125+expectMockLineContains(runtime.error, formatCliCommand("openclaw gateway restart"));
126126});
127127128128it("prints probe kind and capability separately", () => {
@@ -153,8 +153,8 @@ describe("printDaemonStatus", () => {
153153{ json: false },
154154);
155155156-expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Connectivity probe: ok"));
157-expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Capability: write-capable"));
156+expectMockLineContains(runtime.log, "Connectivity probe: ok");
157+expectMockLineContains(runtime.log, "Capability: write-capable");
158158});
159159160160it("prints CLI and gateway versions with readable guidance when they differ", () => {
@@ -190,17 +190,12 @@ describe("printDaemonStatus", () => {
190190{ json: false },
191191);
192192193-expect(runtime.log).toHaveBeenCalledWith(
194-expect.stringContaining("CLI version: 2026.4.23 (/usr/local/bin/openclaw)"),
195-);
196-expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Gateway version: 2026.5.6"));
197-expect(runtime.error).toHaveBeenCalledWith(
198-expect.stringContaining("this OpenClaw command is version 2026.4.23"),
199-);
200-expect(runtime.error).toHaveBeenCalledWith(
201-expect.stringContaining(
202-"if this mismatch is unexpected, update PATH so `openclaw` points to the version you want",
203-),
193+expectMockLineContains(runtime.log, "CLI version: 2026.4.23 (/usr/local/bin/openclaw)");
194+expectMockLineContains(runtime.log, "Gateway version: 2026.5.6");
195+expectMockLineContains(runtime.error, "this OpenClaw command is version 2026.4.23");
196+expectMockLineContains(
197+runtime.error,
198+"if this mismatch is unexpected, update PATH so `openclaw` points to the version you want",
204199);
205200});
206201@@ -231,12 +226,8 @@ describe("printDaemonStatus", () => {
231226{ json: false },
232227);
233228234-expect(runtime.log).toHaveBeenCalledWith(
235-expect.stringContaining("Recent restart handoff: full-process via launchd"),
236-);
237-expect(runtime.log).toHaveBeenCalledWith(
238-expect.stringContaining("reason=plugin source changed"),
239-);
229+expectMockLineContains(runtime.log, "Recent restart handoff: full-process via launchd");
230+expectMockLineContains(runtime.log, "reason=plugin source changed");
240231});
241232242233it("passes daemon TLS state to dashboard link rendering", () => {
@@ -321,9 +312,7 @@ describe("printDaemonStatus", () => {
321312{ json: false },
322313);
323314324-expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("Config warnings:"));
325-expect(runtime.error).toHaveBeenCalledWith(
326-expect.stringContaining("without channelConfigs metadata"),
327-);
315+expectMockLineContains(runtime.error, "Config warnings:");
316+expectMockLineContains(runtime.error, "without channelConfigs metadata");
328317});
329318});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。