Files
oh-my-pi/packages/coding-agent/test/plan-mode/approved-plan.test.ts
T
can1357 cd5c9655aa refactor: renamed notes protocol to local
- Renamed the `notes://` protocol to `local://` for better clarity.
- Updated all internal references, prompts, and tool documentation.
- Migrated plan storage paths to use the new `local://` scheme.
2026-02-22 18:05:22 +01:00

48 lines
1.7 KiB
TypeScript

import { afterEach, beforeEach, describe, expect, it } from "bun:test";
import * as fs from "node:fs/promises";
import * as os from "node:os";
import * as path from "node:path";
import { renameApprovedPlanFile } from "@oh-my-pi/pi-coding-agent/plan-mode/approved-plan";
describe("renameApprovedPlanFile", () => {
let tmpDir: string;
let artifactsDir: string;
beforeEach(async () => {
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "approved-plan-"));
artifactsDir = path.join(tmpDir, "artifacts");
await fs.mkdir(path.join(artifactsDir, "local"), { recursive: true });
});
afterEach(async () => {
await fs.rm(tmpDir, { recursive: true, force: true });
});
function options(planFilePath: string, finalPlanFilePath: string) {
return {
planFilePath,
finalPlanFilePath,
getArtifactsDir: () => artifactsDir,
getSessionId: () => "session-z",
};
}
it("fails with actionable error when destination already exists", async () => {
await Bun.write(path.join(artifactsDir, "local", "PLAN.md"), "draft");
await Bun.write(path.join(artifactsDir, "local", "WP_MIGRATION_PLAN.md"), "existing");
await expect(renameApprovedPlanFile(options("local://PLAN.md", "local://WP_MIGRATION_PLAN.md"))).rejects.toThrow(
"Plan destination already exists at local://WP_MIGRATION_PLAN.md",
);
});
it("renames PLAN.md to titled artifact path", async () => {
await Bun.write(path.join(artifactsDir, "local", "PLAN.md"), "draft body");
await renameApprovedPlanFile(options("local://PLAN.md", "local://WP_MIGRATION_PLAN.md"));
expect(await Bun.file(path.join(artifactsDir, "local", "WP_MIGRATION_PLAN.md")).text()).toBe("draft body");
await expect(fs.stat(path.join(artifactsDir, "local", "PLAN.md"))).rejects.toThrow();
});
});