Skip to content

test: add 18 unit tests for export_report helpers#286

Open
TerminalGravity wants to merge 3 commits intomainfrom
add-export-report-tests
Open

test: add 18 unit tests for export_report helpers#286
TerminalGravity wants to merge 3 commits intomainfrom
add-export-report-tests

Conversation

@TerminalGravity
Copy link
Collaborator

Exports and tests the three pure helper functions in export-report.ts:

  • getDateRange — all 4 periods + unknown period error
  • summarizeEvents — empty arrays, type counting, day grouping, missing timestamps
  • generateMarkdown — metrics table, correction rate quality tiers (excellent/good/needs improvement/poor), commits/errors sections, single vs multi-day activity

Brings total test count from 74 → 92. All green.

Export pure helper functions (estimateTokens, extractText, extractToolNames,
formatTokens, formatCost, formatDuration, analyzeSessionFile) and add
comprehensive tests covering:

- Token estimation (empty, short, long strings)
- Content extraction from string, block arrays, null/undefined
- Tool name extraction from content blocks
- Token/cost/duration formatting with edge cases
- Session file analysis: prompt counting, correction detection,
  tool call counting, preflight detection, timestamp tracking,
  empty files, and malformed JSON resilience

Brings test count from 43 to 74.
Generates session reports from timeline data with:
- Activity overview (events, prompts, commits, errors)
- Prompt quality scoring (correction rate analysis)
- Daily activity breakdown with visual bars
- Event type distribution
- Recent commits and errors
- Optional file output

Closes #5
Export getDateRange, summarizeEvents, generateMarkdown, and EventSummary
from export-report.ts and add comprehensive test coverage:

- getDateRange: all periods + error case
- summarizeEvents: empty, type counting, day grouping, missing timestamps
- generateMarkdown: metrics table, correction rate quality tiers,
  commits/errors sections, daily activity, single vs multi-day

Brings test count from 74 to 92.
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.

1 participant