feat: tasks workflow

This commit is contained in:
2026-07-13 16:00:25 +05:00
parent 9705bac7af
commit ce69209820
15 changed files with 559 additions and 31 deletions
+60
View File
@@ -0,0 +1,60 @@
import { beforeEach, describe, expect, it } from "vitest";
import { err } from "neverthrow";
import { InMemoryFileSystem } from "../../tests/helpers/InMemoryFileSystem";
import { AppError } from "@/error";
import { FsTaskRepository } from "@/storage/FsTaskRepository";
import { openTask } from "./openTask";
describe("openTask", () => {
const folder = "/tasks";
let repo: FsTaskRepository;
beforeEach(() => {
repo = new FsTaskRepository(new InMemoryFileSystem(), ".task.md");
});
it("returns file path and task for an existing id", async () => {
const created = await repo.create(folder, {
title: "Open me",
description: "body",
status: "todo",
priority: "high",
tags: [],
assignee: "",
});
const result = await openTask(repo, {
folderPath: folder,
id: created.id,
});
expect(result.isOk()).toBe(true);
if (result.isErr()) return;
expect(result.value.path).toBe("/tasks/open-me.task.md");
expect(result.value.task).toEqual(created);
});
it("returns not_found for unknown id", async () => {
const result = await openTask(repo, {
folderPath: folder,
id: "missing",
});
expect(result).toEqual(err(AppError.notFound()));
});
it("rejects missing folder", async () => {
const result = await openTask(repo, {
folderPath: undefined,
id: "x",
});
expect(result).toEqual(err(AppError.noFolder()));
});
it("rejects missing id", async () => {
const result = await openTask(repo, {
folderPath: folder,
id: undefined,
});
expect(result).toEqual(err(AppError.noId()));
});
});