hephaestus/heph.nvim/tests/e2e/view_actions_spec.lua
Erich Blume 0462a6e43b
Some checks failed
Build / validate (pull_request) Failing after 4m47s
heph.nvim: interactive next/list views (add, done, refresh) + key hint
The Tactical next and Organizational list buffers are now actionable:
- a  add a task from the list (prompt title + attention)
- d  mark the task under the cursor done
- r  refresh
- <CR> open the task's context (as before)

A dimmed key hint renders above the rows as a virtual line (extmark), so it's
discoverable without taking a task row. e2e covers add-from-list and
done-from-list via stubbed vim.ui.input/select.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 11:48:09 -07:00

60 lines
1.9 KiB
Lua

-- Interactive task-list actions: add a task from the list, mark done from it.
local h = require("e2e.helpers")
describe("task list actions", function()
local ctx
before_each(function()
ctx = h.start()
end)
after_each(function()
h.stop(ctx)
end)
it("adds a task from the list buffer", function()
require("heph.view").list()
local buf = vim.api.nvim_get_current_buf()
vim.g.heph_force_ui_select = true
local orig_input, orig_select = vim.ui.input, vim.ui.select
vim.ui.input = function(_o, cb)
cb("Buy milk")
end
vim.ui.select = function(_items, _o, cb)
cb("orange")
end
require("heph.view").add_from(buf)
vim.ui.input, vim.ui.select, vim.g.heph_force_ui_select = orig_input, orig_select, nil
-- The task was created with the chosen attention...
local found
for _, t in ipairs(ctx.q:call("list", {})) do
if t.title == "Buy milk" then
found = t
end
end
assert.is_truthy(found, "task not created")
assert.are.equal("orange", found.attention)
-- ...and the list refreshed to show it.
local present = false
for _, l in ipairs(vim.api.nvim_buf_get_lines(vim.api.nvim_get_current_buf(), 0, -1, false)) do
if l:find("Buy milk", 1, true) then
present = true
end
end
assert.is_true(present, "added task missing from the refreshed list")
end)
it("marks the task under the cursor done from the list buffer", function()
local t = ctx.q:call("task.create", { title = "Ship it", attention = "red" })
require("heph.view").list()
local buf = vim.api.nvim_get_current_buf()
vim.api.nvim_win_set_cursor(0, { 1, 0 })
require("heph.view").done_under_cursor(buf)
assert.are.equal("done", ctx.q:call("task.get", { id = t.node_id }).state)
assert.are.equal(0, #ctx.q:call("list", {})) -- gone from the refreshed list
end)
end)