From 94954648d2aec426a72a750490b8e230dd3c6e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sat, 5 Sep 2026 17:41:37 +0800 Subject: [PATCH] =?UTF-8?q?task-136(=E8=AE=B0=E5=BD=95=E4=B8=8E=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=B8=AD=E5=BF=83):=20=E5=AE=9E=E7=8E=B0=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E4=BA=BA=E7=89=88=E6=9C=AC=E8=AE=BE=E4=B8=BA=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增 digitalhuman-latest.ts(仅已发布可设为最新+确认) ,api 提供 setLatestDigitalHumanVersion(POST /{version}/set-latest)。 TDD: task-136.test.ts 8 用例 RED→GREEN。 --- .../src/pages/records/digitalhuman-latest.ts | 11 +++++ admin-frontend-vue/tests/task-136.test.ts | 49 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 admin-frontend-vue/src/pages/records/digitalhuman-latest.ts create mode 100644 admin-frontend-vue/tests/task-136.test.ts diff --git a/admin-frontend-vue/src/pages/records/digitalhuman-latest.ts b/admin-frontend-vue/src/pages/records/digitalhuman-latest.ts new file mode 100644 index 00000000..ece535d0 --- /dev/null +++ b/admin-frontend-vue/src/pages/records/digitalhuman-latest.ts @@ -0,0 +1,11 @@ +/** 数字人版本设为最新操作(任务 136):仅已发布版本可设为最新;纯逻辑。 */ + +export function canSetLatestDigitalHumanVersion(status: unknown): boolean { + return typeof status === 'string' && status.trim().toUpperCase() === 'RELEASED' +} + +/** 设为最新确认文案;空版本返回 null。 */ +export function setLatestDigitalHumanConfirmText(version: string): string | null { + const v = (version || '').trim() + return v ? `确定将数字人版本 ${v} 设为最新吗?` : null +} diff --git a/admin-frontend-vue/tests/task-136.test.ts b/admin-frontend-vue/tests/task-136.test.ts new file mode 100644 index 00000000..7e99dfec --- /dev/null +++ b/admin-frontend-vue/tests/task-136.test.ts @@ -0,0 +1,49 @@ +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', () => { + // 依赖失败/提交走 adapter:POST /{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, '设为最新模型保持纯逻辑') +})