feat(team-mode): add team tasklist get with tests

This commit is contained in:
YeonGyu-Kim
2026-04-28 10:46:05 +09:00
parent 6e0f6aefcc
commit 031a7a4dd4
2 changed files with 58 additions and 0 deletions
@@ -0,0 +1,45 @@
/// <reference types="bun-types" />
import { expect, test } from "bun:test"
import { createTask } from "./store"
import { createTaskInput, createTasklistFixture } from "./test-support"
import { getTask } from "./get"
test("getTask returns a persisted task", async () => {
// given
const fixture = await createTasklistFixture()
try {
const createdTask = await createTask(fixture.teamRunId, createTaskInput({ subject: "persisted task" }), fixture.config)
// when
const loadedTask = await getTask(fixture.teamRunId, createdTask.id, fixture.config)
// then
expect(loadedTask).toEqual(createdTask)
} finally {
await fixture.cleanup()
}
})
test("getTask throws when the task file is missing", async () => {
// given
const fixture = await createTasklistFixture()
try {
// when
let thrownError: unknown = null
try {
await getTask(fixture.teamRunId, "999", fixture.config)
} catch (error) {
thrownError = error
}
// then
expect(thrownError).toBeInstanceOf(Error)
} finally {
await fixture.cleanup()
}
})
@@ -0,0 +1,13 @@
import { readFile } from "node:fs/promises"
import path from "node:path"
import type { TeamModeConfig } from "../../../config/schema/team-mode"
import { getTasksDir, resolveBaseDir } from "../team-registry"
import { TaskSchema } from "../types"
import type { Task } from "../types"
export async function getTask(teamRunId: string, taskId: string, config: TeamModeConfig): Promise<Task> {
const tasksDirectory = getTasksDir(resolveBaseDir(config), teamRunId)
const taskContent = await readFile(path.join(tasksDirectory, `${taskId}.json`), "utf8")
return TaskSchema.parse(JSON.parse(taskContent))
}