测试:补回入队被拒消息不落盘、不重放的断言
- home.suite.ts 的入队被拒用例恢复 persistedMessages 桩,并让历史切片返回它 - 增加断言:被拒消息不落历史条目、不被乐观渲染成用户气泡、不写本地历史 - 增加 cleanup + 重挂载断言:重进项目不重放被拒消息与拒绝文案,且不自动重试
This commit is contained in:
@@ -2544,6 +2544,7 @@ export function registerHomeProjectCreationTests() {
|
||||
'failed-direct-project',
|
||||
'直连失败项目',
|
||||
);
|
||||
const persistedMessages: Array<Record<string, unknown>> = [];
|
||||
const invoke = vi.fn(
|
||||
async (command: string, args?: Record<string, unknown>) => {
|
||||
if (command === 'get_local_game_manifest') {
|
||||
@@ -2552,7 +2553,11 @@ export function registerHomeProjectCreationTests() {
|
||||
}
|
||||
if (command === 'read_direct_project_history_slice') {
|
||||
expect(args).toEqual({ projectPath, limit: 20 });
|
||||
return { items: [], hasMore: false, firstItemId: null };
|
||||
return {
|
||||
items: [...persistedMessages],
|
||||
hasMore: false,
|
||||
firstItemId: null,
|
||||
};
|
||||
}
|
||||
if (command === 'append_local_permission_log') {
|
||||
return {};
|
||||
@@ -2601,13 +2606,38 @@ export function registerHomeProjectCreationTests() {
|
||||
await screen.findAllByText('项目权限策略拒绝了本次调用'),
|
||||
).not.toBeNull();
|
||||
expect(screen.queryAllByText(/permissionRejected/)).toHaveLength(0);
|
||||
// 入队没成立:只发一次命令,失败之后不自动重试、也不重放。
|
||||
// 入队没成立:被拒消息不得留下任何历史条目,也不得被乐观渲染成已成立的用户消息。
|
||||
expect(persistedMessages).toHaveLength(0);
|
||||
expect(screen.queryAllByText('生成一个游戏')).toHaveLength(0);
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'append_local_conversation_message',
|
||||
),
|
||||
).toHaveLength(0);
|
||||
// 入队没成立:只发一次命令,失败之后不自动重试。
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'enqueue_direct_codex_turn',
|
||||
),
|
||||
).toHaveLength(1);
|
||||
cleanup();
|
||||
|
||||
// 重进项目:被拒消息不得从历史里被重放,拒绝文案也不该被当成历史条目。
|
||||
render(
|
||||
React.createElement(App, {
|
||||
initialProjectPath: projectPath,
|
||||
initialProjectManifest: manifest,
|
||||
}),
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(screen.queryAllByText('生成一个游戏')).toHaveLength(0);
|
||||
});
|
||||
expect(screen.queryAllByText('项目权限策略拒绝了本次调用')).toHaveLength(0);
|
||||
expect(
|
||||
invoke.mock.calls.filter(
|
||||
([command]) => command === 'enqueue_direct_codex_turn',
|
||||
),
|
||||
).toHaveLength(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user