mirror of https://github.com/openclaw/openclaw.git
fix: tighten runtime status detail coverage
This commit is contained in:
parent
70489cbed0
commit
6ad2f793af
|
|
@ -18,6 +18,16 @@ describe("formatRuntimeStatusWithDetails", () => {
|
|||
).toBe("running (pid 1234, state sleeping, healthy, port 18789)");
|
||||
});
|
||||
|
||||
it("trims distinct state and detail text before formatting", () => {
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
status: "running",
|
||||
state: " sleeping ",
|
||||
details: [" healthy ", " port 18789 "],
|
||||
}),
|
||||
).toBe("running (state sleeping, healthy, port 18789)");
|
||||
});
|
||||
|
||||
it("omits duplicate state text and falsy pid values", () => {
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
|
|
@ -35,4 +45,14 @@ describe("formatRuntimeStatusWithDetails", () => {
|
|||
}),
|
||||
).toBe("RUNNING");
|
||||
});
|
||||
|
||||
it("drops whitespace-only state and detail entries", () => {
|
||||
expect(
|
||||
formatRuntimeStatusWithDetails({
|
||||
status: "running",
|
||||
state: " ",
|
||||
details: ["", " "],
|
||||
}),
|
||||
).toBe("running");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@ export function formatRuntimeStatusWithDetails({
|
|||
if (pid) {
|
||||
fullDetails.push(`pid ${pid}`);
|
||||
}
|
||||
if (state && state.toLowerCase() !== runtimeStatus.toLowerCase()) {
|
||||
fullDetails.push(`state ${state}`);
|
||||
const normalizedState = state?.trim();
|
||||
if (normalizedState && normalizedState.toLowerCase() !== runtimeStatus.toLowerCase()) {
|
||||
fullDetails.push(`state ${normalizedState}`);
|
||||
}
|
||||
for (const detail of details) {
|
||||
if (detail) {
|
||||
fullDetails.push(detail);
|
||||
const normalizedDetail = detail.trim();
|
||||
if (normalizedDetail) {
|
||||
fullDetails.push(normalizedDetail);
|
||||
}
|
||||
}
|
||||
return fullDetails.length > 0 ? `${runtimeStatus} (${fullDetails.join(", ")})` : runtimeStatus;
|
||||
|
|
|
|||
Loading…
Reference in New Issue