74 lines
2.4 KiB
TypeScript
74 lines
2.4 KiB
TypeScript
import { afterAll, beforeAll, describe, expect, it } from "bun:test";
|
|
import { resetSettingsForTest, Settings } from "@oh-my-pi/pi-coding-agent/config/settings";
|
|
import {
|
|
createHandoffSummaryMessageComponent,
|
|
HandoffSummaryMessageComponent,
|
|
} from "@oh-my-pi/pi-coding-agent/modes/components/compaction-summary-message";
|
|
import { initTheme } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
|
|
import type { CustomMessage } from "@oh-my-pi/pi-coding-agent/session/messages";
|
|
|
|
beforeAll(async () => {
|
|
resetSettingsForTest();
|
|
await Settings.init({ inMemory: true });
|
|
await initTheme(false);
|
|
});
|
|
|
|
afterAll(() => {
|
|
resetSettingsForTest();
|
|
});
|
|
|
|
function makeHandoffMessage(content: CustomMessage<unknown>["content"]): CustomMessage<unknown> {
|
|
return {
|
|
role: "custom",
|
|
customType: "handoff",
|
|
content,
|
|
display: true,
|
|
attribution: "agent",
|
|
timestamp: Date.now(),
|
|
};
|
|
}
|
|
|
|
describe("handoff summary divider", () => {
|
|
it("renders handoff custom messages with the compact divider instead of a framed block", () => {
|
|
const component = createHandoffSummaryMessageComponent(
|
|
makeHandoffMessage(
|
|
`<handoff-context>\n# Goal\nContinue the resize fix.\n</handoff-context>\n\nThe above is a handoff document.`,
|
|
),
|
|
false,
|
|
);
|
|
|
|
expect(component).toBeInstanceOf(HandoffSummaryMessageComponent);
|
|
const collapsed = Bun.stripANSI(component!.render(80).join("\n"));
|
|
expect(collapsed).toContain("handoff");
|
|
expect(collapsed).toContain("ctrl+o");
|
|
expect(collapsed).not.toContain("[handoff]");
|
|
expect(collapsed).not.toContain("Continue the resize fix");
|
|
});
|
|
|
|
it("expands to the handoff document without the provider-only XML wrapper", () => {
|
|
const component = createHandoffSummaryMessageComponent(
|
|
makeHandoffMessage([
|
|
{
|
|
type: "text",
|
|
text: "<handoff-context>\n# Goal\nContinue the resize fix.\n</handoff-context>",
|
|
},
|
|
]),
|
|
true,
|
|
);
|
|
|
|
expect(component).toBeInstanceOf(HandoffSummaryMessageComponent);
|
|
const expanded = Bun.stripANSI(component!.render(80).join("\n"));
|
|
expect(expanded).toContain("Handoff context");
|
|
expect(expanded).toContain("Continue the resize fix");
|
|
expect(expanded).not.toContain("<handoff-context>");
|
|
expect(expanded).not.toContain("</handoff-context>");
|
|
});
|
|
|
|
it("leaves unrelated custom messages on the generic renderer path", () => {
|
|
const message = makeHandoffMessage("Not a handoff.");
|
|
message.customType = "extension-note";
|
|
|
|
expect(createHandoffSummaryMessageComponent(message, false)).toBeUndefined();
|
|
});
|
|
});
|