feat(teacher): stream Yuxi reasoning and answer previews
This commit is contained in:
1 parent
f443f3bc66
commit
8ccc4650a2
12 files changed
+364
-42
No files matched your search
@@ -180,3 +180,28 @@ describe('continuous agent panel', () => {
|
||||
expect(api.sendConversation).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it.each([undefined, 'suggestions'] as const)('updates reasoning and answer independently before completion (%s)', async intent => {
|
||||
let current = topic([{ ...request('streaming'), intent, presentation: 'reply-v1', status: 'running', response: '' }]);
|
||||
api.conversation.mockResolvedValue({ topic: current, before: null });
|
||||
api.seenConversation.mockImplementation(async () => current);
|
||||
await mount();
|
||||
await waitFor(() => expect(api.events).toHaveBeenCalled());
|
||||
const emit = async (patch: Partial<TeacherRequest>) => {
|
||||
current = { ...current, revision: current.revision + 1, requests: [{ ...current.requests[0], ...patch }] };
|
||||
await act(async () => stream.dispatchEvent(new MessageEvent('snapshot', { data: JSON.stringify(current) })));
|
||||
};
|
||||
await emit({ reasoning: '先读项目。' });
|
||||
expect(screen.getByTestId('teacher-reasoning')).toHaveAttribute('open');
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('先读项目。');
|
||||
await emit({ reasoning: '先读项目。再分析玩法。', response: '正在生成正文' });
|
||||
expect(screen.getByTestId('teacher-reply')).toHaveTextContent('正在生成正文');
|
||||
expect(screen.getByTestId('teacher-reply')).not.toHaveTextContent('再分析玩法');
|
||||
expect(screen.getByRole('button', { name: '停止回复' })).toBeEnabled();
|
||||
await emit({ status: 'completed', response: '完整正文', suggestedQuestions: ['再讲一个例子'] });
|
||||
expect(screen.getByTestId('teacher-reasoning')).not.toHaveAttribute('open');
|
||||
expect(screen.getByTestId('teacher-reply')).toHaveTextContent('完整正文');
|
||||
expect(screen.getByRole('button', { name: '再讲一个例子' })).toBeEnabled();
|
||||
fireEvent.click(screen.getByText('思考过程'));
|
||||
expect(screen.getByLabelText('智能体思考过程')).toHaveTextContent('再分析玩法。');
|
||||
});
|
||||
Reference in new issue
Block a user