align(asin·像素复刻): 品牌库/查询ASIN/最低价ASIN/商品类目 四页自绘复刻旧版(panel-invalid-asin-data/query-asin/skip-price-asin/product-categories)——原生rowspan表格+可复制ASIN+btn-sm行操作+原生confirm删除+旧式分页(类目15/页/搜索态)+面板头搜索组/操作组+树[+/−]折叠/懒加载/编辑态按钮文案;编辑弹窗父级只读
This commit is contained in:
@@ -2,45 +2,42 @@ import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readSource } from './helpers.ts'
|
||||
|
||||
/** 对齐旧版 .btn-sm:asin 域 5 页表格行内操作(编辑/删除/配置)统一为实心小按钮(type primary/danger + size small),不再用 link/text;类目树折叠钮由靛蓝改为蓝白 token。 */
|
||||
/** 对齐旧版 .btn-sm:asin 域 5 页已像素复刻,行内操作(编辑/删除/配置)用原生 btn btn-sm 实心小按钮(非 EP 按钮)。 */
|
||||
|
||||
// 实心小按钮:同一 el-button 内同时含 size="small" 与 @click="<action>",且不含 link/text 修饰。
|
||||
const SOLID_ACTION = (action: string) => new RegExp(`<el-button[^>]*size="small"[^>]*@click="${action}`)
|
||||
const NO_MODIFIER = (action: string, mod: 'link' | 'text') =>
|
||||
new RegExp(`<el-button[^>]*${mod}[^>]*@click="${action}`)
|
||||
// 断言单个 el-button 标签同时含 btn-sm 与目标 @click,且不含 link/text 修饰(action 含正则元字符需转义)。
|
||||
const escapeRe = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
||||
const OLD_BTN = (action: string) => new RegExp(`class="btn btn-sm[^"]*"[^>]*@click="${escapeRe(action)}`)
|
||||
const NO_LINK = (action: string) => new RegExp(`<el-button[^>]*link[^>]*@click="${escapeRe(action)}`)
|
||||
const NO_TEXT = (action: string) => new RegExp(`<el-button[^>]*text[^>]*@click="${escapeRe(action)}`)
|
||||
const NO_EL = (action: string) => new RegExp(`<el-button[^>]*@click="${escapeRe(action)}`)
|
||||
|
||||
function assertRowButtonSolid(source: string, action: string) {
|
||||
assert.match(source, SOLID_ACTION(action), `${action} 为 size=small 实心按钮`)
|
||||
assert.doesNotMatch(source, NO_MODIFIER(action, 'link'), `${action} 不再 link`)
|
||||
assert.doesNotMatch(source, NO_MODIFIER(action, 'text'), `${action} 不再 text`)
|
||||
function assertOldRowButton(source: string, action: string, page: string) {
|
||||
assert.match(source, OLD_BTN(action), `${page} ${action} 为 btn-sm 实心按钮`)
|
||||
assert.doesNotMatch(source, NO_LINK(action), `${page} ${action} 不再 link`)
|
||||
assert.doesNotMatch(source, NO_TEXT(action), `${page} ${action} 不再 text`)
|
||||
assert.doesNotMatch(source, NO_EL(action), `${page} ${action} 不再用 EP 按钮`)
|
||||
}
|
||||
|
||||
test('align_dedupe_registry_row_buttons_old_btn', () => {
|
||||
const s = readSource('src/pages/asin/DedupeRegistryPage.vue')
|
||||
assert.match(s, /class="btn btn-sm"[^>]*@click="openEdit\(row\)"/, '编辑用旧版 btn-sm 实心小按钮')
|
||||
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="removeRow\(row\)"/, '删除用旧版 btn-sm btn-danger')
|
||||
assert.doesNotMatch(s, /el-button/, '去重汇总已自绘,无 EP 按钮')
|
||||
assert.match(s, /window\.confirm\(`确定删除总数据/, '删除确认文案对齐旧版(原生 confirm)')
|
||||
})
|
||||
|
||||
test('align_invalid_asin_row_buttons_solid', () => {
|
||||
test('align_invalid_asin_row_buttons_old_btn', () => {
|
||||
const s = readSource('src/pages/asin/AsinInvalidPage.vue')
|
||||
assertRowButtonSolid(s, 'openEdit')
|
||||
assertRowButtonSolid(s, 'remove')
|
||||
assertOldRowButton(s, 'openEdit(row)', '不符合ASIN')
|
||||
assertOldRowButton(s, 'remove(row)', '不符合ASIN')
|
||||
assert.match(s, /window\.confirm\(invalidAsinDeleteText\(row\)\)/, '删除确认原生 confirm 对齐旧版')
|
||||
})
|
||||
|
||||
test('align_query_asin_config_solid', () => {
|
||||
assertRowButtonSolid(readSource('src/pages/asin/QueryAsinPage.vue'), 'openConfig')
|
||||
test('align_query_asin_config_old_btn', () => {
|
||||
assertOldRowButton(readSource('src/pages/asin/QueryAsinPage.vue'), 'openConfig(row.item as QueryAsinItem)', '查询ASIN')
|
||||
})
|
||||
|
||||
test('align_skip_price_config_solid', () => {
|
||||
assertRowButtonSolid(readSource('src/pages/asin/SkipPricePage.vue'), 'openConfig')
|
||||
test('align_skip_price_config_old_btn', () => {
|
||||
assertOldRowButton(readSource('src/pages/asin/SkipPricePage.vue'), 'openConfig(row.item as SkipPriceItem)', '最低价ASIN')
|
||||
})
|
||||
|
||||
test('align_product_category_tree_row_buttons_solid', () => {
|
||||
test('align_product_category_row_buttons_old_btn', () => {
|
||||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
assertRowButtonSolid(s, 'openEdit')
|
||||
assertRowButtonSolid(s, 'removeCategory')
|
||||
assertOldRowButton(s, 'openEdit(row.node)', '商品类目树视图')
|
||||
assertOldRowButton(s, 'openEdit(row)', '商品类目搜索视图')
|
||||
assert.match(s, /btn-sm btn-danger"[^>]*@click="removeCategory/, '删除为 btn-sm btn-danger')
|
||||
})
|
||||
|
||||
test('align_product_category_no_indigo_left', () => {
|
||||
@@ -49,14 +46,16 @@ test('align_product_category_no_indigo_left', () => {
|
||||
assert.match(s, /--admin-primary-soft/, '折叠钮改用蓝白主色 soft token')
|
||||
})
|
||||
|
||||
test('align_product_category_search_and_tree_edits_both_solid', () => {
|
||||
test('align_product_category_load_more_old_class', () => {
|
||||
// 类目「加载更多」行按钮沿用 btn-sm btn-secondary(旧版小组按钮样式)。
|
||||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
const opens = s.match(/<el-button[^>]*size="small"[^>]*@click="openEdit/g) || []
|
||||
assert.ok(opens.length >= 2, `树/搜索两处编辑均实心(${opens.length})`)
|
||||
assert.match(s, /class="btn btn-sm btn-secondary"[^>]*loadMoreChildren/, '加载更多为旧版 btn-sm btn-secondary')
|
||||
})
|
||||
|
||||
test('align_product_category_load_more_kept_link', () => {
|
||||
// 类目"加载更多"是非行内操作的树加载行,保留 link 不误伤。
|
||||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
assert.match(s, /link size="small" type="primary"[^>]*loadMoreChildren/, '加载更多保留 link')
|
||||
test('align_dedupe_registry_row_buttons_old_btn', () => {
|
||||
const s = readSource('src/pages/asin/DedupeRegistryPage.vue')
|
||||
assert.match(s, /class="btn btn-sm"[^>]*@click="openEdit\(row\)"/, '编辑用旧版 btn-sm 实心小按钮')
|
||||
assert.match(s, /class="btn btn-sm btn-danger"[^>]*@click="removeRow\(row\)"/, '删除用旧版 btn-sm btn-danger')
|
||||
assert.doesNotMatch(s, /el-button/, '去重汇总已自绘,无 EP 按钮')
|
||||
assert.match(s, /window\.confirm\(`确定删除总数据/, '删除确认文案对齐旧版(原生 confirm)')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user