feat(coding): keep one ongoing conversation per delivered agent
This commit is contained in:
@@ -14,6 +14,9 @@ const api = vi.hoisted(() => ({
|
||||
cancel: vi.fn(),
|
||||
save: vi.fn(),
|
||||
events: vi.fn(),
|
||||
conversation: vi.fn(),
|
||||
sendConversation: vi.fn(),
|
||||
seenConversation: vi.fn(),
|
||||
}));
|
||||
vi.mock('@/lib/coding-teacher', () => ({
|
||||
teacherApi: api,
|
||||
@@ -676,8 +679,11 @@ describe('merged cloud teacher classroom', () => {
|
||||
{ teacher_id: 'algorithm', version: 9, definition: cloudDefinition, is_default: false },
|
||||
] });
|
||||
const selected = { ...topic('selected'), sourceConversationId: 'project', role: 'teacher' as const, definition: cloudDefinition, version: 9 };
|
||||
api.conversation.mockResolvedValue({ topic: null, before: null });
|
||||
api.create.mockResolvedValue(selected);
|
||||
api.send.mockImplementation(async (_base, _id, input: TeacherSend) => ({ ...selected, revision: 2, requests: [request({ id: input.requestId, text: input.text, response: '先看看玩家会做什么。' })] }));
|
||||
api.sendConversation.mockImplementation(async (_agent, input: TeacherSend) => ({ ...selected, revision: 2,
|
||||
conversation: {agentId: 'algorithm', segmentTurns: 1, discussions: {}, seenThrough: input.requestId},
|
||||
requests: [request({ id: input.requestId, text: input.text, response: '先看看玩家会做什么。' })] }));
|
||||
render(<TeacherChatPanel projectId="p" sourceId="c" selectedAgent={{ teacher_id: 'algorithm', version: 9, definition: cloudDefinition, is_default: false }} />);
|
||||
await waitFor(() => expect(screen.getByLabelText('向智能体提问')).toBeEnabled());
|
||||
expect(screen.queryByLabelText('新话题使用的智能体')).not.toBeInTheDocument();
|
||||
@@ -685,8 +691,8 @@ describe('merged cloud teacher classroom', () => {
|
||||
fireEvent.change(screen.getByLabelText('向智能体提问'), { target: { value: '我想做一个小游戏' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: '提问', exact: true }));
|
||||
await screen.findByText('先看看玩家会做什么。');
|
||||
expect(api.create).toHaveBeenCalledWith('p/agent-topics', undefined, undefined, 9);
|
||||
expect(api.send.mock.calls[0][2]).toMatchObject({ sourceConversationId: 'c', presentation: 'discussion-v1' });
|
||||
expect(api.create).not.toHaveBeenCalled();
|
||||
expect(api.sendConversation).toHaveBeenCalledWith('algorithm', expect.objectContaining({ projectId: 'p', sourceConversationId: 'c', presentation: 'discussion-v1' }));
|
||||
expect(screen.getByRole('heading', { name: '算法智能体' })).toBeVisible();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user