test: cover the behaviour that has actually broken #27

Merged
barrettruth merged 4 commits from test/behaviour into main 2026-07-28 00:04:09 +00:00
Owner

Checklist

  • I have read CONTRIBUTING.md.
  • No AI was used to generate, edit, or review any part of this contribution.

Stacked on #26.

Problem

Every existing spec calls a pure function — ansi.line, target.parse,
status.of, log.parse. Nothing opened a buffer. And every bug found by hand
recently was in the untested half: buffer lifecycle, extmarks, navigation.

guh.nvim runs one 863-line spec that drives a real Nvim and makes real gh
calls. Same instinct, cheaper transport: these drive real ci:// buffers with
the gh layer stubbed, so they are deterministic and need no network.

What is covered

Seven cases, each one a regression that actually shipped:

  • the log is kept verbatim, escapes are gone, ##[endgroup] is gone, step
    headers are added
  • no chrome ever reaches the buffer, on success or on failure
  • a skipped job keeps up, url and its title when the log 404s
  • a failed refresh leaves what you were reading
  • gS toggles, and survives a reload without going stale
  • - returns to the list you came from, from both a commit and a pull request
  • - falls back to the commit for a job opened by URL

They assert on behaviour, not appearance. No winbar strings, no colours, no
indent widths — those changed on taste half a dozen times recently and would
have cried wolf every time.

The refresh case failed on the first run

Expected: '2026-07-27T15:14:08.0000000Z ✓ Setup …'
Passed in: ''

A failed refresh was leaving an empty buffer, not the previous text. Nvim
clears a buffer before BufReadCmd runs — which the comment above save_view
has said all along — so by the time the fetch came back there was nothing left
to keep.

The check in #14 called fail() directly and never went through :edit, so it
proved nothing about the real path. That is the whole argument for these tests
in one example.

Fixed by keeping the lines alongside the view already being saved at the same
moment, and restoring them together:

loaded:      lines=2563 cursor=900
failed R:    lines=2563 cursor=900
## Checklist - [x] I have read [CONTRIBUTING.md](https://forge.barrettruth.com/barrettruth/ci.nvim/src/branch/main/CONTRIBUTING.md). - [ ] No AI was used to generate, edit, or review any part of this contribution. > Stacked on #26. ## Problem Every existing spec calls a pure function — `ansi.line`, `target.parse`, `status.of`, `log.parse`. Nothing opened a buffer. And every bug found by hand recently was in the untested half: buffer lifecycle, extmarks, navigation. `guh.nvim` runs one 863-line spec that drives a real Nvim and makes real `gh` calls. Same instinct, cheaper transport: these drive real `ci://` buffers with the `gh` layer stubbed, so they are deterministic and need no network. ## What is covered Seven cases, each one a regression that actually shipped: - the log is kept verbatim, escapes are gone, `##[endgroup]` is gone, step headers are added - no chrome ever reaches the buffer, on success or on failure - a skipped job keeps `up`, `url` and its title when the log 404s - a failed refresh leaves what you were reading - `gS` toggles, and survives a reload without going stale - `-` returns to the list you came from, from both a commit and a pull request - `-` falls back to the commit for a job opened by URL They assert on behaviour, not appearance. No winbar strings, no colours, no indent widths — those changed on taste half a dozen times recently and would have cried wolf every time. ## The refresh case failed on the first run ``` Expected: '2026-07-27T15:14:08.0000000Z ✓ Setup …' Passed in: '' ``` A failed refresh was leaving an **empty buffer**, not the previous text. Nvim clears a buffer before `BufReadCmd` runs — which the comment above `save_view` has said all along — so by the time the fetch came back there was nothing left to keep. The check in #14 called `fail()` directly and never went through `:edit`, so it proved nothing about the real path. That is the whole argument for these tests in one example. Fixed by keeping the lines alongside the view already being saved at the same moment, and restoring them together: ``` loaded: lines=2563 cursor=900 failed R: lines=2563 cursor=900 ```
Every existing spec calls a pure function. Nothing opened a buffer, and every
bug found by hand this month was in the half that had no tests: buffer
lifecycle, extmarks, navigation. So these seven drive real ci:// buffers with
the gh layer stubbed, and each one is a regression that shipped.

The refresh case failed on the first run. A failed refresh was leaving an
empty buffer, not the text you had been reading. Neovim clears a buffer
before BufReadCmd runs, which the comment above save_view has said all along,
so there was nothing left to keep by the time the fetch came back; the
earlier check called fail() directly and never went through :edit at all.

The lines are now kept alongside the view that was already being saved there,
and put back together with it.

They assert on behaviour, not on appearance. No winbar strings, no colours,
no indent widths: those changed on taste half a dozen times this month and
would have cried wolf every time.
barrettruth changed target branch from docs/fix-log-claims to main 2026-07-28 00:04:00 +00:00
barrettruth deleted branch test/behaviour 2026-07-28 00:04:09 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
barrettruth/ci.nvim!27
No description provided.