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) => /]*\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 自身宽度保留') })