Files
oh-my-pi/packages/coding-agent/test/slash-commands/btw.test.ts
T
maximharandGitHub 952db9fd93 feat: add ephemeral /btw side-question panel (#399)
* feat: add ephemeral /btw side-question panel

* fix: preserve /btw live context and payload hooks

* fix: send /btw question through session pipeline
2026-03-14 10:42:26 +01:00

44 lines
1.4 KiB
TypeScript

import { describe, expect, it, vi } from "bun:test";
import type { InteractiveModeContext } from "@oh-my-pi/pi-coding-agent/modes/types";
import { executeBuiltinSlashCommand } from "@oh-my-pi/pi-coding-agent/slash-commands/builtin-registry";
function createRuntime() {
const handleBtwCommand = vi.fn(async () => {});
const setText = vi.fn();
return {
handleBtwCommand,
setText,
runtime: {
ctx: {
editor: { setText } as unknown as InteractiveModeContext["editor"],
handleBtwCommand,
} as unknown as InteractiveModeContext,
handleBackgroundCommand: () => {},
},
};
}
describe("/btw slash command", () => {
it("routes the full question through the interactive btw handler", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand("/btw why is it doing that?", harness.runtime);
expect(handled).toBe(true);
expect(harness.setText).toHaveBeenCalledWith("");
expect(harness.handleBtwCommand).toHaveBeenCalledWith("why is it doing that?");
});
it("preserves the raw multi-word suffix after /btw", async () => {
const harness = createRuntime();
const handled = await executeBuiltinSlashCommand(
"/btw explain why the cache reuse matters here",
harness.runtime,
);
expect(handled).toBe(true);
expect(harness.handleBtwCommand).toHaveBeenCalledWith("explain why the cache reuse matters here");
});
});