feat(cli): colorize gateway health + daemon output
This commit is contained in:
43
src/commands/health-format.test.ts
Normal file
43
src/commands/health-format.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { formatHealthCheckFailure } from "./health-format.js";
|
||||
|
||||
const stripAnsi = (input: string) =>
|
||||
input.replace(
|
||||
// biome-ignore lint/suspicious/noControlCharactersInRegex: strip ANSI escape sequences
|
||||
/\u001b\[[0-9;]*m/g,
|
||||
"",
|
||||
);
|
||||
|
||||
describe("formatHealthCheckFailure", () => {
|
||||
it("keeps non-rich output stable", () => {
|
||||
const err = new Error(
|
||||
"gateway closed (1006 abnormal closure): no close reason",
|
||||
);
|
||||
expect(formatHealthCheckFailure(err, { rich: false })).toBe(
|
||||
`Health check failed: ${String(err)}`,
|
||||
);
|
||||
});
|
||||
|
||||
it("formats gateway connection details as indented key/value lines", () => {
|
||||
const err = new Error(
|
||||
[
|
||||
"gateway closed (1006 abnormal closure (no close frame)): no close reason",
|
||||
"Gateway target: ws://127.0.0.1:19001",
|
||||
"Source: local loopback",
|
||||
"Config: /Users/steipete/.clawdbot-dev/clawdbot.json",
|
||||
"Bind: loopback",
|
||||
].join("\n"),
|
||||
);
|
||||
|
||||
expect(stripAnsi(formatHealthCheckFailure(err, { rich: true }))).toBe(
|
||||
[
|
||||
"Health check failed: gateway closed (1006 abnormal closure (no close frame)): no close reason",
|
||||
" Gateway target: ws://127.0.0.1:19001",
|
||||
" Source: local loopback",
|
||||
" Config: /Users/steipete/.clawdbot-dev/clawdbot.json",
|
||||
" Bind: loopback",
|
||||
].join("\n"),
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user