-
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or requestmediumDifficulty level of this issue is: MEDIUMDifficulty level of this issue is: MEDIUM
Description
Title: Increase test coverage to prevent regressions
Summary
Recent refactors (e.g., dependency picker ↔ UI adapter) exposed gaps in test coverage that allowed breaking changes to be delivered. Expand automated tests to cover core modules and integration paths to prevent similar regressions.
Scope
- Add/extend unit tests across modules
- Add light integration “smoke” tests for UI wiring
- Keep the Arrange–Act–Assert convention
- Reuse the existing Plenary/Busted runner and
tests/minimal_init.lua
Target Areas
-
algo/hashset.lua
- Already covered; add edge cases (nil inputs, boolean keys, large inserts,
unionwith empty set).
- Already covered; add edge cases (nil inputs, boolean keys, large inserts,
-
telescope/telescope.lua (dependency picker)
- Flattens groups correctly (empty groups, missing
values). - Entry formatting (
[Group] Name) and ordering. - Selection handler calls
record_selectiononce per confirm. - No duplicates when the same item is confirmed multiple times.
- Flattens groups correctly (empty groups, missing
-
ui/deps.lua (adapter used by layout)
create_buttonmaps<CR>to open picker and then callsupdate_display.create_displayinitializes buffer and first render.update_displayrenders “no items” vs list state.- (Stub/mocking) Verify it reads from
telescope.selected_dependencies.
-
ui/layout.lua
- “Builds” end-to-end without throwing (smoke test).
- Left/right panels both mount; focus maps exist.
-
metadata/metadata.lua
- Successful decode: calls callbacks with table and sets
loaded. - Failed decode: sets
error, calls callbacks with error. - Subsequent
fetch_metadatareturns cached data without issuing a job.
- Successful decode: calls callbacks with table and sets
-
utils/
url:urlencodeandencode_query(reserved chars, spaces, unicode).http:download_filesuccess vs non-zero exit (mockJob).file:unziptriggerson_doneand removes file (mockJob, stubos.remove).window:get_winidfor{winid}vs{popup.winid};safe_closeno-op on invalid.
Proposed Plan
- Create new specs in
tests/mirroring module paths:tests/ ├── algo/hashset_spec.lua ├── telescope/telescope_spec.lua ├── ui/deps_spec.lua ├── ui/layout_smoke_spec.lua ├── metadata/metadata_spec.lua └── utils/ ├── url_spec.lua ├── http_spec.lua ├── file_spec.lua └── window_spec.lua - Use Plenary stubs/mocks:
- Stub
require("plenary.job").newto inject fakeon_exit,result,stderr_result. - For UI smoke tests, construct minimal instances and assert no exceptions and expected side-effects (buffer lines, keymaps exist).
- Stub
- Keep tests headless; avoid real network/file system effects.
CI Integration
- Reuse/extend existing
testworkflow:- Ensure plenary is installed (vendor path) in CI.
- Run:
nvim --headless -u tests/minimal_init.lua -c "PlenaryBustedDirectory tests" +q
Acceptance Criteria
- Specs exist for all modules listed in Target Areas.
- Tests follow Arrange–Act–Assert and run headlessly via Plenary/Busted.
-
ui/layout.luasmoke test mounts the layout without runtime errors. -
ui/deps.luaadapter tests verifycreate_button,create_display,update_displaybehavior and interaction with the picker state. -
metadata.luatests cover success, parse failure, and cache hit paths. -
utilstests cover happy paths and error branches. - CI
testjob passes onpushandpull_requesttomain.
Notes
- Where direct mocking is awkward, wrap external calls (e.g., Job/new) behind tiny local helpers to make stubbing easier in tests.
- Keep tests deterministic and avoid timing flakiness by calling scheduled callbacks synchronously where practical.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmediumDifficulty level of this issue is: MEDIUMDifficulty level of this issue is: MEDIUM