Files
oh-my-pi/packages/coding-agent/test/tools/python-renderer.test.ts
T
can1357 a07f38b16e feat(grep): added grep CLI, diff highlighting, FileReader abstraction, and markdown improvements
- Added grep CLI subcommand with support for pattern matching, file globbing, context lines, and multiple output modes (content, files-with-matches, count).
- Added diff syntax highlighting support with distinct colors for inserted and deleted lines in code output.
- Implemented FileReader abstraction for cross-platform file reading with mmap support and 4MB size limit.
- Refactored worker pool initialization to support both compiled and development build environments using resolveWorkerSpecifier utility.
- Enhanced markdown rendering with improved inline style context handling and blockquote formatting with text wrapping.
- Replaced external strip-ansi dependency with Bun's built-in stripANSI method across all packages.
2026-01-31 01:27:36 +01:00

46 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { getThemeByName } from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
import { pythonToolRenderer } from "@oh-my-pi/pi-coding-agent/tools/python";
describe("pythonToolRenderer", () => {
it("renders truncated output when collapsed and full output when expanded", async () => {
const theme = await getThemeByName("dark");
expect(theme).toBeDefined();
const uiTheme = theme!;
const fullOutput = ["line 1", "line 2", "line 3", "line 4"].join("\n");
const result = {
content: [{ type: "text", text: fullOutput }],
details: {
cells: [
{
index: 0,
title: "run",
code: "print('hello')",
output: fullOutput,
status: "complete" as const,
durationMs: 12,
},
],
},
};
const collapsed = pythonToolRenderer.renderResult(
result,
{ expanded: false, isPartial: false, renderContext: { previewLines: 2 } },
uiTheme,
);
const collapsedLines = Bun.stripANSI(collapsed.render(80).join("\n"));
expect(collapsedLines).toContain("line 4");
expect(collapsedLines).not.toContain("line 1");
expect(collapsedLines).toContain("more lines");
const expanded = pythonToolRenderer.renderResult(result, { expanded: true, isPartial: false }, uiTheme);
const expandedLines = Bun.stripANSI(expanded.render(80).join("\n"));
expect(expandedLines).toContain("line 1");
expect(expandedLines).toContain("line 4");
expect(expandedLines).not.toContain("more lines");
});
});