1737903ec7
- 删除 17 个被测模块已不存在的测试(api-field-schemas / build-chunk-planner /
polling-state-machine 等),套件 94 -> 77 文件
- polling-unknown-status 只保留仍接线的 useTaskProgressLoop 两条,去掉状态机用例
- endpoints 快照重钉 218 -> 215(漂移恰好等于外观专利 parsed-payload/queue-payload/
activate 三个下线端点,无新增、无取值变化)
- brand-rows-version-wiring 的轻量失败回退断言改用 [^}] 锁进 catch 体内:
原窗口会跨过 catch 右花括号读到后面正常分支的 return { taskIds, force: true },
删掉回退也照样绿;五处变异(三页 heavyIds = ids + 外观页两种写法)现全部转红
- appearance-patent-failed-status 改为断言公共映射 taskStatusClass('FAILED')
46 lines
2.2 KiB
TypeScript
46 lines
2.2 KiB
TypeScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readFileSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import { resolve, dirname } from 'node:path'
|
|
import { taskStatusClass } from '../src/shared/utils/task-status-text.ts'
|
|
|
|
const here = dirname(fileURLToPath(import.meta.url))
|
|
const tabSource = readFileSync(
|
|
resolve(here, '../src/pages/brand/components/BrandAppearancePatentTab.vue'),
|
|
'utf-8',
|
|
)
|
|
|
|
function functionBody(name: string): string {
|
|
const match = tabSource.match(new RegExp(`function ${name}\\([\\s\\S]*?\\n\\}`))
|
|
assert.ok(match, `找不到函数 ${name}`)
|
|
return match[0]
|
|
}
|
|
|
|
// 心跳超时判死的任务(taskStatus=FAILED)后台检测可能仍在跑、结果文件稍后生成。
|
|
// 此时状态文案必须是"失败"而不是"结果生成中",否则用户会以为任务还在执行、放弃等待/下载(2026-09-28 29473/29479)。
|
|
test('test_failed_status_wins_over_result_preparing', () => {
|
|
const body = functionBody('statusText')
|
|
const failedIdx = body.indexOf("'FAILED'")
|
|
const preparingIdx = body.indexOf('isResultPreparing(item)')
|
|
assert.ok(failedIdx >= 0, 'statusText 缺少 FAILED 分支')
|
|
assert.ok(preparingIdx >= 0, 'statusText 缺少 isResultPreparing 分支')
|
|
assert.ok(failedIdx < preparingIdx, 'FAILED 必须在 isResultPreparing(结果生成中)之前判定')
|
|
})
|
|
|
|
test('test_failed_class_wins_over_running', () => {
|
|
const body = functionBody('statusClass')
|
|
const failedIdx = body.indexOf("=== 'FAILED'")
|
|
const runningIdx = body.indexOf('isResultPreparing(item)')
|
|
assert.ok(failedIdx >= 0 && runningIdx >= 0)
|
|
assert.ok(failedIdx < runningIdx, 'FAILED 必须先于 isResultPreparing 判为 failed 样式')
|
|
assert.match(body, /taskStatusClass\('FAILED'\)/, 'FAILED 样式必须由公共映射产出')
|
|
assert.equal(taskStatusClass('FAILED'), 'failed', '公共映射里 FAILED 应产出 failed 样式')
|
|
})
|
|
|
|
test('test_failed_hint_marks_task_failed_and_download_later', () => {
|
|
const body = functionBody('pendingResultHint')
|
|
assert.match(body, /'FAILED'\s*\?\s*'任务已失败'/, '提示文案应按 FAILED 切换为任务已失败')
|
|
assert.match(body, /下载按钮稍后出现/, '失败后仍提示结果文件生成后会给出下载按钮')
|
|
})
|