2257a78d6b
思考展开时隐藏重复预览并使用灯泡图标,首个响应前显示临时思考提示。 统一分钟内小数和分钟以上整数秒,保持内外过程的紧凑间距与正文层级。 失败工具与分组显示错误色,非零退出码不再误判为成功。 补齐状态、格式、样式和交互回归,本批其余需求留待后续PR。
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { formatElapsedDuration } from '../../../packages/shared/src/lib/formatElapsedDuration';
|
|
import {
|
|
formatToolCallDuration,
|
|
formatTurnDuration,
|
|
} from '../src/features/project-workspace/toolCallGroupPresentation';
|
|
import { resourceCanvasAssetGenerationElapsedLabel } from '../src/features/resource-canvas/resourceCanvasAssetGenerationTaskModel';
|
|
|
|
describe('统一中文耗时', () => {
|
|
it.each([
|
|
[0, '0.0秒'],
|
|
[5200, '5.2秒'],
|
|
[59_949, '59.9秒'],
|
|
[59_950, '1分00秒'],
|
|
[60_000, '1分00秒'],
|
|
[60_100, '1分00秒'],
|
|
[65_600, '1分06秒'],
|
|
[125_200, '2分05秒'],
|
|
[3_599_950, '1时00分00秒'],
|
|
[3_725_200, '1时02分05秒'],
|
|
[90_061_200, '25时01分01秒'],
|
|
])('%s ms → %s,所有入口一致', (ms, expected) => {
|
|
expect(formatElapsedDuration(ms)).toBe(expected);
|
|
expect(formatToolCallDuration(ms)).toBe(expected);
|
|
expect(formatTurnDuration(ms)).toBe(expected);
|
|
expect(resourceCanvasAssetGenerationElapsedLabel(ms)).toBe(expected);
|
|
});
|
|
|
|
it.each([null, undefined, NaN, Infinity, -1])(
|
|
'未知时间不伪造零:%s',
|
|
(ms) => {
|
|
expect(formatElapsedDuration(ms)).toBeNull();
|
|
},
|
|
);
|
|
});
|