Skip to content

test(codex): add unit coverage for JSONL event parser helpers#1049

Merged
aaight merged 1 commit intodevfrom
feature/codex-jsonl-parser-unit-tests
Mar 25, 2026
Merged

test(codex): add unit coverage for JSONL event parser helpers#1049
aaight merged 1 commit intodevfrom
feature/codex-jsonl-parser-unit-tests

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 25, 2026

Summary

  • Adds a new tests/unit/backends/codex-jsonlParser.test.ts with 56 tests covering all pure helper functions in src/backends/codex/jsonlParser.ts
  • Extends tests/unit/backends/codex.test.ts with 8 additional extractToolCall Responses API cases including malformed argument payloads
  • All 125 tests pass; lint and typecheck clean

What was tested

New codex-jsonlParser.test.ts covers:

  • extractTextFromContentParts — array/non-array input, string items, type-filtered objects, mixed arrays, whitespace-only text, no-type objects
  • extractItemTextagent_message, message/content, command_execution, function_call, null/non-object inputs
  • extractDeltaText — plain string delta, text_delta objects, empty/whitespace, null, non-text delta objects, arrays
  • parseFunctionCallItem — string arguments, malformed JSON arguments, object arguments, command_execution items, no-command guard, empty name guard, complex nested arguments
  • resolveUsageRecord — flat event.usage, event.token_usage, nested response.usage (Responses API), priority ordering, missing usage, non-object response.usage
  • parseCodexEvent — full integration: text events, tool_use, turn.completed, response.completed, agent_message, function_call with malformed args, command_execution, item.delta, error events, unrecognized events, mixed content arrays, cost_usd, camelCase usage fields

Extended codex.test.ts extractToolCall cases:

  • item.completed with non-function_call item type returns null
  • Malformed JSON arguments in item.completed function_call
  • item.completed function_call with object (non-string) arguments
  • item.completed with no item field returns null
  • item.completed with null item returns null
  • tool_name without tool_input (input is undefined)

Trello card

https://trello.com/c/69c3e0f9853cbbb3920a0e0f

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Thorough unit test coverage for all exported helpers in jsonlParser.ts. Tests accurately reflect the source implementation (traced every expectation against the source), edge cases are well-chosen (malformed JSON, null/undefined inputs, whitespace-only strings, priority ordering in resolveUsageRecord), and the new extractToolCall cases in codex.test.ts fill real gaps (malformed args, null items, object arguments). All CI checks pass.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit 9020083 into dev Mar 25, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants