Files
crawler-plugin/admin-frontend-vue/tests/align-asin-row-buttons.test.ts
T
huangzd1997 8776a9bf1e 后管(四面9分批次): 裸提示 92→0、裸 confirm 24→0 且逐处 await、失败态可见并真能重试
- ElMessage.error 全收进 showAdminFeedback(例外清单 CAP=0,唯一保留的裸调用是出口本体);
  window.confirm 24 处全部改成 await 的 openAdminConfirm(逐处核过所在函数本就 async,
  不存在"点了确认不执行"的异步断层)。
- 新增 load-failure-model + LoadFailureBar:22/23 个取数页有失败态与真重试
  (只有"知道了"清条不算过),例外仅登录页。
- DedupeRegistryPage / DuplicateCheckPage 补 onUnmounted,并加全树定时器/监听配对判据。
- 去重页那处"能点但后端 403":读侧认 wholeCompany、写侧只认 groupIds/userIds 的不对称
  本轮没动后端(前端拿不到与写侧同集合的 groupIds,按它置灰会误伤同事名下真能改的行=静默删功能);
  先修更实在的一半——403 的中文原因此前整段丢失,现在走统一文案到界面。
- 验收:node --test 1,818 例 0 红、npx vue-tsc --noEmit rc=0;5 支新判据 26 例。
2026-10-09 23:09:37 +08:00

70 lines
3.9 KiB
TypeScript

import test from 'node:test'
import assert from 'node:assert/strict'
import { readSource } from './helpers.ts'
/** 对齐旧版 .btn-sm:asin 域 5 页已像素复刻,行内操作(编辑/删除/配置)用原生 btn btn-sm 实心小按钮(非 EP 按钮)。 */
// 断言单个 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 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_invalid_asin_row_buttons_old_btn', () => {
const s = readSource('src/pages/asin/AsinInvalidPage.vue')
assertOldRowButton(s, 'openEdit(row)', '不符合ASIN')
assertOldRowButton(s, 'remove(row)', '不符合ASIN')
assert.match(s, /openAdminConfirm\(\{ message: invalidAsinDeleteText\(row\), danger: true \}\)/, '删除确认走统一确认出口,文案仍取旧版模型')
})
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_old_btn', () => {
assertOldRowButton(readSource('src/pages/asin/SkipPricePage.vue'), 'openConfig(row.item as SkipPriceItem)', '最低价ASIN')
})
test('align_product_category_row_buttons_old_btn', () => {
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
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', () => {
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_load_more_old_class', () => {
// 类目「加载更多」行按钮沿用 btn-sm btn-secondary(旧版小组按钮样式)。
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
assert.match(s, /class="btn btn-sm btn-secondary"[^>]*loadMoreChildren/, '加载更多为旧版 btn-sm btn-secondary')
})
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, /openAdminConfirm\(\{ message: `确定删除总数据/, '删除确认文案对齐旧版,出口统一为 openAdminConfirm')
})
test('align_asin_actions_cell_spacing', () => {
// 反馈:查询ASIN操作按钮要有间距——asin-col-actions 统一 flex + gap 8px(对齐全站 ops-cell)。
for (const page of ['src/pages/asin/QueryAsinPage.vue', 'src/pages/asin/SkipPricePage.vue']) {
const s = readSource(page)
assert.match(s, /\.asin-col-actions\s*\{[^}]*gap:\s*8px/, `${page} 操作列按钮间距 8px`)
}
})