test(studio): add live agent create e2e
This commit is contained in:
parent
765bf749f2
commit
9d5430b62c
File diff suppressed because one or more lines are too long
@ -5,5 +5,5 @@
|
||||
- **目标(owner 职责)**:链路编排 / 上下文组装 / 生成 / 分析 / 全书解析 / 质量门控 / AI 候选(Suggestion)/ 规划候选 / 风险标记 / Quality Result / 运行记录;承载 Protection Node(grant)与 Quality Policy。
|
||||
- **边界(不可违反)**:**只产 Shadow,绝不直写 Canonical**;只消费服务端签发的 Runtime Permission Envelope,不能自授权;grant 与 runtime **包级隔离**;守 BC 边界不碰他域 `.dal`([bc-boundaries](../../.agents/rules/bc-boundaries.md);历史违例 `ContentMuseWorkOwnerFacade` **已整改消除**——改消费 content `MuseContentWorkOwnerApi`,门禁已收紧、无豁免)。
|
||||
- **out-of-scope**:Accept Suggestion(归 content BC)、正文写入。
|
||||
- **现状**:只读评估 72%;后端真实较高质量(无 stub),`RealNewApiMuseAiRuntimeClient` 真打 New-API,SSE 已脱占位。
|
||||
- **关键风险 / TODO**:真实 New-API 未端到端验收;前端 agent 仍有部分 MSW/活体覆盖缺口。SSE `event:` 解析漂移已修复并有 targeted Vitest 证据(2026-06-19:`sse.test.ts` + `AIPanel.contract.test.tsx` 17/17);`muse-module-ai-contract-server` 空壳孤儿 submodule 已清理(2026-06-19:从 AI reactor 移除并删除唯一 pom,`P1rAiRouteOwnershipTest` 加回潮门禁)。
|
||||
- **现状**:只读评估 72%;后端真实较高质量(无 stub),`RealNewApiMuseAiRuntimeClient` 真打 New-API,SSE 已脱占位;studio `/agents` 已补自建智能体写路活体证(2026-06-19:`agent-create.spec.ts` MSW-off 真单体 1/1,DB 证 `muse_agent` user/owner=1/active + command/audit)。
|
||||
- **关键风险 / TODO**:真实 New-API 未端到端验收;前端 agent 仍缺“运行试用/槽位绑定”等外部或多状态深链活体覆盖。SSE `event:` 解析漂移已修复并有 targeted Vitest 证据(2026-06-19:`sse.test.ts` + `AIPanel.contract.test.tsx` 17/17);`muse-module-ai-contract-server` 空壳孤儿 submodule 已清理(2026-06-19:从 AI reactor 移除并删除唯一 pom,`P1rAiRouteOwnershipTest` 加回潮门禁)。
|
||||
|
||||
45
muse-studio/e2e/agent-create.spec.ts
Normal file
45
muse-studio/e2e/agent-create.spec.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { expect, test, type Page } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* 智能体创建 e2e(真实后端,MSW off)。
|
||||
*
|
||||
* 只覆盖“新建智能体 → 真实 POST → 列表回显”,刻意不点击“运行试用”,避免把 New-API 外部依赖带入本切片。
|
||||
*/
|
||||
const TOKEN = 'test1';
|
||||
|
||||
async function seedToken(page: Page): Promise<void> {
|
||||
await page.addInitScript((t) => {
|
||||
window.localStorage.setItem('accessToken', t);
|
||||
window.localStorage.setItem('tenantId', '1');
|
||||
}, TOKEN);
|
||||
}
|
||||
|
||||
test('用户可在真实后端创建自建智能体并在列表回显', async ({ page }) => {
|
||||
await seedToken(page);
|
||||
const uniqueName = `活体智能体-e2e-${Date.now()}`;
|
||||
|
||||
await page.goto('/agents');
|
||||
await expect(page.getByRole('heading', { name: '智能体工作台' })).toBeVisible({ timeout: 15_000 });
|
||||
|
||||
await page.getByRole('button', { name: '新建智能体' }).click();
|
||||
await page.getByPlaceholder('例如:角色口吻校对员').fill(uniqueName);
|
||||
await page.getByPlaceholder('说明智能体适合的写作场景').fill('Playwright 活体验收创建的自建智能体');
|
||||
await page.getByPlaceholder('写下能力目标、输入要求、输出格式和禁止越权范围')
|
||||
.fill('只做结构化润色建议,不写入作品事实。');
|
||||
|
||||
const createResponsePromise = page.waitForResponse((response) =>
|
||||
response.url().includes('/app-api/muse/agents') &&
|
||||
response.request().method() === 'POST' &&
|
||||
response.status() === 201
|
||||
);
|
||||
await page.getByRole('button', { name: '创建智能体' }).click();
|
||||
|
||||
const createResponse = await createResponsePromise;
|
||||
const createBody = await createResponse.json();
|
||||
expect(createBody.code).toBe(0);
|
||||
expect(createBody.data?.agentId).toBeTruthy();
|
||||
|
||||
await expect(page.getByRole('button', { name: '关闭创建' })).toBeHidden({ timeout: 15_000 });
|
||||
await expect(page.getByRole('button', { name: new RegExp(`${uniqueName} v1`) })).toBeVisible({ timeout: 15_000 });
|
||||
await expect(page.getByText('我创建的').first()).toBeVisible();
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user