Simplify Agent chat with inline attachments and separate thinking
This commit is contained in:
1 parent
7af43acebb
commit
faebfe9e84
18 files changed
+1558
-195
No files matched your search
@@ -91,7 +91,7 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
if (body.operation === 'submit' || body.operation === 'preview') return result({ request_id: input.request_id, thread_id: 'thread-1', run_id: 'run-1', version: '1', status: 'dispatched' });
|
||||
if (body.operation === 'history') return result({ thread_id: 'thread-1', next_offset: null,
|
||||
queued_requests: [], schedule_proposals: [{ id: 'proposal', name: '每天整理选题', prompt: '每天给我三个适合个人创作的选题', cron_expression: '30 8 * * *', timezone: 'Asia/Shanghai' }],
|
||||
messages: [{ id: 1, role: 'assistant', content: '## 创作建议\n先从一个真实的观察开始。\n\n' + '记录今天的一次观察,把具体场景、你的感受和想分享的发现写下来。\n\n'.repeat(22) }],
|
||||
messages: [{ id: 1, role: 'user', content: '先给我一些创作建议' }, { id: 2, role: 'assistant', content: '## 创作建议\n先从一个真实的观察开始。\n\n' + '记录今天的一次观察,把具体场景、你的感受和想分享的发现写下来。\n\n'.repeat(22) }],
|
||||
run: { agent_run_id: 'run-1', request_id: 'request-1', thread_id: 'thread-1', status: 'completed', version: '1' } });
|
||||
if (body.operation === 'viewed') return result({ viewed: true });
|
||||
if (body.operation === 'attachments') return result({ attachments: [] });
|
||||
@@ -266,12 +266,17 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
expect(await messageOperations()).toEqual([]);
|
||||
await expect(formalChat.getByRole('heading', { name: 'Hi,今天想聊些什么?', exact: true })).toBeVisible();
|
||||
await expect(formalChat.locator('.agent-chat-welcome').getByRole('img', { name: '我的写作搭档头像', exact: true })).toHaveAttribute('src', avatar.icon_url);
|
||||
const conversationSources = page.getByRole('navigation', { name: '对话来源', exact: true });
|
||||
const sourceBounds = await conversationSources.getByRole('button', { name: '客户端对话', exact: true }).boundingBox();
|
||||
const adjustBounds = await conversationSources.getByRole('button', { name: '调整智能体', exact: true }).boundingBox();
|
||||
expect(sourceBounds).not.toBeNull();
|
||||
expect(adjustBounds).not.toBeNull();
|
||||
expect(Math.abs(sourceBounds!.y + sourceBounds!.height / 2 - adjustBounds!.y - adjustBounds!.height / 2)).toBeLessThanOrEqual(1);
|
||||
const expectCleanChat = async () => {
|
||||
await expect(page.getByRole('navigation', { name: '对话来源', exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole('textbox', { name: '名称', exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: /^(已保存|保存草稿|已应用|应用最新修改|调整智能体|修改头像|修改名称|查看历史对话|新对话|客户端对话|微信对话)$/ })).toHaveCount(0);
|
||||
await expect(page.locator('.agent-chat-toolbar')).toHaveCount(0);
|
||||
await expect(page.getByText('和助手聊一聊', { exact: true })).toHaveCount(0);
|
||||
await expect(page.getByText(/由创建者支付词元点数/)).toHaveCount(0);
|
||||
};
|
||||
await expectCleanChat();
|
||||
await expect(editor.locator('header').getByRole('heading', { name: '我的写作搭档', exact: true })).toBeVisible();
|
||||
await expect(editor.locator('header').getByRole('img', { name: '我的写作搭档头像', exact: true })).toHaveAttribute('src', avatar.icon_url);
|
||||
const example = formalChat.locator('.agent-chat-example').first();
|
||||
const exampleText = await example.innerText();
|
||||
await example.click();
|
||||
@@ -283,6 +288,14 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
await formalChat.getByRole('button', { name: '发送', exact: true }).click();
|
||||
await expect(formalChat.getByRole('heading', { name: '创作建议' })).toBeAttached();
|
||||
expect(await messageOperations()).toEqual(['submit']);
|
||||
const userBubble = formalChat.locator('.agent-chat-message[data-role="user"]');
|
||||
await expect(userBubble).toHaveText(/先给我一些创作建议/);
|
||||
const bubbleStyle = await userBubble.evaluate(element => {
|
||||
const style = getComputedStyle(element);
|
||||
return { background: style.backgroundColor, radius: Number.parseFloat(style.borderTopLeftRadius) };
|
||||
});
|
||||
expect(bubbleStyle.background).not.toBe('rgba(0, 0, 0, 0)');
|
||||
expect(bubbleStyle.radius).toBeGreaterThan(0);
|
||||
await expect(formalChat.locator('.agent-chat-message[data-role="assistant"]').getByRole('img', { name: '我的写作搭档头像', exact: true })).toHaveAttribute('src', avatar.icon_url);
|
||||
await expect(formalChat.getByLabel('消息', { exact: true })).toBeInViewport();
|
||||
const transcriptBounds = await formalChat.getByTestId('cloud-chat-messages').boundingBox();
|
||||
@@ -294,7 +307,8 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
await app.evaluate(({ BrowserWindow }) => { const win = BrowserWindow.getAllWindows()[0]; win.setSize(980, 680); win.webContents.setZoomFactor(1.5); });
|
||||
await expect(formalChat.getByTestId('cloud-chat-composer')).toBeInViewport({ ratio: 1 });
|
||||
await expect(formalChat.getByRole('button', { name: '发送', exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(conversationSources.getByRole('button', { name: '调整智能体', exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(page.getByRole('button', { name: '返回智能体列表', exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expectCleanChat();
|
||||
await expect.poll(() => editor.evaluate(el => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect.poll(() => formalChat.getByTestId('cloud-chat-messages').evaluate(el => el.clientHeight)).toBeGreaterThanOrEqual(80);
|
||||
// Chromium screenshots can crop a zoomed Electron surface. Capture the
|
||||
@@ -305,7 +319,8 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
});
|
||||
await writeFile(testInfo.outputPath('cloud-agent-chat-compact-window.png'), Buffer.from(compactWindowImage, 'base64'));
|
||||
await app.evaluate(({ BrowserWindow }) => { const win = BrowserWindow.getAllWindows()[0]; win.webContents.setZoomFactor(1); win.setSize(1366, 768); });
|
||||
await page.getByRole('button', { name: '调整智能体', exact: true }).click();
|
||||
await page.getByRole('button', { name: '返回智能体列表', exact: true }).click();
|
||||
await page.getByRole('article', { name: '我的写作搭档', exact: true }).getByRole('button', { name: '调整', exact: true }).click();
|
||||
await expect(prompt).toHaveValue(initialPrompt);
|
||||
await page.getByLabel('名称', { exact: true }).fill('我的新版写作搭档');
|
||||
await expect(page.getByRole('button', { name: '应用最新修改', exact: true })).toBeDisabled();
|
||||
@@ -316,6 +331,7 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
await editor.getByRole('button', { name: '我的智能体', exact: true }).click();
|
||||
await page.getByRole('article', { name: '我的新版写作搭档', exact: true }).getByRole('button', { name: '和它聊聊', exact: true }).click();
|
||||
await expect(formalChat).toBeVisible();
|
||||
await expectCleanChat();
|
||||
await expect(page.getByRole('button', { name: /^(聊天|自动任务|使用与接入)$/ })).toHaveCount(0);
|
||||
expect(await messageOperations()).toEqual(['submit']);
|
||||
await page.screenshot({ path: testInfo.outputPath('cloud-agent-separate-chat.png') });
|
||||
|
||||
Reference in new issue
Block a user