feat(admin): 为支持单删的管理列表补齐批量删除
This commit is contained in:
@@ -105,7 +105,7 @@ function categoryHeaderColumns(page: string): Array<{ label: string; px: number
|
||||
const theadBlocks = page.match(/<thead>[\s\S]*?<\/thead>/g) ?? []
|
||||
assert.equal(theadBlocks.length, 1, '类目页应只有一个 thead(本闸门按单个表头求列宽之和)')
|
||||
const columns: Array<{ label: string; px: number | null }> = []
|
||||
for (const cell of theadBlocks[0].matchAll(/<th\b[^>]*>([^<]*)<\/th>/g)) {
|
||||
for (const cell of theadBlocks[0].matchAll(/<th(?=[\s>])[^>]*>([\s\S]*?)<\/th>/g)) {
|
||||
const style = cell[0].match(/style="([^"]*)"/)?.[1] ?? ''
|
||||
const px = /width:\s*(\d+)px/.exec(style)?.[1]
|
||||
columns.push({ label: cell[1].trim(), px: px === undefined ? null : Number(px) })
|
||||
@@ -120,14 +120,14 @@ function categoryTableMinWidth(page: string): number | null {
|
||||
}
|
||||
|
||||
test('align_category_fixed_layout_never_leaves_a_column_to_be_squeezed', () => {
|
||||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
const page = readSource('src/pages/asin/ProductCategoryPage.vue', true)
|
||||
// 前提也要钉:这条闸门只在 fixed 布局下成立,改成 auto 布局时它该喊,而不是安静地继续绿。
|
||||
// 窗口用 [^}] 而不是定长字符数:本页 CSS 注释里就写着 "table-layout:fixed 下……" 这句话,
|
||||
// 定长窗口能跨过 } 把注释喂成"前提成立"(变异自证时实测过一次 SURVIVED)。
|
||||
assert.match(page, /\.table-scroll\s+table\s*\{[^}]*table-layout:\s*fixed/, '本闸门的前提:表格是 table-layout:fixed')
|
||||
|
||||
const columns = categoryHeaderColumns(page)
|
||||
assert.equal(columns.length, 8, `表头应有 8 列(与 <td colspan="8"> 对齐),实际 ${columns.length}:${JSON.stringify(columns)}`)
|
||||
assert.equal(columns.length, 9, `表头应有 9 列(与 <td colspan="9"> 对齐),实际 ${columns.length}:${JSON.stringify(columns)}`)
|
||||
const unwidthed = columns.filter((c) => c.px === null).map((c) => c.label)
|
||||
assert.deepEqual(unwidthed, [], 'fixed 布局下没写宽度的列会在容器变窄时被第一个压到 0px:' + unwidthed.join('/'))
|
||||
assert.equal(/width:\s*\d+%/.test(page.match(/<thead>[\s\S]*?<\/thead>/)?.[0] ?? ''), false,
|
||||
@@ -137,7 +137,7 @@ test('align_category_fixed_layout_never_leaves_a_column_to_be_squeezed', () => {
|
||||
const minWidth = categoryTableMinWidth(page)
|
||||
assert.notEqual(minWidth, null, '.category-table-scroll > table 必须有 px 下限,否则塌缩区又合法了')
|
||||
assert.ok((minWidth ?? 0) >= sum,
|
||||
`min-width(${minWidth}px) 必须 >= 8 列宽度之和(${sum}px):否则表格落在 [min-width, 列宽和] 这一段时列被等比压缩`)
|
||||
`min-width(${minWidth}px) 必须 >= 9 列宽度之和(${sum}px):否则表格落在 [min-width, 列宽和] 这一段时列被等比压缩`)
|
||||
|
||||
// 控制方圈出的那两列是这次的直接症状:它们是文字列,宽度下限给死,别被"重新调配比"顺手砍回去。
|
||||
for (const label of ['层级路径', '备注']) {
|
||||
|
||||
Reference in New Issue
Block a user