import { describe, it, expect } from "vitest"; import { createTask, getAgentTasks, getTaskById, updateTask, deleteTask, } from "./db"; describe("Tasks Management", () => { const testAgentId = 1; describe("createTask", () => { it("should create a new task", async () => { const task = await createTask({ agentId: testAgentId, title: "Test Task", description: "This is a test task", status: "pending", priority: "high", }); expect(task).toBeDefined(); expect(task?.title).toBe("Test Task"); expect(task?.status).toBe("pending"); expect(task?.priority).toBe("high"); }); }); describe("getAgentTasks", () => { it("should retrieve all tasks for an agent", async () => { const tasks = await getAgentTasks(testAgentId); expect(Array.isArray(tasks)).toBe(true); }); }); describe("getTaskById", () => { it("should return null for non-existent task", async () => { const task = await getTaskById(99999); expect(task).toBeNull(); }); }); describe("updateTask", () => { it("should update task status", async () => { const task = await createTask({ agentId: testAgentId, title: "Update Test", status: "pending", priority: "medium", }); if (task?.id) { const updated = await updateTask(task.id, { status: "in_progress", }); expect(updated?.status).toBe("in_progress"); } }); }); describe("deleteTask", () => { it("should return false for non-existent task", async () => { const success = await deleteTask(99999); expect(success).toBe(false); }); }); });