fdaae3c560
- 删 ZiniaoVersionSetting.vue / ziniao-version.ts;9 个 Tab 摘 ziniao_version 载荷 - 删 BrandDeleteBrandTab.vue / BrandPatrolDeleteTab.vue 与 delete-brand 类型模块; 路由、工具目录(20→18)、端点表、progress-light 模块(12→10)、withdraw.ts 巡店段、 java-modules re-export 同步摘除 - 测试面:node --test 17 处红按实况收敛(端点冻结快照摘两组、适配器 16→14、窄集合台账 摘两页、六页→五页、reexport/快照随实况),modules-delete-brand.test.ts 整文件删 - vue-tsc+vite build 通过;node --test 837/837 绿
62 lines
3.1 KiB
TypeScript
62 lines
3.1 KiB
TypeScript
import { test } from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { readFileSync } from 'node:fs'
|
||
import { fileURLToPath } from 'node:url'
|
||
import { dirname, join } from 'node:path'
|
||
|
||
/**
|
||
* 「行数据按需拉取」接线守卫(审查 F5 后续):
|
||
* 品牌工具页用轻量端点的结果行版本跳过重型 batch;这里守住两件最容易写错的事
|
||
* ——①接线没被误删;②跳过分支的返回值必须符合调用方契约(曾经把 shopDataCrawl 写成裸 return,
|
||
* 而调用方 waitForTerminal 把 falsy 当「任务已消失 → FAILED」,会误杀正在跑的任务)。
|
||
*/
|
||
const PAGES_DIR = join(dirname(fileURLToPath(import.meta.url)), '../src/pages/brand/components')
|
||
|
||
// 2026-10-15 旧版界面退役:原第 3 个页签 BrandPatrolDeleteTab.vue(巡店删除)随功能
|
||
// 一并退役删除,接线名单 5→4;其余四页一字未动。
|
||
const WIRED_PAGES = [
|
||
'BrandQueryAsinTab.vue',
|
||
'BrandWithdrawTab.vue',
|
||
'BrandShopDataCrawlTab.vue',
|
||
'BrandAppearancePatentTab.vue',
|
||
]
|
||
|
||
function sourceOf(page: string) {
|
||
return readFileSync(join(PAGES_DIR, page), 'utf8')
|
||
}
|
||
|
||
test('已接线的品牌工具页仍使用结果行版本跳过重型 batch', () => {
|
||
for (const page of WIRED_PAGES) {
|
||
const source = sourceOf(page)
|
||
assert.ok(source.includes('createRowsVersionTracker'), `${page} 缺少版本跟踪器声明`)
|
||
assert.ok(source.includes('selectTasksNeedingRows'), `${page} 缺少按需拉取判断`)
|
||
assert.ok(source.includes('getModuleProgressLight'), `${page} 缺少轻量端点调用`)
|
||
}
|
||
})
|
||
|
||
test('轻量请求失败必须回退为全量拉取(不得因此少拉任务)', () => {
|
||
// 多任务页:catch 里把 heavyIds 还原成全部任务
|
||
// 回退必须写在 catch 体内:用 [^}] 锁住,否则窗口会跨过 catch 的右花括号,
|
||
// 把后面正常分支的 return(如 { taskIds, force: true })当成回退,断言恒真。
|
||
for (const page of ['BrandQueryAsinTab.vue', 'BrandWithdrawTab.vue']) {
|
||
assert.match(sourceOf(page), /catch\s*\{[^}]{0,200}?heavyIds = ids/, `${page} 缺少轻量失败回退`)
|
||
}
|
||
assert.match(sourceOf('BrandAppearancePatentTab.vue'),
|
||
/catch\s*\{[^}]{0,240}?(heavyIds = taskIds|return \{ taskIds,)/,
|
||
'BrandAppearancePatentTab 缺少轻量失败回退(catch 里必须把全部任务交给重型 batch)')
|
||
|
||
// 单任务页:catch 里不能有 return(直接落到批量拉取)
|
||
const shopDataCrawl = sourceOf('BrandShopDataCrawlTab.vue')
|
||
const catchBlock = shopDataCrawl.match(/catch\s*\{([^}]*)\}/)?.[1] ?? ''
|
||
assert.ok(catchBlock.length > 0, 'BrandShopDataCrawlTab 未找到 catch 分支')
|
||
assert.ok(!catchBlock.includes('return'), 'BrandShopDataCrawlTab 轻量失败时不得提前返回,必须照旧拉批量')
|
||
})
|
||
|
||
test('跳过分支的返回值符合调用方契约', () => {
|
||
const shopDataCrawl = sourceOf('BrandShopDataCrawlTab.vue')
|
||
// waitForTerminal: `if (!exists) return 'FAILED'` —— 任务仍在时必须返回 true
|
||
assert.match(shopDataCrawl, /selectTasksNeedingRows\([\s\S]{0,200}?return true/,
|
||
'BrandShopDataCrawlTab 跳过分支必须 return true(false/undefined 会被当成任务已消失)')
|
||
|
||
})
|