git-stats: an e2e suite that would actually notice the card breaking - #29
Merged
Conversation
The 90 unit tests cover pure functions. Nothing exercised the card rendering against OpenCode's sidebar API — which is precisely the surface that has broken twice while those stayed green, most recently a chip that looked clickable and was not. test/e2e boots the real OpenCode TUI in a pty with the built plugin, against a real git repo and a real `gh`, and asserts on the pyte-composed screen and the raw terminal bytes: - the figures match what git itself reports for the fixture (+3 tracked lines and a 2-line untracked file render as "+5 -0 · 2 files", untracked counted as all-additions the way OpenCode's vcs.status does) - a clean tree says "working tree clean" - the chip renders "#20 Merged" once gh answers, painted 48;2;130;80;223 - a scripted SGR mouse click on the chip opens the pull request (asserted against a stub `open` first on PATH, whose recorded argv must equal the PR URL exactly) - a click on the × dismisses the chip and opens nothing - a logged-out gh degrades to "#20 …" with the reason on the card The click coordinates are found by parsing the cursor-position escape before the chip's own run in the raw capture, not hardcoded, so the tests survive the card moving. Checked against a broken plugin, because a rendering suite that passes on one is worse than no suite: deleting the two onMouseDown handlers fails the click test (expected the URL, got []), and changing the merged colour to #ff0000 fails the colour test. Both restored. Opt-in behind GIT_STATS_E2E=1 — it needs an authenticated gh and takes ~4 minutes. Plain `bun test` skips it and still runs in 3 seconds, so CI is unchanged.
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.
The 90 unit tests cover pure functions. Nothing exercised the card rendering against
OpenCode's sidebar API — precisely the surface that has broken twice while those
stayed green, most recently a chip that looked clickable and was not.
test/e2eboots the real OpenCode TUI in a pty with the built plugin, against a realgit repo and a real
gh, and asserts on the pyte-composed screen and the raw terminalbytes:
+3tracked lines + a 2-line untracked file →+5 -0 · 2 filesworking tree clean#20 Mergedonceghanswers48;2;130;80;223openonPATHrecords exactly the PR URL×openrecords nothingghlogged out#20 …andgh: run `gh auth login`Click coordinates are found by parsing the cursor-position escape before the chip's
own run in the raw capture, not hardcoded, so the tests survive the card moving.
Checked against a broken plugin
A rendering suite that passes on a broken plugin is worse than none, so both halves
were verified by sabotage:
onMouseDownhandlers → the click test fails (expected [PR_URL], received [])#ff0000→ the colour test failsBoth restored; full suite green afterwards.
Cost
Opt-in behind
GIT_STATS_E2E=1— it needs an authenticatedghand takes ~4 minutes.Plain
bun testskips it and still finishes in 3 seconds, so CI is unchanged.