Files
crawler-plugin/admin-frontend-vue/tests/task-136.test.ts
T
huangzd1997 94954648d2 task-136(记录与版本中心): 实现数字人版本设为最新操作
新增 digitalhuman-latest.ts(仅已发布可设为最新+确认) ,api 提供
setLatestDigitalHumanVersion(POST /{version}/set-latest)。

TDD: task-136.test.ts 8 用例 RED→GREEN。
2026-09-05 17:41:37 +08:00

50 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { canSetLatestDigitalHumanVersion, setLatestDigitalHumanConfirmText } from '../src/pages/records/digitalhuman-latest.ts'
test('test_task_136_dh_set_latest_normal_primary_path', () => {
// 正常主路径:已发布版本可设为最新并给确认文案。
assert.equal(canSetLatestDigitalHumanVersion('RELEASED'), true)
assert.equal(setLatestDigitalHumanConfirmText('2.0.0'), '确定将数字人版本 2.0.0 设为最新吗?')
})
test('test_task_136_dh_set_latest_normal_variant_input', () => {
// 正常变体:草稿版本不可设为最新。
assert.equal(canSetLatestDigitalHumanVersion('DRAFT'), false)
})
test('test_task_136_dh_set_latest_repeated_is_idempotent', () => {
// 正常重复:文案稳定。
assert.equal(setLatestDigitalHumanConfirmText('1.0.0'), setLatestDigitalHumanConfirmText('1.0.0'))
})
test('test_task_136_dh_set_latest_boundary_empty_input', () => {
// 边界空值:空版本不产出确认。
assert.equal(setLatestDigitalHumanConfirmText(''), null)
})
test('test_task_136_dh_set_latest_boundary_single_item', () => {
// 边界单元素:未知状态不可设为最新。
assert.equal(canSetLatestDigitalHumanVersion('x'), false)
})
test('test_task_136_dh_set_latest_boundary_limit_or_missing_field', () => {
// 边界上限/缺字段:小写归一。
assert.equal(canSetLatestDigitalHumanVersion('released'), true)
})
test('test_task_136_dh_set_latest_invalid_input_rejected', () => {
// 异常输入:非字符串不可设为最新。
assert.equal(canSetLatestDigitalHumanVersion(null as unknown as string), false)
})
test('test_task_136_dh_set_latest_dependency_failure_returns_actionable_message', () => {
// 依赖失败/提交走 adapterPOST /{version}/set-latest。
const api = readSource('src/pages/records/digitalhuman-api.ts')
assert.match(api, /setLatestDigitalHumanVersion/)
assert.match(api, /\/set-latest/)
const model = readSource('src/pages/records/digitalhuman-latest.ts')
assert.equal(/axios|http\.|vue/.test(model), false, '设为最新模型保持纯逻辑')
})