63 lines
3.1 KiB
TypeScript
63 lines
3.1 KiB
TypeScript
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。 */
|
||
|
||
// 实心小按钮:同一 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}`)
|
||
|
||
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`)
|
||
}
|
||
|
||
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', () => {
|
||
const s = readSource('src/pages/asin/AsinInvalidPage.vue')
|
||
assertRowButtonSolid(s, 'openEdit')
|
||
assertRowButtonSolid(s, 'remove')
|
||
})
|
||
|
||
test('align_query_asin_config_solid', () => {
|
||
assertRowButtonSolid(readSource('src/pages/asin/QueryAsinPage.vue'), 'openConfig')
|
||
})
|
||
|
||
test('align_skip_price_config_solid', () => {
|
||
assertRowButtonSolid(readSource('src/pages/asin/SkipPricePage.vue'), 'openConfig')
|
||
})
|
||
|
||
test('align_product_category_tree_row_buttons_solid', () => {
|
||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assertRowButtonSolid(s, 'openEdit')
|
||
assertRowButtonSolid(s, 'removeCategory')
|
||
})
|
||
|
||
test('align_product_category_no_indigo_left', () => {
|
||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||
assert.doesNotMatch(s, /#6366f1|#eef0fe|6366f1|eef0fe/, '靛蓝色点已清')
|
||
assert.match(s, /--admin-primary-soft/, '折叠钮改用蓝白主色 soft token')
|
||
})
|
||
|
||
test('align_product_category_search_and_tree_edits_both_solid', () => {
|
||
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})`)
|
||
})
|
||
|
||
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')
|
||
})
|