Files
crawler-plugin/admin-frontend-vue/tests/align-column-width.test.ts
T
huangzd1997 191e5f9102 align(重复检测): DuplicateCheckPage 像素级复刻 reference asin-store-console
撞款控制台整页复刻 reference 观感:引入页面独立 reference 令牌(#2E5BE6 主蓝/#D63A4A 红/#F2F4F8 底)落到 KPI 色点/矩阵单元格/撞款卡/台账 chips;撞款覆盖矩阵与全部ASIN台账改原生表格(台账20条/页+共N条/上一页/下一页/跳至N页分页条,列头服务端排序▲/▼);筛选改原生 input/select/date;明细抽屉+底部 toast 复刻 reference(原生 mask/drawer/d-table 汇总徽章);分组说明只读(归属来自店铺管理)。
数据源保持自家 /api/admin/shop-data-crawl/duplicate-check-console|-ledger|-export 不变。

验收:mock-admin-server 补 console/ledger 夹具;新增 e2e dup-console.spec(渲染/台账切换/令牌色值/矩阵台账结构断言+截图);align-dup-console/align-column-width 断言随原生表格调整;前端 1552 测试全绿 + vue-tsc/build 通过。
2026-09-07 02:43:36 +08:00

61 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
// 验收反馈:所有列表的宽度列自适应。
// 不变式:列表页 el-table-column 一律用 min-width(弹性分配,随容器自适应),不得残留固定 width。
// 例外:DuplicateCheckPage 不动;dialog/表单的 width 不属于表格列。
const PAGES = [
'src/pages/account/GroupsPage.vue',
'src/pages/account/MenusPage.vue',
'src/pages/account/UsersPage.vue',
'src/pages/asin/AsinInvalidPage.vue',
'src/pages/asin/DedupeRegistryPage.vue',
'src/pages/asin/ProductCategoryPage.vue',
'src/pages/asin/QueryAsinPage.vue',
'src/pages/asin/SkipPricePage.vue',
'src/pages/records/RecordsDigitalHumanVersionPage.vue',
'src/pages/records/RecordsHistoryPage.vue',
'src/pages/records/RecordsSoftwareVersionPage.vue',
'src/pages/shop/ShopKeysPage.vue',
'src/pages/shop/ShopManagePage.vue',
'src/pages/tasks/ImageVideoTasksPage.vue',
'src/pages/tasks/ShopDataTasksPage.vue',
]
function columnWidthLines(src: string): string[] {
// 只检查 el-table-column 标签行内出现的固定 width="数字"。
return src
.split('\n')
.filter((line) => /<el-table-column[^>]*\swidth="\d+"/.test(line))
}
test('align_column_width_normal_primary_path', () => {
for (const page of PAGES) {
const bad = columnWidthLines(readSource(page))
assert.equal(bad.length, 0, `${page} 表格列不得残留固定 width(应改 min-width: ${bad.join(' | ')}`)
}
})
test('align_column_width_normal_variant_input', () => {
// 自适应不意味着无下限:至少保留一处 min-width 以保证内容可读。
for (const page of PAGES) {
const src = readSource(page)
assert.match(src, /el-table-column[^>]*min-width|el-table-column/, `${page} 应有表格列定义`)
}
})
test('align_column_width_boundary_empty_input', () => {
// 例外页 DuplicateCheckPage 已整页复刻 reference 撞款控制台(原生 ledger 表格),不参与 el-table 列宽约定。
const dup = readSource('src/pages/tasks/DuplicateCheckPage.vue')
assert.equal(/el-table-column/.test(dup), false, '撞款台账已用 reference 原生表格,不再有 el-table-column')
assert.match(dup, /class="ledger"/, '撞款台账仍为表格实现')
})
test('align_column_width_dependency_failure_returns_actionable_message', () => {
// dialog 宽度(如 width="620px")与表单宽度不受影响——只约束 el-table-column 行。
const shop = readSource('src/pages/tasks/ShopDataTasksPage.vue')
assert.match(shop, /el-dialog[^>]*width="\d+px"/, 'el-dialog 自身宽度保留')
})