build(trial): preserve deployed source for knowledge refresh
This commit is contained in:
1 parent
8e0e52f30e
commit
2d4e44f4a0
42 files changed
+2321
-283
No files matched your search
@@ -18,8 +18,10 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
let draft: Record<string, unknown> | null = null;
|
||||
let recent: unknown = null;
|
||||
let createInput: Record<string, unknown> | null = null;
|
||||
const creationInputs: Record<string, unknown>[] = [];
|
||||
let pending: Record<string, unknown>[] = [];
|
||||
const operations: string[] = [];
|
||||
Reflect.set(globalThis, '__cloudAgentUiFixture', { snapshot: () => ({ draft, createInput, operations }) });
|
||||
Reflect.set(globalThis, '__cloudAgentUiFixture', { snapshot: () => ({ draft, createInput, creationInputs, operations }) });
|
||||
const versions: { version: number; draft_revision: number; created_at: string }[] = [];
|
||||
let knowledgeCatalogLoads = 0;
|
||||
let knowledgeCreated = false;
|
||||
@@ -51,14 +53,15 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
knowledgeUploaded = true;
|
||||
return result({ ...knowledgeFile, status: 'uploaded', chunk_count: 0, available: false, processing_task: null });
|
||||
}
|
||||
if (path.endsWith('/recovery')) return result({ recent, pending: [] });
|
||||
if (path.endsWith('/recovery')) return result({ recent, pending });
|
||||
if (path.endsWith('/recovery/pending') && body.discard === true) { pending = []; return result({ discarded: true }); }
|
||||
if (path.endsWith('/recovery/recent')) { recent = body; return result({ saved: true }); }
|
||||
if (path.endsWith('/actions')) {
|
||||
operations.push(body.operation);
|
||||
const input = body.input ?? {};
|
||||
if (body.operation === 'catalog') return result({
|
||||
models: [{ id: 'test-model', name: '创作模型', description: '模型说明不应显示在配置页' }, { id: 'reasoning-model', name: '思考模型' }],
|
||||
resources: { tools: [{ key: 'fixture-tool', name: '资料整理工具' }], skills: [{ key: 'fixture-skill', name: '文章整理 Skill' }] },
|
||||
resources: { tools: [{ key: 'fixture-tool', name: '资料整理工具' }, { key: 'web_search', name: '上网查资料', description: '在网上查找相关信息。' }], skills: [{ key: 'fixture-skill', name: '文章整理 Skill' }, { key: 'deep-research', name: '查资料,做研究', description: '比较不同说法,再整理出结论和出处。' } ] },
|
||||
pricing: { unit: '词元点数', usage_unit: '词元', unit_size: 1000, points_per_unit: '9.99', version: 1 },
|
||||
});
|
||||
if (body.operation === 'knowledge') return result({ databases: knowledgeCreated ? [{ kb_id: 'kb', name: '我的创作资料' }] : [], models: ++knowledgeCatalogLoads === 1 ? [] : [{ id: 'fixture:test-embedding', name: '资料向量模型', dimension: 1024 }] });
|
||||
@@ -98,7 +101,19 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
if (body.operation === 'files') return result({ files: [] });
|
||||
throw new Error('Unexpected cloud fixture operation ' + body.operation);
|
||||
}
|
||||
if (method === 'POST') { createInput = body; draft = {
|
||||
if (method === 'POST') {
|
||||
creationInputs.push(body);
|
||||
if (creationInputs.length === 1) return { ok: true, data: { status: 422, ok: false,
|
||||
json: { error: '名称没有被接受,请修改后重试', code: 'invalid_name', commandOutcome: 'definitive_failure' } } };
|
||||
if (creationInputs.length === 2) {
|
||||
pending = [{ id: `createAgent::${body.operation_id}`, operation: 'createAgent', input: body, created_at: new Date().toISOString() }];
|
||||
return { ok: true, data: { status: 502, ok: false,
|
||||
json: { error: '暂时无法确认创建结果', code: 'cloud_service_unavailable', commandOutcome: 'unknown' } } };
|
||||
}
|
||||
if (creationInputs.length === 3) return { ok: true, data: { status: 422, ok: false,
|
||||
json: { error: '名称没有被接受,请稍后重试', code: 'invalid_name', commandOutcome: 'definitive_failure' } } };
|
||||
pending = [];
|
||||
createInput = body; draft = {
|
||||
slug: 'ml-' + 'a'.repeat(32), name: body.name, purpose: body.purpose, system_prompt: body.purpose,
|
||||
icon: body.icon ?? null, icon_url: body.icon === uploadedAvatar.icon ? uploadedAvatar.icon_url : null,
|
||||
draft_revision: 1, updated_at: '2026-09-10T00:00:00Z',
|
||||
@@ -161,11 +176,26 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
await expect(page.getByRole('button', { name: '上一步', exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole('button', { name: '下一步', exact: true })).toBeDisabled();
|
||||
await page.screenshot({ path: testInfo.outputPath('cloud-agent-create-empty-form.png') });
|
||||
await page.getByLabel('名称', { exact: true }).fill('我的写作搭档');
|
||||
await page.getByLabel('名称', { exact: true }).fill('待修改的名字');
|
||||
await page.getByRole('button', { name: '上传头像', exact: true }).click();
|
||||
await expect(page.getByRole('img', { name: '我的写作搭档头像', exact: true })).toHaveAttribute('src', avatar.icon_url);
|
||||
await expect(page.getByRole('img', { name: '待修改的名字头像', exact: true })).toHaveAttribute('src', avatar.icon_url);
|
||||
await page.screenshot({ path: testInfo.outputPath('cloud-agent-create-identity.png') });
|
||||
await page.getByRole('button', { name: '下一步', exact: true }).click();
|
||||
await expect(page.getByRole('alert')).toContainText('创建失败');
|
||||
await expect(page.getByLabel('名称', { exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole('button', { name: '更换头像', exact: true })).toBeEnabled();
|
||||
await expect(page.getByRole('complementary', { name: '未确认的云端操作' })).toHaveCount(0);
|
||||
await page.getByLabel('名称', { exact: true }).fill('我的写作搭档');
|
||||
await page.getByRole('button', { name: '下一步', exact: true }).click();
|
||||
await expect(page.getByLabel('名称', { exact: true })).toBeDisabled();
|
||||
await expect(page.getByRole('button', { name: '更换头像', exact: true })).toBeDisabled();
|
||||
await expect(page.getByRole('complementary', { name: '未确认的云端操作' })).toBeVisible();
|
||||
await page.getByRole('button', { name: '移除提醒', exact: true }).click();
|
||||
await expect(page.getByRole('complementary', { name: '未确认的云端操作' })).toHaveCount(0);
|
||||
await page.getByRole('button', { name: '重试创建', exact: true }).click();
|
||||
await expect(page.getByRole('alert')).toContainText('创建结果暂未确认');
|
||||
await expect(page.getByLabel('名称', { exact: true })).toBeDisabled();
|
||||
await page.getByRole('button', { name: '重试创建', exact: true }).click();
|
||||
|
||||
const editor = page.getByTestId('cloud-agent-editor');
|
||||
const instructionsTab = page.getByRole('tab', { name: '介绍与提示词', exact: true });
|
||||
@@ -189,6 +219,10 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
const created = await fixtureState();
|
||||
expect(created.createInput).toMatchObject({ name: '我的写作搭档', icon: avatar.icon, purpose: '' });
|
||||
expect(created.createInput).not.toHaveProperty('icon_url');
|
||||
expect(created.creationInputs).toHaveLength(4);
|
||||
expect(created.creationInputs[0].operation_id).not.toBe(created.creationInputs[1].operation_id);
|
||||
expect(created.creationInputs[1]).toEqual(created.creationInputs[2]);
|
||||
expect(created.creationInputs[1]).toEqual(created.creationInputs[3]);
|
||||
expect(await messageOperations()).toEqual([]);
|
||||
|
||||
await page.getByRole('button', { name: '修改头像', exact: true }).click();
|
||||
@@ -214,7 +248,11 @@ test('personal cloud Agent identity, configuration and separate published chat i
|
||||
await expect(page.getByRole('heading', { name: '费用上限', exact: true })).toHaveCount(0);
|
||||
await expect(page.getByRole('heading', { name: '运行限制', exact: true })).toHaveCount(0);
|
||||
await page.getByRole('button', { name: '选择工具箱', exact: true }).click();
|
||||
await expect(page.getByRole('checkbox', { name: /上网查资料.*在网上查找相关信息/ })).toBeVisible();
|
||||
await page.getByRole('checkbox', { name: '资料整理工具', exact: true }).check();
|
||||
await page.getByRole('button', { name: '选择做事手册', exact: true }).click();
|
||||
await page.getByLabel('搜索做事手册', { exact: true }).fill('出处');
|
||||
await expect(page.getByRole('checkbox', { name: /查资料,做研究.*出处/ })).toBeVisible();
|
||||
await instructionsTab.click();
|
||||
await expect(introduction).toHaveValue('一起梳理故事和文章');
|
||||
await expect(prompt).toHaveValue(initialPrompt);
|
||||
|
||||
Reference in new issue
Block a user