feat: add dashboard and commands

This commit is contained in:
2026-07-14 10:00:15 +05:00
parent 2f09b3754e
commit 3490781ad5
13 changed files with 835 additions and 1 deletions
+56
View File
@@ -0,0 +1,56 @@
import { beforeEach, describe, expect, it } from "vitest";
import { err } from "neverthrow";
import { InMemoryFileSystem } from "../../tests/helpers/InMemoryFileSystem";
import { appError, AppErrorVariant } from "@/error";
import { FsTaskRepository } from "@/storage/FsTaskRepository";
import { loadDashboard } from "./loadDashboard";
describe("loadDashboard", () => {
const folder = "/tasks";
let repo: FsTaskRepository;
beforeEach(() => {
repo = new FsTaskRepository(new InMemoryFileSystem(), ".task.md");
});
it("loads all tasks for a folder", async () => {
const a = await repo.create(folder, {
title: "First",
description: "",
status: "todo",
priority: "medium",
tags: [],
assignee: "",
});
const b = await repo.create(folder, {
title: "Second",
description: "body",
status: "done",
priority: "high",
tags: ["x"],
assignee: "",
});
const result = await loadDashboard(repo, { folderPath: folder });
expect(result.isOk()).toBe(true);
if (result.isErr()) return;
expect(result.value.tasks).toHaveLength(2);
const ids = result.value.tasks.map((t) => t.id).sort();
expect(ids).toEqual([a.id, b.id].sort());
});
it("returns empty list when folder has no tasks", async () => {
const result = await loadDashboard(repo, { folderPath: folder });
expect(result.isOk()).toBe(true);
if (result.isErr()) return;
expect(result.value.tasks).toEqual([]);
});
it("rejects missing folder", async () => {
const result = await loadDashboard(repo, { folderPath: undefined });
expect(result).toEqual(err(appError(AppErrorVariant.NO_FOLDER)));
});
});