64 lines
2.4 KiB
TypeScript
64 lines
2.4 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { readSource } from './helpers.ts'
|
|
import {
|
|
imageVideoGeneratedAt,
|
|
imageVideoHasDisplayUrl,
|
|
toImageVideoRow,
|
|
type ImageVideoCard,
|
|
type ImageVideoRow,
|
|
} from '../src/pages/tasks/image-video-model.ts'
|
|
|
|
/** 对齐 admin.js:1328-1353 renderImageVideoCard:任务模式/生成时间(completed||submitted)/调试链接复制/下载禁用。 */
|
|
|
|
function row(overrides: Partial<ImageVideoRow> = {}): ImageVideoRow {
|
|
return {
|
|
taskId: '1',
|
|
username: '张三',
|
|
groupName: 'A组',
|
|
status: 'RUNNING',
|
|
cozeStatus: '',
|
|
cozeExecuteId: '',
|
|
videos: [],
|
|
videoUrl: '',
|
|
debugUrl: '',
|
|
archiveStatus: '',
|
|
archiveError: '',
|
|
...overrides,
|
|
}
|
|
}
|
|
|
|
test('align_image_video_mode_parsed_from_row', () => {
|
|
const task = toImageVideoRow({ task_id: 7, mode: 'text2video' })
|
|
assert.equal(task?.mode, 'text2video')
|
|
assert.equal(toImageVideoRow({ task_id: 8 })?.mode, undefined)
|
|
})
|
|
|
|
test('align_image_video_generated_at_completed_first', () => {
|
|
assert.equal(imageVideoGeneratedAt(row({ submittedAt: '2026-09-01 10:00:00', completedAt: '2026-09-01 10:05:00' })), '2026-09-01 10:05:00')
|
|
assert.equal(imageVideoGeneratedAt(row({ submittedAt: '2026-09-01 10:00:00' })), '2026-09-01 10:00:00')
|
|
assert.equal(imageVideoGeneratedAt(row()), '-')
|
|
})
|
|
|
|
test('align_image_video_has_display_url', () => {
|
|
const card: ImageVideoCard = {
|
|
key: '1:0',
|
|
task: row(),
|
|
video: { sourceUrl: '', archivedUrl: '', displayUrl: 'https://cdn/1.mp4', objectKey: '', archiveStatus: '', archiveError: '' },
|
|
videoIndex: 0,
|
|
}
|
|
assert.equal(imageVideoHasDisplayUrl(card), true)
|
|
assert.equal(imageVideoHasDisplayUrl({ ...card, video: null }), false)
|
|
})
|
|
|
|
test('align_image_video_page_card_info_wiring', () => {
|
|
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
|
|
assert.match(page, /任务模式/, '卡片补任务模式信息行')
|
|
assert.match(page, /所属分组/, '卡片信息行对齐参考')
|
|
assert.match(page, /生成时间/, '生成时间口径 completed||submitted')
|
|
assert.match(page, /imageVideoGeneratedAt/, '生成时间走纯模型')
|
|
assert.match(page, /调试链接/, '卡片补调试链接行')
|
|
assert.match(page, /copyLink\(task\.debugUrl\)/, '调试链接复制接线')
|
|
assert.match(page, /:disabled="!video\.displayUrl"|!hasDisplayUrl/, '下载按钮无视频禁用')
|
|
})
|