generated from eblume/project-template
32 lines
1.1 KiB
Lua
32 lines
1.1 KiB
Lua
|
|
-- Workflow (b): create a daily journal, write an entry, save, assert persisted.
|
||
|
|
|
||
|
|
local h = require("e2e.helpers")
|
||
|
|
|
||
|
|
describe("journal", function()
|
||
|
|
local ctx
|
||
|
|
before_each(function()
|
||
|
|
ctx = h.start()
|
||
|
|
end)
|
||
|
|
after_each(function()
|
||
|
|
h.stop(ctx)
|
||
|
|
end)
|
||
|
|
|
||
|
|
it("creates the journal, persists an entry, and round-trips exactly", function()
|
||
|
|
local node = require("heph.journal").open("2026-06-01")
|
||
|
|
local buf = vim.api.nvim_get_current_buf()
|
||
|
|
assert.are.equal("heph://node/" .. node.id, vim.api.nvim_buf_get_name(buf))
|
||
|
|
assert.are.equal("journal", vim.b[buf].heph_node_kind)
|
||
|
|
|
||
|
|
h.set_lines(buf, { "Today I wrote tests." })
|
||
|
|
h.save(buf)
|
||
|
|
assert.is_false(vim.bo[buf].modified)
|
||
|
|
|
||
|
|
-- Persisted body equals the typed text exactly — the trailing-newline canary.
|
||
|
|
local stored = ctx.q:call("node.get", { id = node.id })
|
||
|
|
assert.are.equal("Today I wrote tests.", stored.body)
|
||
|
|
|
||
|
|
-- Idempotent reopen returns the same deterministic journal node.
|
||
|
|
local again = require("heph.journal").open("2026-06-01")
|
||
|
|
assert.are.equal(node.id, again.id)
|
||
|
|
end)
|
||
|
|
end)
|