diff --git a/admin-frontend-vue/src/pages/records/digitalhuman-api.ts b/admin-frontend-vue/src/pages/records/digitalhuman-api.ts index 2355cf1b..32e9405f 100644 --- a/admin-frontend-vue/src/pages/records/digitalhuman-api.ts +++ b/admin-frontend-vue/src/pages/records/digitalhuman-api.ts @@ -19,3 +19,13 @@ export async function uploadDigitalHumanVersion(form: DigitalHumanUploadForm, fi if (form.file) body.append('file', form.file as unknown as Blob, filename || (form.file.name || 'dh.zip')) await http.post(`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/upload`, body) } + +/** 发布数字人版本:POST /{version}/release。 */ +export async function releaseDigitalHumanVersion(version: string): Promise { + await http.post(`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/${encodeURIComponent(version)}/release`) +} + +/** 设为最新版本:POST /{version}/set-latest。 */ +export async function setLatestDigitalHumanVersion(version: string): Promise { + await http.post(`${DIGITAL_HUMAN_VERSIONS_ENDPOINT}/${encodeURIComponent(version)}/set-latest`) +} diff --git a/admin-frontend-vue/src/pages/records/digitalhuman-release.ts b/admin-frontend-vue/src/pages/records/digitalhuman-release.ts new file mode 100644 index 00000000..91634a05 --- /dev/null +++ b/admin-frontend-vue/src/pages/records/digitalhuman-release.ts @@ -0,0 +1,13 @@ +/** 数字人版本发布操作(任务 135):可发布判定与确认文案;纯逻辑。 */ +import { normalizeDigitalHumanStatus } from './digitalhuman-dto.ts' + +/** 仅草稿版本可发布。 */ +export function canReleaseDigitalHumanVersion(status: unknown): boolean { + return normalizeDigitalHumanStatus(status) === 'DRAFT' +} + +/** 发布确认文案;空版本返回 null。 */ +export function releaseDigitalHumanConfirmText(version: string): string | null { + const v = (version || '').trim() + return v ? `确定发布数字人版本 ${v} 吗?` : null +} diff --git a/admin-frontend-vue/tests/task-135.test.ts b/admin-frontend-vue/tests/task-135.test.ts new file mode 100644 index 00000000..55449131 --- /dev/null +++ b/admin-frontend-vue/tests/task-135.test.ts @@ -0,0 +1,49 @@ +import test from 'node:test' +import assert from 'node:assert/strict' +import { readSource } from './helpers.ts' +import { canReleaseDigitalHumanVersion, releaseDigitalHumanConfirmText } from '../src/pages/records/digitalhuman-release.ts' + +test('test_task_135_dh_release_normal_primary_path', () => { + // 正常主路径:草稿版本可发布并给出确认文案。 + assert.equal(canReleaseDigitalHumanVersion('DRAFT'), true) + assert.equal(releaseDigitalHumanConfirmText('1.0.0'), '确定发布数字人版本 1.0.0 吗?') +}) + +test('test_task_135_dh_release_normal_variant_input', () => { + // 正常变体:已发布版本不再提示可发布。 + assert.equal(canReleaseDigitalHumanVersion('RELEASED'), false) +}) + +test('test_task_135_dh_release_repeated_is_idempotent', () => { + // 正常重复:文案稳定。 + assert.equal(releaseDigitalHumanConfirmText('1.0.0'), releaseDigitalHumanConfirmText('1.0.0')) +}) + +test('test_task_135_dh_release_boundary_empty_input', () => { + // 边界空值:空版本不产出确认。 + assert.equal(releaseDigitalHumanConfirmText(''), null) +}) + +test('test_task_135_dh_release_boundary_single_item', () => { + // 边界单元素:未知状态按不可发布处理。 + assert.equal(canReleaseDigitalHumanVersion('x'), false) +}) + +test('test_task_135_dh_release_boundary_limit_or_missing_field', () => { + // 边界上限/缺字段:小写归一。 + assert.equal(canReleaseDigitalHumanVersion('draft'), true) +}) + +test('test_task_135_dh_release_invalid_input_rejected', () => { + // 异常输入:非字符串状态不可发布。 + assert.equal(canReleaseDigitalHumanVersion(null as unknown as string), false) +}) + +test('test_task_135_dh_release_dependency_failure_returns_actionable_message', () => { + // 依赖失败/提交走 adapter:POST /{version}/release。 + const api = readSource('src/pages/records/digitalhuman-api.ts') + assert.match(api, /releaseDigitalHumanVersion/) + assert.match(api, /\/release/) + const model = readSource('src/pages/records/digitalhuman-release.ts') + assert.equal(/axios|http\.|vue/.test(model), false, '发布模型保持纯逻辑') +})