a0f6b7c67d
思考展开复用安全Markdown渲染,折叠显示浅色单行纯文本预览与右侧箭头。 共享过程摘要组件,执行过程按真实操作数显示统计并保留各组独立计时。 工具、整轮、生成任务和策划耗时统一为中文时分秒格式。 补齐格式与Markdown回归、更新已有界面断言并验证窄屏键盘操作。
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
AGENT_PROCESS_PREVIEW_MAX_CHARS,
|
|
agentProcessPreview,
|
|
} from '../src/features/project-workspace/agentProcessPreview';
|
|
|
|
describe('思考过程单行预览模型', () => {
|
|
it('去掉 Markdown 符号与链接目标,只留字面文字', () => {
|
|
expect(agentProcessPreview('**Planning** 一下')).toBe('Planning 一下');
|
|
expect(
|
|
agentProcessPreview(
|
|
'先看 [设计文档](https://internal.example/secret) 再动手',
|
|
),
|
|
).toBe('先看 设计文档 再动手');
|
|
expect(agentProcessPreview('用 `npm run build` 验证')).toBe(
|
|
'用 npm run build 验证',
|
|
);
|
|
});
|
|
|
|
it('原始 HTML 不进预览(不渲染、也不当文字)', () => {
|
|
expect(agentProcessPreview('<script>alert(1)</script>')).toBe('');
|
|
expect(agentProcessPreview('<img src="x.png" alt="图">')).toBe('');
|
|
expect(
|
|
agentProcessPreview('先检查\n\n<script>alert(1)</script>\n\n再继续'),
|
|
).toBe('先检查 再继续');
|
|
// 行内 HTML 与其文字内容都不泄漏。
|
|
expect(agentProcessPreview('结果 <b>加粗</b> 完成')).toBe('结果 加粗 完成');
|
|
});
|
|
|
|
it('GFM 删除线按同源插件解析,波浪号不进预览', () => {
|
|
// 与正文同源:删除线保留其文字(正文里也是这段字),但 `~~` 控制符不进预览。
|
|
expect(agentProcessPreview('~~删除这段~~ 保留这段')).toBe(
|
|
'删除这段 保留这段',
|
|
);
|
|
expect(agentProcessPreview('~~删除~~')).toBe('删除');
|
|
});
|
|
|
|
it('压成单行并按上限省略', () => {
|
|
expect(agentProcessPreview('第一行\n\n第二行')).toBe('第一行 第二行');
|
|
expect(agentProcessPreview('- 第一项\n- 第二项')).toBe('第一项 第二项');
|
|
const long = 'x'.repeat(AGENT_PROCESS_PREVIEW_MAX_CHARS + 20);
|
|
const preview = agentProcessPreview(long);
|
|
expect(preview.endsWith('…')).toBe(true);
|
|
expect(preview.length).toBeLessThanOrEqual(
|
|
AGENT_PROCESS_PREVIEW_MAX_CHARS + 1,
|
|
);
|
|
expect(agentProcessPreview('')).toBe('');
|
|
expect(agentProcessPreview(' ')).toBe('');
|
|
});
|
|
});
|