test: cover ui.py rendering helpers and slash menu - #86
Draft
aryansk wants to merge 3 commits into
Draft
Conversation
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.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #60.
Change
Expanded
tests/test_ui.pyfrom 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_bashcommand branch,pathbranch, non-string path → empty, path wins over other args, empty args, long-value truncation._show_slash_menu: command extraction with a mockedquestionary— selection returns the command, cancel (None) returns empty,KeyboardInterruptreturns empty; asserts the choices are derived from the slash-command table.token()/assistant_start()/assistant_end()against a fakeLive— 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
_truncate/_summarize_toolare exercised exhaustively (all branches).Validation
tests/test_ui.py: 18 passed (17 new).ruff check .clean,ruff format --check .clean,mypy gcodeclean,banditclean,git diff --checkclean.