2026-07-10 17:13:23 +08:00
|
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
|
import { readFile } from 'node:fs/promises'
|
|
|
|
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
|
|
import path from 'node:path'
|
|
|
|
|
|
|
|
|
|
|
|
const scriptDir = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
|
|
const typesPath = path.resolve(scriptDir, '../src/types/index.ts')
|
|
|
|
|
|
const dataPath = path.resolve(scriptDir, '../src/mock/data.ts')
|
|
|
|
|
|
const viewPath = path.resolve(scriptDir, '../src/views/dataset/DatasetListView.vue')
|
|
|
|
|
|
|
|
|
|
|
|
const [typesSource, dataSource, viewSource] = await Promise.all([
|
|
|
|
|
|
readFile(typesPath, 'utf8'),
|
|
|
|
|
|
readFile(dataPath, 'utf8'),
|
|
|
|
|
|
readFile(viewPath, 'utf8'),
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
assert.match(typesSource, /export type DatasetSource = 'upload' \| 'task'/)
|
|
|
|
|
|
assert.match(typesSource, /source\?: DatasetSource/)
|
|
|
|
|
|
|
|
|
|
|
|
assert.equal((dataSource.match(/source: 'upload'/g) || []).length, 6)
|
|
|
|
|
|
assert.equal((dataSource.match(/source: 'task'/g) || []).length, 4)
|
|
|
|
|
|
|
|
|
|
|
|
for (const name of [
|
|
|
|
|
|
'客服对话清洗集',
|
|
|
|
|
|
'通用指令构造集',
|
|
|
|
|
|
'用户反馈脱敏集',
|
|
|
|
|
|
'多轮对话增强集',
|
|
|
|
|
|
]) {
|
|
|
|
|
|
const datasetLine = dataSource.split('\n').find((line) => line.includes(`name: '${name}'`))
|
|
|
|
|
|
assert.ok(datasetLine, `缺少数据任务 Mock:${name}`)
|
|
|
|
|
|
assert.match(datasetLine, /source: 'task'/, `${name} 必须标记为数据任务来源`)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-25 17:04:21 +08:00
|
|
|
|
assert.match(viewSource, /route\.query\.tab === 'task' \? 'task' : 'upload'/)
|
|
|
|
|
|
assert.doesNotMatch(viewSource, /hasSplitCounts|splitLabels/)
|
|
|
|
|
|
assert.match(viewSource, /DATASET_TYPE_MAP\[String\(row\.type\)\.toLowerCase\(\)\]/)
|
2026-07-10 17:13:23 +08:00
|
|
|
|
assert.match(
|
|
|
|
|
|
viewSource,
|
|
|
|
|
|
/if \(activeTab\.value === 'task'\) \{\s*return dataList\.value\.filter\(\(item\) => item\.source === 'task'\)\s*\}/,
|
|
|
|
|
|
)
|
|
|
|
|
|
assert.match(viewSource, /return dataList\.value\.filter\(\(item\) => item\.source !== 'task'\)/)
|
|
|
|
|
|
assert.doesNotMatch(viewSource, /数据任务产生的数据集[\s\S]*?return \[\]/)
|
|
|
|
|
|
|
|
|
|
|
|
console.log('数据任务 Mock 数据与页签分流回归检查通过')
|