feat(trial): assemble completed Agent workspace updates
This commit is contained in:
1 parent
8289f27f3e
commit
7c51bb4a00
38 files changed
+2081
-276
No files matched your search
@@ -41,7 +41,7 @@ async function open(preview = false) {
|
||||
|
||||
it('shows reasoning without an answer, preserves manual folding during deltas and folds final history once', async () => {
|
||||
await open(); await emit({ reasoning_content: '流式思考' });
|
||||
const details = screen.getByTestId('cloud-chat-reasoning');
|
||||
const details = screen.getByTestId('cloud-message-process');
|
||||
expect(details).toHaveAttribute('open'); expect(screen.queryByRole('heading', { name: 'Hi,今天想聊些什么?' })).not.toBeInTheDocument();
|
||||
act(() => { details.removeAttribute('open'); fireEvent(details, new Event('toggle')); });
|
||||
await emit({ reasoning_content: '第二段', content: '流式回答' }, '2-0');
|
||||
@@ -51,8 +51,8 @@ it('shows reasoning without an answer, preserves manual folding during deltas an
|
||||
history = { ...history, run: { ...run, status: 'completed' }, messages: [savedAssistant()] };
|
||||
await emit({}, '2-0', 'end');
|
||||
await screen.findByText('完整回答');
|
||||
expect(screen.getAllByTestId('cloud-chat-reasoning')).toHaveLength(1);
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).not.toHaveAttribute('open');
|
||||
expect(screen.getAllByTestId('cloud-message-process')).toHaveLength(1);
|
||||
expect(screen.getByTestId('cloud-message-process')).not.toHaveAttribute('open');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('完整思考');
|
||||
expect(screen.queryByText('流式回答')).not.toBeInTheDocument();
|
||||
});
|
||||
@@ -65,7 +65,7 @@ it('keeps partial thought and answer when terminal history fails and excludes la
|
||||
await screen.findByText('历史暂时离线');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('已收思考');
|
||||
expect(screen.getByText('已收片段')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).not.toHaveAttribute('open');
|
||||
expect(screen.getByTestId('cloud-message-process')).not.toHaveAttribute('open');
|
||||
await emit({ reasoning_content: '另一线程' }, '2-0', 'messages', { thread_id: 'other-thread' });
|
||||
expect(screen.getByLabelText('智能体思考过程')).not.toHaveTextContent('另一线程');
|
||||
});
|
||||
@@ -78,8 +78,8 @@ it('restores only assistant reasoning from completed history and shows no block
|
||||
] };
|
||||
render(<CloudChat slug={slug} />);
|
||||
await screen.findByText('完整回答');
|
||||
expect(screen.getAllByTestId('cloud-chat-reasoning')).toHaveLength(1);
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).not.toHaveAttribute('open');
|
||||
expect(screen.getAllByTestId('cloud-message-process')).toHaveLength(1);
|
||||
expect(screen.getByTestId('cloud-message-process')).not.toHaveAttribute('open');
|
||||
expect(screen.queryByText('不属于用户显示的思考')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('系统字段')).not.toBeInTheDocument();
|
||||
expect(api.events).not.toHaveBeenCalled();
|
||||
@@ -88,9 +88,9 @@ it('restores only assistant reasoning from completed history and shows no block
|
||||
it('clears live reasoning on a new conversation and ignores its obsolete stream', async () => {
|
||||
await open(true); await emit({ reasoning_content: '旧对话思考' });
|
||||
fireEvent.click(screen.getByRole('button', { name: '新对话' }));
|
||||
await waitFor(() => expect(screen.queryByTestId('cloud-chat-reasoning')).not.toBeInTheDocument());
|
||||
await waitFor(() => expect(screen.queryByTestId('cloud-message-process')).not.toBeInTheDocument());
|
||||
await emit({ reasoning_content: '旧事件迟到' }, '2-0');
|
||||
expect(screen.queryByTestId('cloud-chat-reasoning')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('cloud-message-process')).not.toBeInTheDocument();
|
||||
expect(api.call.mock.calls.some(call => ['submit', 'preview'].includes(call[0]))).toBe(false);
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ it('hydrates a final message that is saved after its terminal Run stops the runn
|
||||
history = { ...history, messages: [savedAssistant('迟到保存的思考')] };
|
||||
await act(async () => { await vi.advanceTimersByTimeAsync(2000); });
|
||||
expect(screen.getByText('完整回答')).toBeInTheDocument();
|
||||
expect(screen.getAllByTestId('cloud-chat-reasoning')).toHaveLength(1);
|
||||
expect(screen.getAllByTestId('cloud-message-process')).toHaveLength(1);
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('迟到保存的思考');
|
||||
expect(screen.queryByText('还没落盘的回答')).not.toBeInTheDocument();
|
||||
expect(api.call.mock.calls.some(call => ['submit', 'preview'].includes(call[0]))).toBe(false);
|
||||
@@ -157,8 +157,8 @@ it('ignores a pending history read when approval resumes the same request in a n
|
||||
run_id: 'run-2', thread_id: 'thread-1', request_id: 'request-1', payload: { chunk: { stream_event: { type: 'message_delta', message_id: 'message-2', reasoning_content: '操作后的思考' } } },
|
||||
}) })));
|
||||
await act(async () => { resolveOld({ ...history, run: { ...run, status: 'interrupted' } }); });
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('操作前的思考');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('操作后的思考');
|
||||
expect(screen.getAllByLabelText('智能体思考过程').map(item => item.textContent).join('')).toContain('操作前的思考');
|
||||
expect(screen.getAllByLabelText('智能体思考过程').map(item => item.textContent).join('')).toContain('操作后的思考');
|
||||
expect(screen.queryByRole('button', { name: '允许执行', exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '停止回答', exact: true })).toBeInTheDocument();
|
||||
});
|
||||
@@ -176,7 +176,7 @@ it('reopens a resumed same-Run stream and ignores its obsolete interrupted histo
|
||||
return base(operation, input);
|
||||
});
|
||||
await emit({}, '2-0', 'end');
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).not.toHaveAttribute('open');
|
||||
expect(screen.getByTestId('cloud-message-process')).not.toHaveAttribute('open');
|
||||
const resumedStream = new Stream(); api.events.mockResolvedValue(resumedStream);
|
||||
await act(async () => { fireEvent.click(screen.getByRole('button', { name: '允许执行', exact: true })); });
|
||||
await waitFor(() => expect(api.events).toHaveBeenLastCalledWith('run-1', '2-0'));
|
||||
@@ -186,13 +186,13 @@ it('reopens a resumed same-Run stream and ignores its obsolete interrupted histo
|
||||
type: 'message_delta', message_id: 'message-2', reasoning_content: '恢复后的思考', content: '恢复后的回答',
|
||||
} } },
|
||||
}) })));
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).toHaveAttribute('open');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('操作前的思考');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('恢复后的思考');
|
||||
expect(screen.getAllByTestId('cloud-message-process').every(item => !item.hasAttribute('open'))).toBe(true);
|
||||
expect(screen.getAllByLabelText('智能体思考过程').map(item => item.textContent).join('')).toContain('操作前的思考');
|
||||
expect(screen.getAllByLabelText('智能体思考过程').map(item => item.textContent).join('')).toContain('恢复后的思考');
|
||||
expect(screen.getByText(/恢复后的回答/)).toBeInTheDocument();
|
||||
await act(async () => { resolveOld({ ...history, run: { ...run, status: 'interrupted' }, messages: [savedAssistant()] }); });
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('恢复后的思考');
|
||||
expect(screen.getByTestId('cloud-chat-reasoning')).toHaveAttribute('open');
|
||||
expect(screen.getAllByLabelText('智能体思考过程').map(item => item.textContent).join('')).toContain('恢复后的思考');
|
||||
expect(screen.getAllByTestId('cloud-message-process').every(item => !item.hasAttribute('open'))).toBe(true);
|
||||
expect(screen.getByRole('button', { name: '停止回答', exact: true })).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: '允许执行', exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('完整回答')).not.toBeInTheDocument();
|
||||
@@ -215,12 +215,12 @@ it('ignores a late approval receipt after the user discards input and starts a n
|
||||
await waitFor(() => expect(api.call.mock.calls.some(([operation]) => operation === 'resume')).toBe(true));
|
||||
fireEvent.click(screen.getByRole('button', { name: '新对话', exact: true }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: '放弃内容', exact: true }));
|
||||
expect(screen.queryByTestId('cloud-chat-reasoning')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('cloud-message-process')).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: '问它一个小问题' })).toBeInTheDocument();
|
||||
await act(async () => { resolveResume({ run_id: 'resumed-old-run', status: 'running' }); });
|
||||
expect(screen.queryByRole('button', { name: '停止回答', exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole('button', { name: '允许执行', exact: true })).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('cloud-chat-reasoning')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('cloud-message-process')).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('heading', { name: '问它一个小问题' })).toBeInTheDocument();
|
||||
expect(api.events).not.toHaveBeenCalledWith('resumed-old-run');
|
||||
expect(api.events).toHaveBeenCalledTimes(1);
|
||||
|
||||
Reference in new issue
Block a user