generated from eblume/project-template
All checks were successful
Build / validate (pull_request) Successful in 16m0s
A dailies picker (zkd-style): lists the last `journal_days` (default 7) days newest-first, previews existing journals and shows "@create" for new ones, and opens the chosen day (creating if new). Journals resolve by their ISO-date title, so no new RPC is needed. picker.select gains an optional Telescope preview pane. e2e covers the recent-days list (exists/@create across a month boundary) and open-on-pick via a stubbed vim.ui.select. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
1.6 KiB
Lua
50 lines
1.6 KiB
Lua
-- The recent-days journal picker (the `zkd`-style dailies picker).
|
|
|
|
local h = require("e2e.helpers")
|
|
|
|
describe("journal picker", function()
|
|
local ctx
|
|
before_each(function()
|
|
ctx = h.start()
|
|
end)
|
|
after_each(function()
|
|
h.stop(ctx)
|
|
end)
|
|
|
|
it("lists recent days newest-first with @create state", function()
|
|
local entries = require("heph.journal").recent_entries(5, "2026-06-02")
|
|
assert.are.equal(5, #entries)
|
|
assert.are.equal("2026-06-02", entries[1].date) -- newest first
|
|
assert.are.equal("2026-05-29", entries[5].date) -- crosses the month boundary
|
|
for _, e in ipairs(entries) do
|
|
assert.is_false(e.exists) -- nothing created yet
|
|
end
|
|
|
|
-- Create one day's journal; it now reports as existing (with its node).
|
|
ctx.q:call("journal.open_or_create", { date = "2026-05-31" })
|
|
local found
|
|
for _, e in ipairs(require("heph.journal").recent_entries(5, "2026-06-02")) do
|
|
if e.date == "2026-05-31" then
|
|
found = e
|
|
end
|
|
end
|
|
assert.is_true(found.exists)
|
|
assert.is_truthy(found.node)
|
|
end)
|
|
|
|
it("opens the picked day's journal", function()
|
|
vim.g.heph_force_ui_select = true
|
|
local orig, picked = vim.ui.select, nil
|
|
vim.ui.select = function(items, _opts, on_choice)
|
|
picked = items[1] -- choose the newest day
|
|
on_choice(items[1])
|
|
end
|
|
require("heph.journal").pick()
|
|
vim.ui.select, vim.g.heph_force_ui_select = orig, nil
|
|
|
|
assert.is_truthy(picked)
|
|
local buf = vim.api.nvim_get_current_buf()
|
|
assert.are.equal("journal", vim.b[buf].heph_node_kind)
|
|
assert.are.equal(picked.date, ctx.q:call("node.get", { id = vim.b[buf].heph_node_id }).title)
|
|
end)
|
|
end)
|