Files
crawler-plugin/admin-frontend-vue/tests/align-asin-row-buttons.test.ts
T

61 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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_solid', () => {
const s = readSource('src/pages/asin/DedupeRegistryPage.vue')
assertRowButtonSolid(s, 'openEdit')
assertRowButtonSolid(s, 'removeRow')
})
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')
})