feat: 统一恢复管理端列表上下文
- 统一列表路由状态、分页初始化与安全返回契约 - 接入知识库、工作流、插件、审批、Skill、Agent、Bot、反馈和定时任务链路 - 补齐公共能力与关键返回路径自动化测试
This commit is contained in:
@@ -1,78 +1,59 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
function readViewSource(relativePath: string) {
|
||||
return readFileSync(resolve('app/src/views', relativePath), 'utf8');
|
||||
const workspaceViews = resolve('app/src/views');
|
||||
const viewsRoot = existsSync(workspaceViews)
|
||||
? workspaceViews
|
||||
: resolve('src/views');
|
||||
return readFileSync(resolve(viewsRoot, relativePath), 'utf8');
|
||||
}
|
||||
|
||||
describe('detail return navigation', () => {
|
||||
it.each([
|
||||
['system/sysFeedback/sysFeedbackDetail.vue', '/sys/sysFeedback'],
|
||||
['system/sysJob/SysJobLogList.vue', '/sys/sysJob'],
|
||||
['ai/workflow/WorkflowDesign.vue', '/ai/workflow'],
|
||||
['ai/workflow/components/WorkflowChatPage.vue', '/ai/workflow'],
|
||||
['ai/workflow/execute/WorkflowExecResultList.vue', '/ai/workflow'],
|
||||
])('returns %s to its fixed parent list', (relativePath, parentPath) => {
|
||||
const source = readViewSource(relativePath);
|
||||
[
|
||||
'ai/documentCollection/DocumentCollection.vue',
|
||||
'ai/documentCollection/Document.vue',
|
||||
],
|
||||
['ai/skill/SkillList.vue', 'ai/skill/SkillDetail.vue'],
|
||||
['ai/agents/AgentList.vue', 'ai/agents/AgentDesigner.vue'],
|
||||
['ai/bots/index.vue', 'ai/bots/pages/setting/index.vue'],
|
||||
[
|
||||
'system/approval/ApprovalManage.vue',
|
||||
'system/approval/ApprovalDetail.vue',
|
||||
],
|
||||
['system/sysJob/SysJobList.vue', 'system/sysJob/SysJobLogList.vue'],
|
||||
[
|
||||
'system/sysFeedback/sysFeedbackList.vue',
|
||||
'system/sysFeedback/sysFeedbackDetail.vue',
|
||||
],
|
||||
['ai/workflow/WorkflowList.vue', 'ai/workflow/WorkflowDesign.vue'],
|
||||
[
|
||||
'ai/workflow/WorkflowList.vue',
|
||||
'ai/workflow/components/WorkflowChatPage.vue',
|
||||
],
|
||||
['ai/plugin/Plugin.vue', 'ai/plugin/PluginTools.vue'],
|
||||
['ai/plugin/PluginToolTable.vue', 'ai/plugin/PluginToolEdit.vue'],
|
||||
])(
|
||||
'passes an exact return target from %s and validates it in %s',
|
||||
(listPath, detailPath) => {
|
||||
expect(readViewSource(listPath)).toContain('withListReturnTo');
|
||||
expect(readViewSource(detailPath)).toContain('navigateBackToList');
|
||||
},
|
||||
);
|
||||
|
||||
expect(source).not.toMatch(/router\.(?:back|go)\s*\(/);
|
||||
expect(source).toContain(`path: '${parentPath}'`);
|
||||
});
|
||||
|
||||
it('returns approval details to the originating approval tab', () => {
|
||||
const detailSource = readViewSource('system/approval/ApprovalDetail.vue');
|
||||
const listSource = readViewSource('system/approval/ApprovalManage.vue');
|
||||
|
||||
expect(detailSource).not.toMatch(/router\.(?:back|go)\s*\(/);
|
||||
expect(detailSource).toContain("path: '/sys/approval'");
|
||||
expect(detailSource).toContain('query: { tab }');
|
||||
expect(listSource).toContain('tab: activeTab.value');
|
||||
});
|
||||
|
||||
it('returns workflow design to the originating list page and filters', () => {
|
||||
const detailSource = readViewSource('ai/workflow/WorkflowDesign.vue');
|
||||
const listSource = readViewSource('ai/workflow/WorkflowList.vue');
|
||||
|
||||
expect(detailSource).toContain(
|
||||
'parseWorkflowDesignReturnState(route.query)',
|
||||
);
|
||||
expect(detailSource).toContain(
|
||||
'query: buildWorkflowListRouteQuery(listState)',
|
||||
);
|
||||
expect(listSource).toContain('buildWorkflowDesignReturnQuery');
|
||||
expect(listSource).toContain('getPageState');
|
||||
});
|
||||
|
||||
it('returns plugin tool editing to its plugin tool list with a safe fallback', () => {
|
||||
const editSource = readViewSource('ai/plugin/PluginToolEdit.vue');
|
||||
const toolsSource = readViewSource('ai/plugin/PluginTools.vue');
|
||||
const pluginListSource = readViewSource('ai/plugin/Plugin.vue');
|
||||
const listSource = readViewSource('ai/plugin/PluginToolTable.vue');
|
||||
|
||||
expect(editSource).not.toMatch(/router\.(?:back|go)\s*\(/);
|
||||
expect(editSource).toContain("path: '/ai/plugin/tools'");
|
||||
expect(editSource).toContain("path: '/ai/plugin'");
|
||||
expect(editSource).toContain('buildPluginToolsRouteQueryFromEdit');
|
||||
expect(toolsSource).toContain('parsePluginToolsReturnState');
|
||||
expect(toolsSource).toContain('buildPluginListRouteQuery');
|
||||
expect(pluginListSource).toContain('buildPluginToolsReturnQuery');
|
||||
expect(listSource).toContain('pluginId: props.pluginId');
|
||||
expect(listSource).toContain('...route.query');
|
||||
});
|
||||
|
||||
it('returns execution steps to the filtered execution record list', () => {
|
||||
const stepSource = readViewSource(
|
||||
'ai/workflow/execute/WorkflowExecStepList.vue',
|
||||
);
|
||||
it('preserves the nested execution-record list before opening a step', () => {
|
||||
const recordSource = readViewSource(
|
||||
'ai/workflow/execute/WorkflowExecResultList.vue',
|
||||
);
|
||||
const stepSource = readViewSource(
|
||||
'ai/workflow/execute/WorkflowExecStepList.vue',
|
||||
);
|
||||
|
||||
expect(stepSource).not.toMatch(/router\.(?:back|go)\s*\(/);
|
||||
expect(stepSource).toContain("name: 'ExecRecord'");
|
||||
expect(stepSource).toContain('query: workflowId ? { workflowId } : {}');
|
||||
expect(recordSource).toContain('workflowId: $route.query.workflowId');
|
||||
expect(recordSource).toContain('withListReturnTo(currentListFullPath())');
|
||||
expect(stepSource).toContain('navigateBackToList');
|
||||
expect(stepSource).toContain("['/ai/workflow/executeRecords']");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user