fix(frontend): 对齐数据任务详情状态

This commit is contained in:
caoxiaozhu
2026-07-27 10:03:52 +08:00
parent b14b2ecf22
commit b4927a8952
6 changed files with 112 additions and 57 deletions

View File

@@ -3,6 +3,7 @@ import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import path from 'node:path'
import { parse as parseSfc } from '@vue/compiler-sfc'
import { dataProcessDisplayStatus } from '../src/utils/dataProcessStatus.js'
const scriptDir = path.dirname(fileURLToPath(import.meta.url))
const sourceRoot = path.resolve(scriptDir, '../src')
@@ -31,20 +32,20 @@ assert.match(source, /function documentCountLabel\(task: DataProcessTask\)[\s\S]
assert.match(source, /label="生成个数"[\s\S]*?generatedCountLabel\(row as DataProcessTask\)/, '任务列表没有展示真实生成数量')
assert.match(source, /function generatedCountLabel\(task: DataProcessTask\)[\s\S]*?`\$\{safeCount\(task\.output_count\)\} 条`/, '生成数量没有使用 output_count 或缺少单位')
assert.doesNotMatch(source, /label="源数据集"|label="输出数据集"/, '任务列表仍使用旧的数据集列标题')
for (const label of ['待生成', '生成中', '已生成', '已发布', '生成失败', '已停止']) {
assert.ok(source.includes(`label: '${label}'`), `任务状态缺少“${label}`)
}
assert.match(source, /task\.status === 'completed'[\s\S]*?task\.output_dataset_id[\s\S]*?已发布[\s\S]*?已生成/, '完成任务没有按当前轮输出指针区分已生成与已发布')
assert.doesNotMatch(source, /task\.output_datasets\?\.length[\s\S]*?已发布/, '上一轮保留的数据集不应将当前轮标记为已发布')
for (const [label, type] of [
['待生成', 'info'],
['生成中', 'primary'],
['已生成', 'warning'],
['已发布', 'success'],
['生成失败', 'danger'],
['已停止', 'info'],
]) {
assert.ok(source.includes(`label: '${label}', type: '${type}'`), `任务状态“${label}”颜色应为 ${type}`)
assert.match(source, /import \{ dataProcessDisplayStatus \} from '@\/utils\/dataProcessStatus\.js'/, '任务列表没有复用数据处理六态映射')
assert.match(source, /dataProcessDisplayStatus\(row as DataProcessTask\)\.type[\s\S]*?dataProcessDisplayStatus\(row as DataProcessTask\)\.label/, '任务列表状态标签没有使用公共映射')
const statusCases = [
[{ status: 'pending' }, { label: '待生成', type: 'info' }],
[{ status: 'running' }, { label: '生成中', type: 'primary' }],
[{ status: 'completed' }, { label: '已生成', type: 'warning' }],
[{ status: 'completed', output_datasets: [{ id: 'old-train' }] }, { label: '已生成', type: 'warning' }],
[{ status: 'completed', output_dataset_id: 'current-train' }, { label: '已发布', type: 'success' }],
[{ status: 'failed' }, { label: '生成失败', type: 'danger' }],
[{ status: 'stopped' }, { label: '已停止', type: 'info' }],
]
for (const [task, expected] of statusCases) {
assert.deepEqual(dataProcessDisplayStatus(task), expected, `任务六态映射错误:${task.status}`)
}
assert.match(apiSource, /export (?:async )?function getDataProcessTasks/, 'API 模块缺少任务列表方法')