Files
oh-my-pi/packages/coding-agent/test/extensibility/custom-commands/ci-green.test.ts
T
2026-05-12 04:09:33 +02:00

47 lines
1.4 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "bun:test";
import * as typebox from "@sinclair/typebox";
import { GreenCommand } from "../../../src/extensibility/custom-commands/bundled/ci-green";
import type { CustomCommandAPI } from "../../../src/extensibility/custom-commands/types";
import type { HookCommandContext } from "../../../src/extensibility/hooks/types";
import * as piCodingAgent from "../../../src/index";
import * as git from "../../../src/utils/git";
afterEach(() => {
vi.restoreAllMocks();
});
function createApi(): CustomCommandAPI {
return {
cwd: "/tmp/test",
exec: async () => ({
stdout: "",
stderr: "",
code: 0,
killed: false,
}),
typebox,
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");
});
});