feat(consultation): unify server-distributed agents without fixed roles

This commit is contained in:
2026-09-24 11:56:42 +08:00
parent 248776d855
commit 8a157be4f6
35 changed files with 625 additions and 668 deletions

View File

@@ -256,7 +256,7 @@ describe('CodingChatPanel first Conversation', () => {
expect(conversationApi.submit).not.toHaveBeenCalled();
});
it('keeps the operation draft when switching work tabs and reopening separate teacher and friend drafts', async () => {
it('keeps operation and distributed-agent drafts separate across tabs and reopening', async () => {
localStorage.clear();
projectApi.list.mockResolvedValue({ projects: [project], activeProjectId: project.id });
projectApi.config.mockResolvedValue({ project, config });
@@ -296,8 +296,8 @@ describe('CodingChatPanel first Conversation', () => {
expect(operationInput).toBeVisible();
expect(operationInput).toHaveValue('我想先自己试一试');
fireEvent.click(screen.getByRole('button', { name: '老师', exact: true }));
const teacherInput = await screen.findByRole('textbox', { name: '向老师提问' });
fireEvent.click(screen.getByRole('button', { name: '智能体', exact: true }));
const teacherInput = await screen.findByRole('textbox', { name: '向智能体提问' });
expect(workTab).toHaveAttribute('aria-selected', 'true');
expect(operationInput).not.toBeVisible();
expect(operationInput).toHaveValue('我想先自己试一试');
@@ -306,23 +306,12 @@ describe('CodingChatPanel first Conversation', () => {
fireEvent.click(chatTab);
expect(operationInput).toBeVisible();
expect(teacherInput).toHaveValue('怎样判断规则清不清楚?');
fireEvent.click(screen.getByRole('button', { name: '朋友', exact: true }));
expect(chatTab).toHaveAttribute('aria-selected', 'true');
const friendInput = await screen.findByRole('textbox', { name: '向朋友提问' });
await waitFor(() => expect(friendInput).toBeEnabled());
expect(friendInput).toHaveValue('');
fireEvent.change(friendInput, { target: { value: '第一次玩的感受是什么?' } });
fireEvent.click(screen.getByRole('button', { name: '关闭朋友' }));
expect(screen.queryByTestId('teacher-chat-panel')).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '朋友', exact: true }));
expect(screen.getByRole('textbox', { name: '向朋友提问' })).toHaveValue('第一次玩的感受是什么?');
fireEvent.click(screen.getByRole('button', { name: '老师', exact: true }));
expect(workTab).toHaveAttribute('aria-selected', 'true');
expect(screen.getByRole('textbox', { name: '向老师提问' })).toHaveValue('怎样判断规则清不清楚?');
expect(screen.getByRole('button', { name: '老师', exact: true })).toHaveAttribute('aria-expanded', 'true');
expect(screen.getByRole('button', { name: '朋友', exact: true })).toHaveAttribute('aria-expanded', 'false');
expect(operationInput).toHaveValue('我想先自己试一试');
expect(screen.queryByText(/记一下|项目共识|记入共识/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '关闭智能体' }));
expect(screen.queryByRole('button', { name: '朋友', exact: true })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '智能体', exact: true }));
expect(screen.getByRole('textbox', { name: '向智能体提问' })).toHaveValue('怎样判断规则清不清楚?');
fireEvent.click(screen.getByRole('button', { name: '关闭智能体' }));
expect(screen.getByRole('button', { name: '智能体', exact: true })).toHaveAttribute('aria-expanded', 'false');
expect(consultationCreate).not.toHaveBeenCalled();
expect(consultationSend).not.toHaveBeenCalled();
expect(conversationApi.submit).not.toHaveBeenCalled();