feat: add Code-style voice composer to current Agents trial
This commit is contained in:
1 parent
7c51bb4a00
commit
f61efaf046
60 files changed
+3383
-1286
No files matched your search
@@ -5,6 +5,7 @@ import { CloudApproval, CloudChat } from '@/pages/CloudAgents/CloudChat';
|
||||
import { AgentRequirements } from '@/pages/CloudAgents/AgentRequirements';
|
||||
import { CloudAccessPanel as AccessPanel } from '@/pages/CloudAgents/CloudAccess';
|
||||
|
||||
import { AppError } from '@/lib/error-model';
|
||||
import { useCloudPublication } from '@/pages/CloudAgents/useCloudPublication';
|
||||
|
||||
function CloudAccessPanel(props: { slug: string; revision: number; onPublished: () => void }) {
|
||||
@@ -43,7 +44,7 @@ it('starts private use through the existing publication action and retains its i
|
||||
let attempts = 0;
|
||||
api.call.mockImplementation(async (operation, input) => {
|
||||
if (operation === 'access') return { published_version: published ? 1 : null, enabled: true, versions: [], grants: [], applications: [] };
|
||||
if (operation === 'publish') { if (++attempts === 1) throw new Error('连接中断'); published = true; return { version: 1, draft_revision: input.expected_revision }; }
|
||||
if (operation === 'publish') { if (++attempts === 1) throw new AppError('NETWORK', '连接中断', undefined, { commandOutcome: 'unknown' }); published = true; return { version: 1, draft_revision: input.expected_revision }; }
|
||||
if (operation === 'costs') return { items: [], next_offset: null, summary: {} };
|
||||
if (operation === 'channelBindings') return { items: [] };
|
||||
return base(operation, input);
|
||||
@@ -53,9 +54,9 @@ it('starts private use through the existing publication action and retains its i
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: '确认开始使用' })).toBeEnabled());
|
||||
expect(screen.queryByLabelText('应用名称')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button', { name: '确认开始使用' }));
|
||||
await screen.findByText(/连接中断/);
|
||||
await screen.findByText(/网络可能不稳定,请再点一次「应用」。/);
|
||||
view.rerender(<CloudAccessPanel slug={slug} revision={3} onPublished={onPublished} />);
|
||||
fireEvent.click(screen.getByRole('button', { name: '重试本次发布' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '应用' }));
|
||||
await screen.findByText('助手已准备好');
|
||||
const publications = api.call.mock.calls.filter(([operation]) => operation === 'publish');
|
||||
expect(publications).toHaveLength(2);
|
||||
@@ -65,6 +66,24 @@ it('starts private use through the existing publication action and retains its i
|
||||
expect(api.call.mock.calls.some(([operation]) => operation === 'share' || operation === 'createApplication')).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ status: 401, code: 'session_expired', message: '请重新登录' },
|
||||
{ status: 403, code: 'access_revoked', message: '无权使用这个智能体' },
|
||||
{ status: 409, code: 'draft_revision_conflict', message: '云端草稿已更新' },
|
||||
{ status: 422, code: 'invalid_input', message: '请选择模型' },
|
||||
{ status: 429, code: 'cloud_service_unavailable', message: '请求过于频繁,请稍后再试' },
|
||||
])('keeps the actual application rejection for HTTP $status', async ({ status, code, message }) => {
|
||||
api.call.mockImplementation(async operation => {
|
||||
if (operation === 'access') return { published_version: null, enabled: true, versions: [], grants: [], applications: [] };
|
||||
throw new AppError('UNKNOWN', message, undefined, { status, backendCode: code, commandOutcome: 'unknown' });
|
||||
});
|
||||
render(<CloudAccessPanel slug={slug} revision={2} onPublished={vi.fn()} />);
|
||||
await waitFor(() => expect(screen.getByRole('button', { name: '确认开始使用' })).toBeEnabled());
|
||||
fireEvent.click(screen.getByRole('button', { name: '确认开始使用' }));
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent(message);
|
||||
expect(screen.getByRole('alert')).not.toHaveTextContent('网络可能不稳定');
|
||||
});
|
||||
|
||||
it('preserves the entire prompt when displaying and editing former style instruction lines', () => {
|
||||
const initial = '我的规则\n\n 保留缩进和解释。\n使用简单易懂的语言,遇到新词先解释。\n把任务拆成小步骤,一次引导我完成一步。\n先给我提示和思考问题,让我尝试后再补充答案。\n';
|
||||
const edited = '先给我提示和思考问题,让我尝试后再补充答案。\n\n 我的新规则\n使用简单易懂的语言,遇到新词先解释。\n把任务拆成小步骤,一次引导我完成一步。\n\n';
|
||||
|
||||
Reference in new issue
Block a user