Files
Genarrative/apps/ai-game-creator-shell/tests/windowsCommandPresentation.test.ts
T
suzmii 09791eb9e4
Project CI / AI game creator shell Rust shard 1/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 2/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 3/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust shard 4/4 (pull_request) Has been cancelled
Project CI / AI game creator shell Rust smoke (pull_request) Has been cancelled
Project CI / AI game creator shell Rust crates (pull_request) Has been cancelled
Project CI / Backend tests (pull_request) Has been cancelled
Project CI / Native shell tests (pull_request) Has been cancelled
Project CI / Frontend tests (pull_request) Has been cancelled
Project CI / Repository checks (pull_request) Has been cancelled
Project CI / AI game creator shell web tests (pull_request) Has been cancelled
统一对话回合投影并优化工具命令展示
按回合唯一归属渲染正文与工具,修复完成快照冲刷和历史归并

补齐工具输入输出,Windows命令卡片隐藏PowerShell启动器包装

时间显示精确到秒,结束信息右对齐并调整输入框文案与引用按钮间距

同步回归用例与规范文档,保留实机验收待办
2026-09-16 02:30:28 +08:00

76 lines
2.7 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { GameCreatorDirectToolCall } from '../src/app/types';
import {
toolCallInputText,
toolCallRowText,
} from '../src/features/project-workspace/toolCallGroupPresentation';
function commandCall(command: string): GameCreatorDirectToolCall {
return {
schemaVersion: 'agc-tool-call.v1',
id: 'command',
turnId: 'turn',
kind: 'command',
title: '执行命令',
summary: command.slice(0, 120),
status: 'completed',
startedAt: 1,
updatedAt: 2,
detail: { command, output: 'pwsh -Command output must stay unchanged' },
};
}
describe('Windows 命令卡片展示', () => {
it('从 WindowsApps 路径后的完整输入提取脚本,并解开 shlex 引号拼接', () => {
const script = `foreach ($f in @('game/package.json','game/vite.config.js','game/index.html','game/game.js')) { Write-Output "===== $f ====="; Get-Content -Raw $f }`;
const argument = "'" + script.replaceAll("'", "'\"'\"'") + "'";
const command = String.raw`"<absolute-path> Files\WindowsApps\Microsoft.PowerShell_7.6.6.0_x64__8wekyb3d8bbwe\pwsh.exe" -Command ${argument}`;
const call = commandCall(command);
expect(toolCallInputText(call)).toBe(script);
expect(toolCallRowText(call)).toBe(`${script.slice(0, 120)}…`);
expect(call.detail.command).toBe(command);
expect(call.detail.output).toBe('pwsh -Command output must stay unchanged');
});
it.each([
['pwsh -Command Get-Date', 'Get-Date'],
[
'pwsh.exe -NoLogo -NoProfile -NonInteractive -Command "Get-Date"',
'Get-Date',
],
[
String.raw`"C:\Program Files\PowerShell\7\pwsh.exe" -c 'Get-Date'`,
'Get-Date',
],
["POWERSHELL.EXE -ExecutionPolicy Bypass -Command 'Get-Date'", 'Get-Date'],
[
String.raw`pwsh -Command "Write-Output \"hello\"; Get-Content C:\game\a.txt"`,
String.raw`Write-Output "hello"; Get-Content C:\game\a.txt`,
],
["pwsh -Command 'Get-Date\nGet-Location'", 'Get-Date\nGet-Location'],
["pwsh -Command 'Get-Date…", "'Get-Date…"],
])('隐藏启动器:%s', (command, script) => {
expect(toolCallInputText(commandCall(command))).toBe(script);
});
it.each([
'npm run build',
'pwsh -File game/build.ps1',
'pwsh -EncodedCommand ZgBvAG8A',
'not-pwsh.exe -Command Get-Date',
'echo pwsh -Command Get-Date',
"bash -c 'echo hello'",
])('保留非目标调用:%s', (command) => {
expect(toolCallInputText(commandCall(command))).toBe(command);
});
it('不改写 MCP 工具参数', () => {
const call = {
...commandCall('pwsh -Command Get-Date'),
kind: 'mcp_tool' as const,
};
expect(toolCallInputText(call)).toBe('pwsh -Command Get-Date');
});
});