Files
oh-my-pi/packages/coding-agent/test/extensibility/custom-commands/ci-green.test.ts
T
can1357 e9888367d1 refactor: migrated packages to internal utility modules and removed external dependencies
- Implemented in-house, zero-dependency utility modules in `pi-utils` covering DOM manipulation, markdown parsing, templating, browser automation helpers, and terminal buffers.
- Migrated packages across the repository to consume the new internal utilities and `omptype` schema validators instead of external dependencies.
- Removed multiple external runtime and development dependencies including Zod, Marked, LRU cache, Turndown, and Puppeteer browser packages.
2026-08-05 13:39:09 +02:00

51 lines
1.6 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import { type } from "@oh-my-pi/omptype";
import type * as TypeBox from "@oh-my-pi/omptype/typebox";
import * as zod from "@oh-my-pi/omptype/zod";
import * as piCodingAgent from "@oh-my-pi/pi-coding-agent";
import { GreenCommand } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/bundled/ci-green";
import type { CustomCommandAPI } from "@oh-my-pi/pi-coding-agent/extensibility/custom-commands/types";
import type { HookCommandContext } from "@oh-my-pi/pi-coding-agent/extensibility/hooks/types";
import * as git from "@oh-my-pi/pi-coding-agent/utils/git";
afterEach(() => {
vi.restoreAllMocks();
});
function createApi(): CustomCommandAPI {
return {
cwd: "/tmp/test",
exec: async () => ({
stdout: "",
stderr: "",
code: 0,
killed: false,
}),
typebox: {} as unknown as typeof TypeBox,
arktype: type,
zod,
pi: piCodingAgent,
};
}
describe("GreenCommand", () => {
it("includes tag instructions when HEAD has a tag", async () => {
vi.spyOn(git.ref, "tags").mockResolvedValue(["v0.1.0-alpha2"]);
const command = new GreenCommand(createApi());
const result = await command.execute([], {} as HookCommandContext);
expect(result).toContain("v0.1.0-alpha2");
expect(result).not.toContain("timeouts due to the harnesses");
});
it("omits tag instructions when HEAD is not tagged", async () => {
vi.spyOn(git.ref, "tags").mockResolvedValue([]);
const command = new GreenCommand(createApi());
const result = await command.execute([], {} as HookCommandContext);
expect(result).not.toContain("v0.1.0-alpha2");
});
});