hephaestus/heph.nvim/tests/e2e/recurring_spec.lua
Erich Blume 7c9a734ebd
Some checks failed
Build / validate (pull_request) Failing after 2s
heph.nvim: task views — next/list/capture/attention/state/log (slice 11b)
Backend: enrich `list` to return titled RankedTask rows (title +
canonical_context_id, via a shared ranked_from_row with `next`), so the
Organizational view needs no N+1 node.get. TDD: query_surface test asserts
list rows carry title + context id.

Plugin:
- view.lua: Tactical `next` + Organizational `list` rendered scratch buffers;
  <CR> opens the row's canonical-context doc. Narrowed the node autocmd to
  heph://node/* so view buffers (heph://next, heph://list) don't trip it.
- task.lua: capture, set-attention, done/drop, skip, per-task log append, all
  resolving "the current task" from the buffer (a task node, or a context doc
  via its canonical-context backlink).
- picker.lua: vim.ui.select with Telescope auto-upgrade (headless-safe).
- command.lua: :Heph next/list/capture/attention/done/drop/skip/log/search.

e2e: capture→next→open context→add/check checklist→done; recurring
fresh-checklist (complete rolls forward in place, next occurrence all-unchecked
— the §4.4 hard requirement). 6 specs green via `mise run test-nvim`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 21:12:56 -07:00

54 lines
2 KiB
Lua

-- Workflow (e): a recurring task with a checklist. Completing it must roll the
-- task forward in place and present the next occurrence with a FRESH,
-- all-unchecked checklist — completion never carries forward (tech-spec §4.4).
--
-- The e2e daemon uses the real system clock (it's the actual binary), so we
-- assert the do-date *advanced* past the original rather than an exact value;
-- the fresh checklist is the hard requirement.
local h = require("e2e.helpers")
describe("recurring task checklist", function()
local ctx
before_each(function()
ctx = h.start()
end)
after_each(function()
h.stop(ctx)
end)
it("resets the checklist to all-unchecked on the next occurrence", function()
local base = 1717200000000 -- 2024-06-01, safely in the past
local task = require("heph.task").capture("Water plants", {
recurrence = "FREQ=DAILY",
do_date = base,
})
-- Its canonical-context doc holds the checklist (the recurrence template).
local ctx_id
for _, l in ipairs(ctx.q:call("links.outgoing", { id = task.node_id })) do
if l.link_type == "canonical-context" then
ctx_id = l.dst_id
end
end
assert.is_truthy(ctx_id)
-- Add a checklist via the buffer, then check both items off.
local buf = h.open(ctx_id)
h.set_lines(buf, { "- [ ] water fern", "- [ ] water cactus" })
h.save(buf)
h.set_lines(buf, { "- [x] water fern", "- [x] water cactus" })
h.save(buf)
-- Complete the occurrence from its context buffer → rolls forward in place.
require("heph.task").set_state_current("done")
local t = ctx.q:call("task.get", { id = task.node_id })
assert.are.equal("outstanding", t.state) -- rolled forward, not done
assert.is_true(t.do_date > base, "do-date should advance to the next occurrence")
-- The hard requirement: a fresh, all-unchecked checklist.
local stored = ctx.q:call("node.get", { id = ctx_id })
assert.are.equal("- [ ] water fern\n- [ ] water cactus", stored.body)
end)
end)