Files
oh-my-pi/packages/coding-agent/test/tools/python-renderer.test.ts
T
can1357 e22d123009 refactor(fs): migrated remaining sync file operations to async
- Converted readdirSync, readFileSync, and statSync to async readdir, readFile, stat across skills and agent discovery.
- Made scanDirectoryForSkills async and refactored custom directory scanning to use Promise.all for concurrent processing.
- Updated agent discovery to use fs/promises for async file reading and refactored helper patterns.
- Added AgentParsingError exception class for better error handling during agent parsing.
- Added filesystem error type guards (isEnoent, isEacces, isPerm, etc.) to pi-utils for safe error checking.
- Added color manipulation utilities to pi-utils for accessibility features.
- Added color-blind mode setting to settings manager.
- Migrated plugins, settings, and config modules from sync to async file operations.
- Updated error handling to use new pi-utils type guards for type-safe checking.
2026-01-24 03:18:03 +01:00

47 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";
import stripAnsi from "strip-ansi";
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 = 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 = stripAnsi(expanded.render(80).join("\n"));
expect(expandedLines).toContain("line 1");
expect(expandedLines).toContain("line 4");
expect(expandedLines).not.toContain("more lines");
});
});