test: push coverage to 90%+ on lines for all files except execute.ts (FAR-85)

Overall before: 80.36% lines / 79.06% statements
Overall after:  94.65% lines / 93.30% statements

Per-file lines coverage (all targets ≥90% except execute.ts):

| File              | Before | After  |
|-------------------|--------|--------|
| ui-parser.ts      | 93.63% | 99.09% |
| cli/format-event  | 59.85% | 99.27% |
| server/execute    | 81.47% | 89.64% |
| server/job-mfst   | 90.30% | 98.78% |
| server/k8s-client | 37.50% | 95.83% |
| server/log-dedup  | 97.77% | 97.77% |
| server/parse      | 89.85% | 98.55% |
| server/skills     | 100%   | 100%   |

New tests added:

- k8s-client.test.ts: getSelfPodInfo (env-var inheritance, secret volumes,
  PVC discovery, dnsConfig, all error paths) + kubeconfig file branch
- format-event.test.ts: parseStdoutLine (cli) — full event-type matrix,
  tool_use status branches, errorText fallback paths
- ui-parser.test.ts: errorText edge cases, empty event paths
- parse.test.ts: errorText fallback to data.message, name, code, JSON
- job-manifest.test.ts: workspace context env wiring, linkedIssueIds,
  paperclipWorkspaces/RuntimeServices JSON, authToken, inherited URLs,
  prompt-secret + data PVC + secret-volume mount paths
- execute.test.ts: parseModelProvider, completionWithGrace,
  instructionsFilePath read failure, ensureAgentDbPvc throw paths,
  large-prompt secret create failure, step-limit detection,
  waitForPod no-pod messaging, init-container ImagePullBackOff /
  CrashLoopBackOff, main-container CrashLoopBackOff, all-inits-done
  happy path, skill bundle source loading (SKILL.md + flat-file
  fallback), SIGTERM handler full body via vi.resetModules()

execute.ts remains at 89.64% lines — the residual gap is deep async/timer
paths inside streamAndAwaitJob (grace poller, keepalive ticker, log-stream
stop-signal/bail timer). Those need fake-timer scaffolding heavier than
this batch warrants; tracking separately.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 22:27:04 +00:00
committed by Hugh Commit [agent]
parent 693016d1ab
commit 798b80f2f2
8 changed files with 897 additions and 5 deletions
+42
View File
@@ -182,3 +182,45 @@ describe("isOpenCodeUnknownSessionError", () => {
expect(isOpenCodeUnknownSessionError(stdout, "")).toBe(true);
});
});
describe("parseOpenCodeJsonl — errorText fallback paths", () => {
it("uses nested data.message when top-level message is missing", () => {
const stdout = JSON.stringify({
type: "error",
error: { data: { message: "nested issue" } },
sessionID: "ses_x",
});
const result = parseOpenCodeJsonl(stdout);
expect(result.errorMessage).toContain("nested issue");
});
it("uses error.name when no message or nested message", () => {
const stdout = JSON.stringify({
type: "error",
error: { name: "ProviderAuthError" },
sessionID: "ses_x",
});
const result = parseOpenCodeJsonl(stdout);
expect(result.errorMessage).toContain("ProviderAuthError");
});
it("uses error.code when no message/name", () => {
const stdout = JSON.stringify({
type: "error",
error: { code: "E_TIMEOUT" },
sessionID: "ses_x",
});
const result = parseOpenCodeJsonl(stdout);
expect(result.errorMessage).toContain("E_TIMEOUT");
});
it("falls back to JSON.stringify of the error object when nothing matches", () => {
const stdout = JSON.stringify({
type: "error",
error: { unexpectedShape: { foo: "bar" } },
sessionID: "ses_x",
});
const result = parseOpenCodeJsonl(stdout);
expect(result.errorMessage).toContain("unexpectedShape");
});
});