Skip to content

test: cover ui.py rendering helpers and slash menu - #86

Draft
aryansk wants to merge 3 commits into
shauryagangrade:mainfrom
aryansk:test/ui-helpers
Draft

test: cover ui.py rendering helpers and slash menu#86
aryansk wants to merge 3 commits into
shauryagangrade:mainfrom
aryansk:test/ui-helpers

Conversation

@aryansk

@aryansk aryansk commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Closes #60.

Change

Expanded tests/test_ui.py from a single goodbye test to full coverage of the pure display logic:

  • _truncate: short text unchanged, whitespace normalization, limit boundary (exact limit has no ellipsis, over-limit appends ), empty string, non-string input.
  • _summarize_tool: execute_bash command branch, path branch, non-string path → empty, path wins over other args, empty args, long-value truncation.
  • _show_slash_menu: command extraction with a mocked questionary — selection returns the command, cancel (None) returns empty, KeyboardInterrupt returns empty; asserts the choices are derived from the slash-command table.
  • Streaming refresh handler: token()/assistant_start()/assistant_end() against a fake Live — no update below the 80-char threshold, one Markdown update on crossing it, final render + stop on end.
  • tool_start: renders the tool name and summarized args via a recorded console.

Acceptance criteria

  • Helpers and the menu are covered; the goodbye snapshot test still passes.
  • _truncate/_summarize_tool are exercised exhaustively (all branches).

Validation

  • tests/test_ui.py: 18 passed (17 new).
  • Full suite: 124 passed (17 new).
  • ruff check . clean, ruff format --check . clean, mypy gcode clean, bandit clean, git diff --check clean.

The test job already runs coverage and uploads .coverage artifacts, but no
one aggregates or publishes the numbers. Emit coverage.xml in the test job
and upload it with codecov/codecov-action (fail_ci_if_error: false so CI
stays green until the Codecov token or app is configured), gitignore the
generated file, and add the Codecov badge to the README next to the build
badge. Fixes shauryagangrade#64.
CI enforces ruff check/format and mypy, but there was no local hook, so
contributors only learned about violations after pushing. Add a
.pre-commit-config.yaml with local hooks that run the exact CI commands
(uv run ruff check ., uv run ruff format --check ., uv run mypy gcode),
add pre-commit to the dev extras, and document the one-line install in
CONTRIBUTING. Fixes shauryagangrade#58.
Add unit coverage for _truncate (whitespace normalization, limit
boundary, ellipsis), _summarize_tool (execute_bash/path/other-args
branches), the /-menu command extraction with a mocked questionary
(selection, cancel, KeyboardInterrupt), the streaming refresh handler
against a fake Live, and tool_start rendering. Fixes shauryagangrade#60.
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.

[Testing]: Unit tests for gcode/ui.py rendering helpers

1 participant