feat: add Code-style voice composer to current Agents trial

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 19:12:35 +08:00
1 parent 7c51bb4a00
commit f61efaf046
60 files changed
+3383 -1286

No files matched your search

+8 -7
View File
@@ -1,6 +1,7 @@
import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { createMemoryRouter, RouterProvider } from 'react-router-dom';
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
import { AppError } from '@/lib/error-model';
import CloudAgents from '@/pages/CloudAgents';
import { EMPTY_CLOUD_CONFIGURATION } from '../../shared/cloud-agents';
@@ -149,17 +150,17 @@ it('retries an uncertain activation with the original operation and keeps pendin
const base = api.call.getMockImplementation()!;
let attempts = 0;
api.call.mockImplementation(async (operation, input) => {
if (operation === 'publish' && ++attempts === 1) throw new Error('连接中断');
if (operation === 'publish' && ++attempts === 1) throw new AppError('NETWORK', '连接中断', undefined, { commandOutcome: 'unknown' });
return base(operation, input);
});
await openConfiguration();
fireEvent.click(screen.getByRole('button', { name: '开始使用', exact: true }));
await screen.findByText(/连接中断/);
await screen.findByText(/网络可能不稳定,请再点一次「应用」。/);
expect(screen.queryByRole('region', { name: '智能体对话' })).not.toBeInTheDocument();
const unload = new Event('beforeunload', { cancelable: true });
window.dispatchEvent(unload);
expect(unload.defaultPrevented).toBe(true);
fireEvent.click(screen.getByRole('button', { name: '重试开始使用', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '应用', exact: true }));
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
expect(publications()).toHaveLength(2);
expect(publications()[1][1]).toEqual(publications()[0][1]);
@@ -180,7 +181,7 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
versions: activated ? [{ version: 1, draft_revision: 3, created_at: '' }] : [],
};
if (operation === 'publish') {
if (++attempts === 1) throw new Error('连接中断');
if (++attempts === 1) throw new AppError('NETWORK', '连接中断', undefined, { commandOutcome: 'unknown' });
activated = true;
current = { ...current, published_version: 1 };
return { version: 1, draft_revision: input.expected_revision };
@@ -189,11 +190,11 @@ it('keeps a newer saved revision unapplied when retry resolves the original unce
});
await openConfiguration();
fireEvent.click(screen.getByRole('button', { name: '开始使用', exact: true }));
await screen.findByText(/连接中断/);
await screen.findByText(/网络可能不稳定,请再点一次「应用」。/);
fireEvent.change(screen.getByLabelText('提示词'), { target: { value: '这次新保存的要求' } });
fireEvent.click(screen.getByRole('button', { name: '保存草稿', exact: true }));
await waitFor(() => expect(screen.getByRole('button', { name: '已保存', exact: true })).toBeDisabled());
fireEvent.click(screen.getByRole('button', { name: '重试开始使用', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '应用', exact: true }));
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
expect(screen.queryByRole('button', { name: '应用最新修改', exact: true })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '返回智能体列表', exact: true }));
@@ -225,7 +226,7 @@ it('keeps successful activation and conversation when the following status read
expect(await screen.findByRole('region', { name: '智能体对话' })).toBeVisible();
await waitFor(() => expect(api.call.mock.calls.filter(([operation]) => operation === 'access')).toHaveLength(2));
expect(screen.queryByRole('button', { name: '已应用', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '重试开始使用', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '应用', exact: true })).not.toBeInTheDocument();
expect(screen.queryByText(/状态刷新失败/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: '返回智能体列表', exact: true }));
fireEvent.click(await screen.findByRole('button', { name: '调整', exact: true }));