-- 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)