-- Filter views (tech-spec ยง8.2): `:Heph view ` renders a built-in slice. local h = require("e2e.helpers") describe("filter views", function() local ctx before_each(function() ctx = h.start() end) after_each(function() h.stop(ctx) end) it("renders the Top of Mind view (red|orange, not blue)", function() ctx.q:call("task.create", { title = "urgent thing", attention = "red" }) ctx.q:call("task.create", { title = "warm thing", attention = "orange" }) ctx.q:call("task.create", { title = "cool thing", attention = "blue" }) -- The backend view returns just the red + orange tasks. local rows = ctx.q:call("view", { name = "tom" }) assert.are.equal(2, #rows) -- The plugin renders them into a dedicated view buffer. require("heph.view").view("tom") local buf = vim.api.nvim_get_current_buf() assert.is_truthy( vim.api.nvim_buf_get_name(buf):find("heph://view/tom", 1, true), "view buffer not named heph://view/tom" ) local text = table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, false), "\n") assert.is_truthy(text:find("urgent thing", 1, true), "red task missing from ToM") assert.is_truthy(text:find("warm thing", 1, true), "orange task missing from ToM") assert.is_falsy(text:find("cool thing", 1, true), "blue task should not be in ToM") end) it("scopes the chores view to chore projects via the daemon", function() local chores = ctx.q:call("node.create", { kind = "project", title = "Chores" }) ctx.q:call("task.create", { title = "take out trash", attention = "white", project_id = chores.id }) ctx.q:call("task.create", { title = "unrelated", attention = "white" }) local rows = ctx.q:call("view", { name = "chores" }) assert.are.equal(1, #rows) assert.are.equal("take out trash", rows[1].title) end) end)