perf(test): consolidate auth/pty/health mini suites

This commit is contained in:
Peter Steinberger
2026-02-16 01:12:21 +00:00
parent f142048293
commit ea07d3fdd8
8 changed files with 74 additions and 75 deletions

View File

@@ -1,34 +0,0 @@
import { describe, expect, it } from "vitest";
import { stripAnsi } from "../terminal/ansi.js";
import { formatHealthCheckFailure } from "./health-format.js";
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/.openclaw-dev/openclaw.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/.openclaw-dev/openclaw.json",
" Bind: loopback",
].join("\n"),
);
});
});

View File

@@ -1,5 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { HealthSummary } from "./health.js";
import { stripAnsi } from "../terminal/ansi.js";
import { formatHealthCheckFailure } from "./health-format.js";
import { formatHealthChannelLines, healthCommand } from "./health.js";
const runtime = {
@@ -173,3 +175,34 @@ describe("healthCommand", () => {
);
});
});
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/.openclaw-dev/openclaw.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/.openclaw-dev/openclaw.json",
" Bind: loopback",
].join("\n"),
);
});
});