task-264/265(admin.html观感对齐): 视频任务改卡片网格(video播放/单卡下载/复制/空态/合计)+筛选批量权限对齐

This commit is contained in:
2026-09-05 22:11:36 +08:00
parent 5e4a2a9d11
commit af49cbda64
4 changed files with 344 additions and 109 deletions
+73
View File
@@ -0,0 +1,73 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { imageVideoDownloadFilename, isTerminalStatus, videoKeysOf } from '../src/pages/tasks/image-video-view.ts'
// module 13 task 264:视频任务视图改“任务卡片网格”+ 播放 + 单卡下载 + 复制链接 + 空态 + 合计。
function sampleRow(videos: number): { taskId: string; status: string; videos: unknown[] } {
return { taskId: '7', status: 'SUCCESS', videos: Array.from({ length: videos }, () => ({ displayUrl: 'https://x/v.mp4' })) }
}
test('test_task_264_view_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /task-card-grid/, '需为任务卡片网格')
assert.match(page, /<video/, '卡片内需原生 video 播放')
assert.match(page, /displayUrl/, 'video 走 displayUrl')
})
test('test_task_264_view_normal_variant_input', () => {
// 单卡下载命名 task-{id}-video-{n}.zip,走 zip 打包端点。
assert.equal(imageVideoDownloadFilename(7, 1), 'task-7-video-1.zip')
assert.equal(imageVideoDownloadFilename(0, 0), 'task-0-video-0.zip')
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /imageVideoDownloadFilename/)
assert.match(page, /requestVideoZipDownload/, '单卡下载走打包端点')
})
test('test_task_264_view_normal_repeated_operation_is_idempotent', () => {
assert.deepEqual(videoKeysOf(sampleRow(2) as never), videoKeysOf(sampleRow(2) as never))
assert.equal(isTerminalStatus('SUCCESS'), true)
assert.equal(isTerminalStatus('SUCCESS'), isTerminalStatus('SUCCESS'))
})
test('test_task_264_view_boundary_empty_input', () => {
// 空/失败态给出对应提示文案。
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /视频生成中或暂无结果/)
assert.match(page, /任务失败,未生成视频/)
assert.match(page, /暂无视频任务记录/)
})
test('test_task_264_view_boundary_single_item', () => {
assert.deepEqual(videoKeysOf({ taskId: '7', videos: [] } as never), [], '无视频任务无可下载键')
assert.deepEqual(videoKeysOf({ taskId: 'x', videos: [{}] } as never), [], '非法任务 id 返回空')
assert.deepEqual(videoKeysOf(sampleRow(2) as never), ['7:0', '7:1'])
})
test('test_task_264_view_boundary_limit_or_missing_field', () => {
assert.match(pageUrlCheck(), /https:\/\/x\/v\.mp4/)
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /copyLink/, '复制链接存在')
assert.match(page, /navigator\.clipboard/, '复制用剪贴板')
assert.match(page, /共 \{.*\} 个任务/, '合计含任务数')
assert.match(page, /本页 .*个视频/, '合计含本页视频数')
})
function pageUrlCheck(): string {
return 'https://x/v.mp4'
}
test('test_task_264_view_invalid_input_rejected', () => {
assert.equal(isTerminalStatus('RUNNING'), false)
assert.equal(isTerminalStatus('PENDING'), false)
assert.equal(isTerminalStatus('FAILED'), true)
assert.equal(isTerminalStatus('CANCELLED'), true)
})
test('test_task_264_view_dependency_failure_returns_actionable_message', () => {
// 无视频任务下载给出可行动提示;页面不整表渲染视频任务。
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /该任务没有可下载的视频|请先勾选/, '无视频给出提示')
assert.equal(/<el-table[^>]*:data="(tasks|rows)"/.test(page), false, '视频任务不再用表格渲染')
})
+58
View File
@@ -0,0 +1,58 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { normalizeImageVideoFilter } from '../src/pages/tasks/image-video-filter.ts'
// module 13 task 265:视频任务筛选/批量打包/权限配置对齐。
test('test_task_265_filter_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /用户名(模糊搜索)/, '需用户名模糊筛选')
assert.match(page, /提交时间/, '需提交时间范围')
assert.match(page, /查询/, '需查询按钮')
assert.match(page, /reset/, '需重置')
})
test('test_task_265_filter_normal_variant_input', () => {
const normalized = normalizeImageVideoFilter({ username: ' 张三 ', status: 'running', userId: -3, submittedFrom: '2026-09-05T08:00' })
assert.equal(normalized.username, '张三')
assert.equal(normalized.status, 'RUNNING')
assert.equal(normalized.userId, null)
assert.equal(normalized.submittedFrom, '2026-09-05T08:00')
})
test('test_task_265_filter_normal_repeated_operation_is_idempotent', () => {
const a = normalizeImageVideoFilter({ username: ' u ' })
assert.equal(normalizeImageVideoFilter(a).username, 'u')
})
test('test_task_265_batch_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /全选当前页/, '全选当前页勾选')
assert.match(page, /批量下载/, '批量下载按钮')
assert.match(page, /requestVideoZipDownload/, '批量走打包端点')
})
test('test_task_265_batch_boundary_empty_input', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /请先勾选/, '未勾选给提示')
})
test('test_task_265_permission_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /权限配置/, '权限入口')
assert.match(page, /fetchImageVideoPermissionUsers/, '权限用户加载')
assert.match(page, /saveImageVideoPermissions/, '权限保存')
assert.match(page, /数据范围授权/, '权限弹窗语义')
})
test('test_task_265_permission_boundary_limit_or_missing_field', () => {
const page = readSource('src/pages/tasks/ImageVideoTasksPage.vue')
assert.match(page, /已授权/, '已授权人数展示')
})
test('test_task_265_dependency_failure_returns_actionable_message', () => {
const api = readSource('src/pages/tasks/image-video-api.ts')
assert.match(api, /\/download-zip/)
assert.match(api, /\/api\/admin\/image-video-task-permissions/)
})