generated from eblume/project-template
Some checks failed
Build / validate (pull_request) Failing after 5m1s
Node buffers now open with the editable YAML frontmatter block on top
(node.get {frontmatter: true}); on :w, `frontmatter.lua` parses the
block, diffs it against what was rendered, and routes each changed field
to the right RPC:
- title → node.update rename
- attention → task.set_attention
- do_date/late_on/recurrence → task.set_schedule (YYYY-MM-DD → local-ms;
a removed line clears via null)
- project → task.set_project (resolved by name)
- tags → tag.add / tag.remove
A mistyped state surfaces the daemon's validation error; a buffer with no
block edits no metadata (deleting the block can't wipe tags). Body rides
node.update as before (the store strips any echoed frontmatter).
Body-position features are content-relative, so the prepended block
doesn't disturb them; e2e specs that targeted absolute line 1 now locate
body lines by content via a new `h.find` helper. New frontmatter_spec
covers render + the full diff→RPC round-trip. 21 nvim e2e specs green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
78 lines
3 KiB
Lua
78 lines
3 KiB
Lua
-- Workflow (c): follow a [[link]] under the cursor on <CR> to the target doc.
|
|
|
|
local h = require("e2e.helpers")
|
|
|
|
describe("follow link", function()
|
|
local ctx
|
|
before_each(function()
|
|
ctx = h.start()
|
|
end)
|
|
after_each(function()
|
|
h.stop(ctx)
|
|
end)
|
|
|
|
it("follows [[B]] under the cursor to doc B", function()
|
|
local b = h.create_doc("B", "the B doc")
|
|
local a = h.create_doc("A", "see [[B]] here")
|
|
|
|
local buf = h.open(a.id)
|
|
local lnum, col = h.find(buf, "%[%[B") -- the body line, below the frontmatter
|
|
assert.is_truthy(lnum)
|
|
-- Put the cursor on the target inside the brackets.
|
|
vim.api.nvim_win_set_cursor(0, { lnum, col + 2 })
|
|
|
|
require("heph.link").follow()
|
|
|
|
local cur = vim.api.nvim_get_current_buf()
|
|
assert.are.equal("heph://node/" .. b.id, vim.api.nvim_buf_get_name(cur))
|
|
assert.are.equal(b.id, vim.b[cur].heph_node_id)
|
|
end)
|
|
|
|
it("creates the target doc when following an unresolved [[link]]", function()
|
|
local a = h.create_doc("Daily", "see [[New Topic]]")
|
|
local buf = h.open(a.id)
|
|
local lnum, col = h.find(buf, "%[%[New")
|
|
vim.api.nvim_win_set_cursor(0, { lnum, col + 2 }) -- inside [[New Topic]]
|
|
|
|
require("heph.link").follow()
|
|
|
|
-- A new doc titled "New Topic" was created and opened.
|
|
local created = ctx.q:call("node.resolve", { title = "New Topic" })
|
|
assert.is_truthy(created, "expected the target doc to be created")
|
|
assert.are.equal("heph://node/" .. created.id, vim.api.nvim_buf_get_name(0))
|
|
|
|
-- ...and the source now backlinks it (the wiki-link materialized).
|
|
local linked = false
|
|
for _, l in ipairs(ctx.q:call("links.backlinks", { id = created.id })) do
|
|
if l.src_id == a.id and l.link_type == "wiki" then
|
|
linked = true
|
|
end
|
|
end
|
|
assert.is_true(linked, "expected the source to backlink the created doc")
|
|
end)
|
|
|
|
it("creates + links from an unsaved [[link]] just typed into the buffer", function()
|
|
-- The real gesture: open a note, type a new [[link]], <CR> without :w.
|
|
local a = h.create_doc("Journalish", "")
|
|
local buf = h.open(a.id)
|
|
vim.api.nvim_buf_set_lines(buf, 0, -1, false, { "ref [[Fresh Note]]" })
|
|
assert.is_true(vim.bo[buf].modified)
|
|
local at = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1]:find("%[%[Fresh")
|
|
vim.api.nvim_win_set_cursor(0, { 1, at + 1 })
|
|
|
|
require("heph.link").follow()
|
|
|
|
local created = ctx.q:call("node.resolve", { title = "Fresh Note" })
|
|
assert.is_truthy(created)
|
|
assert.are.equal("heph://node/" .. created.id, vim.api.nvim_buf_get_name(0))
|
|
-- The source's pending edit was persisted and the backlink materialized.
|
|
assert.are.equal("ref [[Fresh Note]]", ctx.q:call("node.get", { id = a.id }).body)
|
|
local linked = false
|
|
for _, l in ipairs(ctx.q:call("links.backlinks", { id = created.id })) do
|
|
if l.src_id == a.id and l.link_type == "wiki" then
|
|
linked = true
|
|
end
|
|
end
|
|
assert.is_true(linked, "expected the source edit saved and backlink materialized")
|
|
end)
|
|
end)
|