Files
crawler-plugin/admin-frontend-vue/tests/task-266.test.ts
T

59 lines
2.9 KiB
TypeScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
import { shopDataFilenameFromDisposition } from '../src/pages/tasks/shop-data-download.ts'
import { isTerminalStatus } from '../src/pages/tasks/image-video-view.ts'
// module 13 task 266:店铺数据任务视图改“每店铺卡片”,单文件下载/删除真实端点。
test('test_task_266_view_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.match(page, /shop-card-grid/, '需每店铺卡片网格')
assert.match(page, /group\.results/, '卡片内遍历该店结果文件')
assert.match(page, /暂无结果文件/, '店空态')
})
test('test_task_266_view_normal_variant_input', () => {
const api = readSource('src/pages/tasks/shop-data-api.ts')
assert.match(api, /fetchShopDataResultDownload/, '单文件下载适配')
assert.match(api, /\/results\/\$\{resultId\}\/download/, '单文件下载走管理端真实端点')
assert.match(api, /deleteShopDataResultHistory/, '删除适配')
assert.match(api, /\/history\/\$\{resultId\}/, '删除走管理端真实端点')
})
test('test_task_266_view_normal_repeated_operation_is_idempotent', () => {
assert.equal(shopDataFilenameFromDisposition('attachment; filename="a.xlsx"', 'fallback.xlsx'), 'a.xlsx')
assert.equal(shopDataFilenameFromDisposition(undefined, 'fallback.xlsx'), 'fallback.xlsx')
})
test('test_task_266_view_boundary_empty_input', () => {
assert.equal(shopDataFilenameFromDisposition('', 'shop-data-task-9.xlsx'), 'shop-data-task-9.xlsx', '缺 header 回默认文件名')
assert.equal(shopDataFilenameFromDisposition('inline; filename="店铺.xlsx"', 'd.xlsx'), '店铺.xlsx')
})
test('test_task_266_view_boundary_single_item', () => {
const page = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.match(page, /fileReady/, '未就绪禁下载')
assert.match(page, /isTerminalStatus/, '终态门控下载/删除')
assert.equal(isTerminalStatus('SUCCESS'), true)
assert.equal(isTerminalStatus('RUNNING'), false)
})
test('test_task_266_delete_normal_primary_path', () => {
const page = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.match(page, /确认删除店铺/, '删除确认含店铺')
assert.match(page, /及结果文件/, '删除确认含结果文件')
assert.match(page, /删除成功/, '删除成功提示')
})
test('test_task_266_delete_boundary_limit_or_missing_field', () => {
const page = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.match(page, /正在删除任务/, '删除中有进行文案')
})
test('test_task_266_dependency_failure_returns_actionable_message', () => {
const page = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.equal(/<el-table[^>]*:data="(rows|allResultRows)"/.test(page), false, '结果文件不再用整表渲染')
assert.match(page, /暂无店铺数据任务/, '空态文案')
})