fix(agents): surface unapplied draft changes and publish action
This commit is contained in:
@@ -12,6 +12,7 @@ test('personal cloud Agent creation, draft save and leave protection in Electron
|
||||
BrowserWindow.getAllWindows()[0].setSize(1366, 768);
|
||||
let draft: Record<string, unknown> | null = null;
|
||||
let recent: unknown = null;
|
||||
const versions: { version: number; draft_revision: number; created_at: string }[] = [];
|
||||
let knowledgeCatalogLoads = 0;
|
||||
let knowledgeCreated = false;
|
||||
let knowledgeUploaded = false;
|
||||
@@ -68,8 +69,8 @@ test('personal cloud Agent creation, draft save and leave protection in Electron
|
||||
if (body.operation === 'channelSelfCallers') return result({ items: [] });
|
||||
if (body.operation === 'channelBindings') return result({ items: [], available_accounts: [] });
|
||||
if (body.operation === 'threads') return result({ threads: [], next_offset: null });
|
||||
if (body.operation === 'publish') { if (draft) draft.published_version = 1; return result({ version: 1, draft_revision: 2 }); }
|
||||
if (body.operation === 'access') return result({ published_version: draft?.published_version, enabled: true, share_url: 'niancode://agents/' + draft?.slug, versions: [], grants: [], applications: [] });
|
||||
if (body.operation === 'publish') { const version = versions.length + 1; if (draft) draft.published_version = version; versions.push({ version, draft_revision: input.expected_revision, created_at: new Date().toISOString() }); return result({ version, draft_revision: input.expected_revision }); }
|
||||
if (body.operation === 'access') return result({ published_version: draft?.published_version, enabled: true, share_url: 'niancode://agents/' + draft?.slug, versions, grants: [], applications: [] });
|
||||
if (body.operation === 'costs') return result({ items: [], next_offset: null, unit: '词元点数', summary: { count: 0, settled_points: '0.00', pending_points: '0.00' } });
|
||||
if (body.operation === 'schedules') return result({ jobs });
|
||||
if (body.operation === 'createSchedule') { const job = { ...input, id: 'job-1', agent_slug: draft?.slug, next_run_at: '2026-09-11T01:00:00Z', runs: [] }; jobs.push(job); return result(job); }
|
||||
@@ -272,6 +273,21 @@ test('personal cloud Agent creation, draft save and leave protection in Electron
|
||||
await page.getByRole('button', { name: '确认开始使用' }).click();
|
||||
await expect(page.getByRole('region', { name: '智能体对话', exact: true })).toBeVisible();
|
||||
await expect(page.getByRole('region', { name: '智能体对话', exact: true }).getByRole('heading', { name: '创作建议' })).toHaveCount(0);
|
||||
await page.getByRole('button', { name: '编辑', exact: true }).click();
|
||||
await page.getByLabel('名称', { exact: true }).fill('我的新版写作搭档');
|
||||
await expect(page.getByRole('button', { name: '应用最新修改', exact: true })).toBeDisabled();
|
||||
await page.getByRole('button', { name: '保存草稿', exact: true }).click();
|
||||
await expect(page.getByText('修改已保存,尚未应用', { exact: true })).toBeVisible();
|
||||
const applyButton = page.getByRole('button', { name: '应用最新修改', exact: true });
|
||||
await expect(applyButton).toBeInViewport();
|
||||
await page.screenshot({ path: testInfo.outputPath('cloud-agent-apply-visible.png') });
|
||||
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].setSize(1024, 768));
|
||||
await expect(applyButton).toBeInViewport();
|
||||
await page.screenshot({ path: testInfo.outputPath('cloud-agent-apply-compact.png') });
|
||||
await applyButton.click();
|
||||
await expect(page.getByRole('button', { name: '已应用', exact: true })).toBeDisabled();
|
||||
await expect(page.getByText('修改已保存,尚未应用', { exact: true })).toHaveCount(0);
|
||||
await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0].setSize(1366, 768));
|
||||
await page.getByRole('button', { name: '对话', exact: true }).click();
|
||||
await page.getByRole('region', { name: '智能体对话', exact: true }).getByLabel('消息', { exact: true }).fill('每天早上八点半给我三个创作方向');
|
||||
await page.getByRole('region', { name: '智能体对话', exact: true }).getByRole('button', { name: '发送', exact: true }).click();
|
||||
|
||||
Reference in New Issue
Block a user