Skip to content

test: cover session CLI and review row geometry#317

Open
benvinegar wants to merge 1 commit into
mainfrom
test/coverage-behavior-preservation
Open

test: cover session CLI and review row geometry#317
benvinegar wants to merge 1 commit into
mainfrom
test/coverage-behavior-preservation

Conversation

@benvinegar
Copy link
Copy Markdown
Member

Summary

  • Add coverage for Hunk session CLI HTTP request mapping, daemon error handling, and human-readable formatter output.
  • Add planned review row geometry tests for hidden hunk headers, collapsed gaps, inline notes, and guide caps.
  • Add CLI error formatting tests for expected user errors, debug stacks, and non-error thrown values.

Tests

  • bun run format:check
  • bun run typecheck
  • bun run lint
  • bun test --coverage --coverage-reporter=lcov --reporter=dots ./src ./packages ./scripts ./test/cli ./test/session

This PR description was generated by Pi using OpenAI GPT-5 Codex

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 15, 2026

Greptile Summary

This PR adds test coverage for three areas: the Hunk session CLI HTTP request mapping and formatter output, CLI error formatting, and planned review row geometry calculations. The tests are new files only — no production code is modified.

  • src/core/errors.test.ts: Covers formatCliError for HunkUserError (with and without details), generic Error (with HUNK_DEBUG toggling), and non-Error thrown values. Env-var state is correctly captured and restored in afterEach.
  • src/hunk-session/cli.test.ts: Exercises all HttpHunkSessionCliClient methods against a globalThis.fetch mock, verifies the exact request envelope sent to the daemon (including that CLI-only fields like output and confirmed are stripped), and covers all human-readable formatter functions with snapshot assertions.
  • src/ui/diff/plannedReviewRows.test.ts: Tests plannedReviewRowHeight, plannedReviewRowVisible, and measurePlannedSectionGeometry for hidden hunk headers, collapsed-gap exclusion from hunk bounds, inline-note height contribution, and guide-cap boundary tracking.

Confidence Score: 5/5

Test-only addition with no changes to production code; safe to merge.

All three new test files accurately reflect the production implementations they cover. Fetch and env-var state is properly isolated between tests. The geometry assertions in plannedReviewRows.test.ts were manually verified against the measurePlannedSectionGeometry walk and match exactly. No production logic was modified.

No files require special attention.

Important Files Changed

Filename Overview
src/core/errors.test.ts New test file covering formatCliError; env-var cleanup is correct and test logic matches the implementation.
src/hunk-session/cli.test.ts New test file covering the HTTP client and all formatter functions; request-envelope snapshot is thorough and correctly excludes CLI-only fields from the daemon payload.
src/ui/diff/plannedReviewRows.test.ts New test file covering planned row geometry; hunk-bounds derivations (collapsed gap exclusion, hidden headers, inline-note contribution) match the implementation logic.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[cli.test.ts] -->|mocks globalThis.fetch| B[HttpHunkSessionCliClient]
    B -->|POST /session-api| C[Daemon request envelope]
    B -->|GET /session-api/capabilities| D[readHunkSessionDaemonCapabilities]
    C --> E{action}
    E --> F[list / get / context / review]
    E --> G[navigate / reload]
    E --> H[comment-add / apply / list / rm / clear]
    A -->|asserts exact request bodies| C
    A -->|asserts formatted strings| I[Formatter functions]
    M[errors.test.ts] -->|sets HUNK_DEBUG| N[formatCliError]
    N --> O{error type}
    O -->|HunkUserError| P[hunk: message + details]
    O -->|Error + DEBUG=1| Q[full stack trace]
    O -->|Error, no debug| R[hunk: message]
    O -->|non-Error| S[hunk: String value]
    T[plannedReviewRows.test.ts] --> V[measurePlannedSectionGeometry]
    V --> W{row kind}
    W -->|hunk-header, showHunkHeaders=false| X[height=0, anchor still set]
    W -->|collapsed diff-row| Y[bodyHeight++, hunkBounds unchanged]
    W -->|inline-note / note-guide-cap| Z[height>0, extends hunkBounds]
Loading

Reviews (1): Last reviewed commit: "test: cover session CLI and review row g..." | Re-trigger Greptile

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