docs(test): add busted migration log

Problem: The plenary-to-busted migration surfaced three test isolation
issues whose root causes and fixes were not documented.

Solution: Add spec/TESTING.md recording the issues, their root causes,
and the applied fixes for future reference. Update CLAUDE.md test
section with correct framework, run command, and test count.
This commit is contained in:
Barrett Ruth 2026-02-22 12:13:58 -05:00
parent fc15d14bdb
commit 8d5be7fc5a
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

49
spec/TESTING.md Normal file
View file

@ -0,0 +1,49 @@
# Test Framework Migration Log
Issues encountered during the plenary-to-busted migration (`6be0148`) and
how they were resolved.
## Final status
114 successes / 0 failures / 0 errors.
## Issue 1: altbuf_spec.lua:18 — BufEnter wait mismatch (resolved)
The test `sets previous buffer as alternate when editing url file` originally
waited for two `BufEnter` events via `wait_for_autocmd('BufEnter')` x2.
The oil:// → real file resolution only produces one async BufEnter:
1. `vim.cmd.edit('oil://...')` fires BufEnter synchronously (before any
wait_for_autocmd is registered)
2. `normalize_url` resolves asynchronously via `uv.fs_realpath` + `uv.fs_stat`
3. `rename_buffer` discovers dest is a real file on disk, schedules
`nvim_win_set_buf()` via `vim.schedule()`
4. `nvim_win_set_buf()` fires one async BufEnter on the real file buffer
The second `wait_for_autocmd('BufEnter')` was never correct — it passed under
plenary due to coroutine event loop yielding, not because a second BufEnter
actually fired.
**Fix:** single `wait_for_autocmd('BufEnter')`.
## Issue 2: regression_spec.lua:20 — stale preview window state (resolved)
`reset_editor()` closed all windows except the first, but the surviving window
could be a preview window with stale `oil_preview`, `oil_source_win`,
`previewwindow`, etc. from a prior test. Subsequent tests that triggered
`close_preview_window_if_not_in_oil()` would close the wrong window.
**Fix:** `vim.cmd.new()` + `vim.cmd.only()` creates a fresh window and closes
all others (including the stale one). No variable cleanup needed — the new
window has no oil state.
## Issue 3: preview_spec.lua:30 — M.await timed out (resolved)
Originally thought to be a pre-existing issue unrelated to the migration. Root
cause was identical to issue 2: stale preview window state from a prior test
caused `close_preview_window_if_not_in_oil()` to close the wrong window during
`oil.open()`, preventing the callback from completing.
Fixed by the same `vim.cmd.new()` + `vim.cmd.only()` approach in
`reset_editor()`.