fix(agent-teams): harden deletion and messaging safety

This commit is contained in:
Nguyen Khac Trung Kien
2026-02-08 13:35:03 +07:00
committed by YeonGyu-Kim
parent 0f0ba0f71b
commit f422cfc7af
6 changed files with 305 additions and 8 deletions
@@ -1,6 +1,6 @@
/// <reference types="bun-types" />
import { afterEach, beforeEach, describe, expect, test } from "bun:test"
import { mkdtempSync, rmSync } from "node:fs"
import { mkdtempSync, readFileSync, rmSync } from "node:fs"
import { tmpdir } from "node:os"
import { join } from "node:path"
import { acquireLock } from "../../features/claude-tasks/storage"
@@ -68,4 +68,22 @@ describe("agent-teams team config store", () => {
//#then
expect(teamExists("core")).toBe(false)
})
test("deleteTeamData removes task files before team files", () => {
//#given
const sourceUrl = new URL("./team-config-store.ts", import.meta.url)
const source = readFileSync(sourceUrl, "utf-8")
const deleteFnStart = source.indexOf("export function deleteTeamData")
const deleteFnSlice = deleteFnStart >= 0 ? source.slice(deleteFnStart, deleteFnStart + 700) : ""
//#when
const taskDeleteIndex = deleteFnSlice.indexOf("rmSync(taskDir")
const teamDeleteIndex = deleteFnSlice.indexOf("rmSync(teamDir")
//#then
expect(deleteFnStart).toBeGreaterThanOrEqual(0)
expect(taskDeleteIndex).toBeGreaterThanOrEqual(0)
expect(teamDeleteIndex).toBeGreaterThanOrEqual(0)
expect(taskDeleteIndex).toBeLessThan(teamDeleteIndex)
})
})