harden terminal ui error states
This commit is contained in:
parent
5538f3faa1
commit
7835342cd3
5 changed files with 675 additions and 10 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
countActiveFlowFilterGroups,
|
||||
filterOptionTapeItems,
|
||||
findAnchorRestoreIndex,
|
||||
formatUiErrorMessage,
|
||||
formatCompactUsd,
|
||||
formatOptionContractLabel,
|
||||
flushPausableTapeData,
|
||||
|
|
@ -80,6 +81,25 @@ describe("tape status hardening", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("terminal error message hardening", () => {
|
||||
it("normalizes whitespace and clamps oversized messages before rendering", () => {
|
||||
const longMessage = `API failed\n\n${"x".repeat(320)}`;
|
||||
|
||||
const formatted = formatUiErrorMessage(longMessage);
|
||||
|
||||
expect(formatted).toHaveLength(240);
|
||||
expect(formatted).toStartWith("API failed x");
|
||||
expect(formatted).toEndWith("...");
|
||||
expect(formatted).not.toContain("\n");
|
||||
});
|
||||
|
||||
it("uses a fallback when an error payload is empty", () => {
|
||||
expect(formatUiErrorMessage(" ", "Synthetic status could not be loaded")).toBe(
|
||||
"Synthetic status could not be loaded"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const makeItem = (traceId: string, seq: number, ts: number) => ({
|
||||
trace_id: traceId,
|
||||
seq,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue