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/asin/AsinInvalidPage.vue', 'src/pages/asin/ProductCategoryPage.vue', 'src/pages/asin/QueryAsinPage.vue', 'src/pages/asin/SkipPricePage.vue', 'src/pages/records/RecordsDigitalHumanVersionPage.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) => /]*\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"/, '撞款台账仍为表格实现') const hist = readSource('src/pages/records/RecordsHistoryPage.vue') assert.equal(/el-table-column/.test(hist), false, '生成记录已像素复刻 admin panel-history 原生表格,不再有 el-table-column') assert.match(hist, /class="table-scroll history-table-scroll"/, '生成记录用原生 .table-scroll 表格') assert.match(hist, /]*>结果预览<\/th>/, '原生表含结果预览列') const dedupe = readSource('src/pages/asin/DedupeRegistryPage.vue') assert.equal(/el-table-column/.test(dedupe), false, '去重汇总已像素复刻 admin panel-dedupe-total-data 原生表格,不再有 el-table-column') assert.match(dedupe, /class="table-scroll dedupe-table-scroll"/, '去重汇总用原生 .table-scroll 表格') const users = readSource('src/pages/account/UsersPage.vue') assert.equal(/el-table-column/.test(users), false, '用户管理已像素复刻 admin panel-users 原生表格,不再有 el-table-column') assert.match(users, /class="table-scroll user-table-scroll"/, '用户管理用原生 .table-scroll 表格') const menus = readSource('src/pages/account/MenusPage.vue') assert.equal(/el-table-column/.test(menus), false, '菜单配置已像素复刻 admin panel-columns 原生表格,不再有 el-table-column') assert.match(menus, /class="table-scroll columns-table-scroll"/, '菜单配置用原生 .table-scroll 表格') const groups = readSource('src/pages/account/GroupsPage.vue') assert.equal(/el-table-column/.test(groups), false, '分组管理已像素复刻 admin panel-group-manage 原生表格,不再有 el-table-column') assert.match(groups, /class="table-scroll"/, '分组管理用原生 .table-scroll 表格') }) 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 自身宽度保留') })