feat(studio): 补齐剩余工作台聚合接口与真实对接
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import ElementPlus from 'element-plus';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import StudioDashboardPage from '../StudioDashboardPage.vue';
|
||||
import { getStudioDashboard } from '@/api/studioDashboard';
|
||||
|
||||
vi.mock('@/api/studioDashboard', () => ({
|
||||
getStudioDashboard: vi.fn(() =>
|
||||
Promise.resolve({
|
||||
resultcode: '0',
|
||||
message: null,
|
||||
data: {
|
||||
projectName: 'Common Agent Studio',
|
||||
environment: 'Dev',
|
||||
publishStatus: 'DRAFT',
|
||||
lifecycleSteps: [
|
||||
{ name: '知识接入', description: '上传、解析、切片、向量化', status: 'done' },
|
||||
{ name: '能力编排', description: 'Workflow 连接模型、工具与 Skill', status: 'running' },
|
||||
],
|
||||
readinessChecklist: [
|
||||
{ label: '知识库已绑定 Embedding 模型', done: true },
|
||||
{ label: 'Workflow 已存在可编辑草稿', done: false },
|
||||
],
|
||||
metrics: {
|
||||
todayRunCount: 27,
|
||||
successRate: 96.4,
|
||||
p50Latency: '1.28s',
|
||||
estimatedCost: '¥4.82',
|
||||
},
|
||||
recentRuns: [
|
||||
{ id: 'req-1001', name: '售前问答 Agent', type: 'Agent', status: '成功', latency: '1.42s', cost: '¥0.018' },
|
||||
],
|
||||
warningTitle: '生产发布前仍需确认路由兜底',
|
||||
warningMessage: 'AGENT_PLAN 任务建议补齐 fallback 模型和最大延迟阈值后再发布。',
|
||||
},
|
||||
}),
|
||||
),
|
||||
}));
|
||||
|
||||
describe('StudioDashboardPage', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('loads dashboard aggregate from backend api', async () => {
|
||||
const wrapper = mount(StudioDashboardPage, {
|
||||
global: {
|
||||
plugins: [ElementPlus],
|
||||
},
|
||||
});
|
||||
|
||||
await flushPromises();
|
||||
|
||||
expect(getStudioDashboard).toHaveBeenCalled();
|
||||
expect(wrapper.text()).toContain('Common Agent Studio');
|
||||
expect(wrapper.text()).toContain('96.4%');
|
||||
expect(wrapper.text()).toContain('售前问答 Agent');
|
||||
expect(wrapper.text()).toContain('AGENT_PLAN 任务建议补齐 fallback 模型');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user