mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-21 21:56:46 +00:00
test: tighten daemon status assertions
This commit is contained in:
@@ -73,6 +73,10 @@ vi.mock("./status.gather.js", () => ({
|
||||
}));
|
||||
|
||||
describe("printDaemonStatus", () => {
|
||||
function expectMockLineContains(mock: typeof runtime.log, expected: string) {
|
||||
expect(mock.mock.calls.some(([line]) => line.includes(expected))).toBe(true);
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
runtime.log.mockReset();
|
||||
runtime.error.mockReset();
|
||||
@@ -117,12 +121,8 @@ describe("printDaemonStatus", () => {
|
||||
{ json: false },
|
||||
);
|
||||
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Gateway runtime PID does not own the listening port"),
|
||||
);
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining(formatCliCommand("openclaw gateway restart")),
|
||||
);
|
||||
expectMockLineContains(runtime.error, "Gateway runtime PID does not own the listening port");
|
||||
expectMockLineContains(runtime.error, formatCliCommand("openclaw gateway restart"));
|
||||
});
|
||||
|
||||
it("prints probe kind and capability separately", () => {
|
||||
@@ -153,8 +153,8 @@ describe("printDaemonStatus", () => {
|
||||
{ json: false },
|
||||
);
|
||||
|
||||
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Connectivity probe: ok"));
|
||||
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Capability: write-capable"));
|
||||
expectMockLineContains(runtime.log, "Connectivity probe: ok");
|
||||
expectMockLineContains(runtime.log, "Capability: write-capable");
|
||||
});
|
||||
|
||||
it("prints CLI and gateway versions with readable guidance when they differ", () => {
|
||||
@@ -190,17 +190,12 @@ describe("printDaemonStatus", () => {
|
||||
{ json: false },
|
||||
);
|
||||
|
||||
expect(runtime.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining("CLI version: 2026.4.23 (/usr/local/bin/openclaw)"),
|
||||
);
|
||||
expect(runtime.log).toHaveBeenCalledWith(expect.stringContaining("Gateway version: 2026.5.6"));
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("this OpenClaw command is version 2026.4.23"),
|
||||
);
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining(
|
||||
"if this mismatch is unexpected, update PATH so `openclaw` points to the version you want",
|
||||
),
|
||||
expectMockLineContains(runtime.log, "CLI version: 2026.4.23 (/usr/local/bin/openclaw)");
|
||||
expectMockLineContains(runtime.log, "Gateway version: 2026.5.6");
|
||||
expectMockLineContains(runtime.error, "this OpenClaw command is version 2026.4.23");
|
||||
expectMockLineContains(
|
||||
runtime.error,
|
||||
"if this mismatch is unexpected, update PATH so `openclaw` points to the version you want",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -231,12 +226,8 @@ describe("printDaemonStatus", () => {
|
||||
{ json: false },
|
||||
);
|
||||
|
||||
expect(runtime.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining("Recent restart handoff: full-process via launchd"),
|
||||
);
|
||||
expect(runtime.log).toHaveBeenCalledWith(
|
||||
expect.stringContaining("reason=plugin source changed"),
|
||||
);
|
||||
expectMockLineContains(runtime.log, "Recent restart handoff: full-process via launchd");
|
||||
expectMockLineContains(runtime.log, "reason=plugin source changed");
|
||||
});
|
||||
|
||||
it("passes daemon TLS state to dashboard link rendering", () => {
|
||||
@@ -321,9 +312,7 @@ describe("printDaemonStatus", () => {
|
||||
{ json: false },
|
||||
);
|
||||
|
||||
expect(runtime.error).toHaveBeenCalledWith(expect.stringContaining("Config warnings:"));
|
||||
expect(runtime.error).toHaveBeenCalledWith(
|
||||
expect.stringContaining("without channelConfigs metadata"),
|
||||
);
|
||||
expectMockLineContains(runtime.error, "Config warnings:");
|
||||
expectMockLineContains(runtime.error, "without channelConfigs metadata");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user