10dec12ec0
用户端 frontend-vue: - jd-publish-shop.ts:shopLabel 只出店名(缺名兜底「店铺 N」),跨店/多店琥珀文案压成一两句,判据逻辑零改动 - JdPublishTab:删工具头/分类解释/品牌句后半,默认店铺/选品/collect-hint/中断回执/加价规则各压一句 - JdCollectTab:删工具头 desc、分类机制句、断点游标行,「页面筛选未生效兜底翻页中」从任务卡撤下 - jd-on-shelf 空态一句、JdConsolePage hero-sub 整段删(含过时的「正在建设中」) - 品牌 10 个 tab:输入/筛选/加载长句压一句或删,任务卡删「结果ID/店铺ID/平台」技术行(店名已显形) - 保留:错误出口、额度「当前在架X/Y」、GROUPS_EMPTY 空态动作句、检测按钮与店铺显形 后管 admin-frontend-vue: - 每页顶部「当前页面操作提示」条整条下线(删 OperationGuide.vue+operation-guides.ts) - 撞款/任务中心/关键词用量/密钥用量/客户端包/教程/软件版本/数字人/菜单/店铺密钥/登录页逐页删说明小字(保留:踢线警示、「留空=永不过期」、「不要带v前缀」、「仅支持.zip」、草稿需手动发布、已授权人数、安全提示) - 编辑/建号弹窗 label 括号收短;代理弹窗/设备日志(删 pywebview/kk-browser 进程名)/密钥 pill title/授权弹窗 dim/品牌门控空态收短 测试同步(16 支改反钉或同步断言,全部当场绿): - align-operation-guide 整份重写为反钉(组件与文案表不得回流) - source-pin 台账 task-center-board 条目手工点名 7/3/5→24/14/28:旧值是切分器把正则字面量内裸引号当字符串开关吞掉 18 支用例的误量(stripNonCode 不识别 regex literal),本次改写恰好移除该文件最后两处带引号正则后测出真值;真实用例数反而 25→24(删 1 支 guide 用例),非真实增长 门禁:后管 node --test 1965/1965+vitest 253/253+vue-tsc rc=0;用户端 node 1150/mount 149/vue-tsc rc=0;ops 快检 --fast overall=pass(后端9.5/后管8.8/客户端9.8/用户端9.6)。本窗不发版;app_client/jar/后端零改动。
115 lines
7.1 KiB
TypeScript
115 lines
7.1 KiB
TypeScript
import assert from 'node:assert/strict'
|
||
import test from 'node:test'
|
||
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
||
import { join } from 'node:path'
|
||
|
||
/** v1.5 京东发布用户端契约(蓝图 docs/ITERATION_PLAN.md §1 AC-9 / §3 / §4 Phase 4)。
|
||
*
|
||
* 两组:
|
||
* 1. **立即生效**(AC-9 前端绊线,B113-01):`/api/jd-collect/groups` 是京东分类的
|
||
* 唯一读取口——全 src 不得出现第三个裸 URL 消费点;发布页要分类数据必须走
|
||
* endpoints.jdCollect.groups 的既有 fetch 函数(出现第二个分类口即红)。
|
||
* 2. **Phase 4 契约**(2026-11-18 随 Phase 4 落地移除 skip 正式激活):JdPublishTab
|
||
* (分类→商品→改价→建单→实时面板)的 5 支验收契约,蓝图 §4 Phase 4【待激活验收测试】清单。
|
||
*/
|
||
|
||
const ROOT = process.cwd()
|
||
|
||
function read(relativePath: string, what: string): string {
|
||
const path = join(ROOT, relativePath)
|
||
assert.ok(existsSync(path), `${what} 尚未落地(蓝图 §4 Phase 4):${path}`)
|
||
return readFileSync(path, 'utf8')
|
||
}
|
||
|
||
/** 递归收集 src 下 .ts/.vue 源文件 */
|
||
function collectSourceFiles(dir: string, acc: string[] = []): string[] {
|
||
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
||
const full = join(dir, entry.name)
|
||
if (entry.isDirectory()) collectSourceFiles(full, acc)
|
||
else if (/\.(ts|vue)$/.test(entry.name)) acc.push(full)
|
||
}
|
||
return acc
|
||
}
|
||
|
||
// ---------------------------------------------------------- AC-9 前端绊线(立即生效)
|
||
|
||
test('AC-9: 京东分类读取口全 src 唯一(B113-01 绊线)', () => {
|
||
const hits = collectSourceFiles(join(ROOT, 'src'))
|
||
.filter((f) => readFileSync(f, 'utf8').includes('jd-collect/groups'))
|
||
.map((f) => f.replace(/\\/g, '/').replace(ROOT.replace(/\\/g, '/') + '/', ''))
|
||
assert.deepEqual(hits.sort(), [
|
||
'src/shared/api/endpoints.ts',
|
||
'src/shared/api/types/modules/jd-collect.ts',
|
||
], 'B113-01:/api/jd-collect/groups 是京东分类唯一读取口——发布页要分类必须消费 endpoints.jdCollect.groups 既有出口,不得新增裸 URL 消费点')
|
||
})
|
||
|
||
// ---------------------------------------------------------- Pending Phase 4
|
||
|
||
test('AC-9: JdPublishTab 分类选择消费唯一 groups 出口', () => {
|
||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||
assert.ok(tab.includes('jdCollect'), 'JdPublishTab 的分类数据必须走 endpoints.jdCollect/groups 既有 fetch(AC-9),不得自拼 URL')
|
||
assert.ok(!tab.includes('jd-collect/groups'), 'JdPublishTab 不得裸写分类 URL(B113-01 绊线)')
|
||
})
|
||
|
||
test('选品作用域:建单带 productIds,文案与作用域口径一致(2026-11-25)', () => {
|
||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||
assert.ok(tab.includes('productIds') || tab.includes('productId'),
|
||
'JdPublishTab 建单提交必须携带勾选的商品 id 集合(服务端按可见分类作用域校验)')
|
||
// 口径改:同组同事采集的商品也能上架——文案不得再写「归属你账号」,空态与说明同步。
|
||
assert.ok(!tab.includes('归属你账号'), '文案不得再写「归属你账号」:起作用域是可见分类,不是建单人')
|
||
assert.ok(tab.includes('该分类下暂无商品'), '空态文案必须与作用域口径一致')
|
||
// 2026-11-28 精简口径(客户「删除多余小字」):常驻解释句整行删除,作用域语义只留空态。
|
||
assert.ok(!tab.includes('同组同事采集的也能上架'), '常驻分类解释句已删,不得回流')
|
||
})
|
||
|
||
test('建单请求体形状:categoryId + productIds + priceRule{mode,value}', () => {
|
||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||
// 蓝图 §3 死契约:POST /api/jd-publish/tasks 请求体 {categoryId, productIds[], priceRule:{mode,value?}}
|
||
assert.ok(tab.includes('categoryId'), '建单体缺 categoryId(所选自定义分类)')
|
||
assert.ok(tab.includes('priceRule'), '建单体缺 priceRule(统一改价规则;mode: none|percent|fixed)')
|
||
assert.ok(tab.includes("'percent'") && tab.includes("'fixed'") && tab.includes("'none'"),
|
||
'priceRule.mode 三档(none/percent/fixed)必须与蓝图 §3 同值')
|
||
})
|
||
|
||
test('endpoints 注册 jdPublish 端点组(建单/items/chunk 三件)', () => {
|
||
const endpoints = read('src/shared/api/endpoints.ts', 'endpoints.ts')
|
||
assert.ok(endpoints.includes('jdPublish'), 'endpoints.ts 缺 jdPublish 端点组')
|
||
assert.ok(endpoints.includes('/api/jd-publish/tasks'), 'jdPublish 组缺建单端点 /api/jd-publish/tasks')
|
||
})
|
||
|
||
test('商品上架占位卡转正式:jd-publish 卡挂 /jd-publish 路由', () => {
|
||
const catalog = read('src/pages/jd/tool-catalog.ts', 'jd/tool-catalog.ts')
|
||
const router = read('src/router/index.ts', 'router/index.ts')
|
||
assert.ok(/id:\s*'jd-publish'[\s\S]*?href:\s*'\/jd-publish'/.test(catalog),
|
||
'jd-publish 卡须补 href 指向 /jd-publish(转正式)')
|
||
assert.ok(router.includes("path: '/jd-publish'"), 'router 缺 /jd-publish 路由')
|
||
})
|
||
|
||
// ---------------------------------------------------------- 分类空态点名(2026-11-25)
|
||
|
||
test('分类空态文案单出口:判据 computed+两常量定义存在,模板按名引用不内联第二份', () => {
|
||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||
assert.ok(tab.includes('const GROUPS_EMPTY_DROPDOWN_TEXT'), '下拉空态文案必须定义在常量单出口')
|
||
assert.ok(tab.includes('const GROUPS_EMPTY_HINT_TEXT'), '块下动作句文案必须定义在常量单出口')
|
||
assert.ok(tab.includes('const groupsEmpty = computed'),
|
||
'空态判据=拉取完成且集合为空(groupsLoading 结束+length===0),不许拿加载中也当空')
|
||
assert.ok(tab.includes('{{ GROUPS_EMPTY_HINT_TEXT }}') && tab.includes(':empty-text="groupsEmpty ? GROUPS_EMPTY_DROPDOWN_TEXT'),
|
||
'模板两处都必须引用常量——内联第二份文案就是口径漂移的开始')
|
||
})
|
||
|
||
// -------------------------------------------------- 选分类=整分类上架(2026-11-26 晚客户口径「商品信息不要显示」)
|
||
|
||
test('选分类自动拉全:大页码分页+累计行数对撞 total+令牌作废在飞循环,商品明细 UI 不得残留', () => {
|
||
const tab = read('src/pages/jd/JdPublishTab.vue', '商品上架页')
|
||
assert.ok(tab.includes('PRODUCT_FETCH_PAGE_SIZE'), '选分类必须自动分页拉全(大页码),不得只拉第 1 页')
|
||
assert.ok(tab.includes('fetched >= productTotal.value'),
|
||
'终止按「累计行数对撞 total」判,不按「本页满不满」判——服务端收窄每页条数时满页判据会把第 1 页当末页')
|
||
assert.ok(tab.includes('request !== productRequest'),
|
||
'换分类/重拉必须作废在飞循环:迟到的旧分类商品绝不进新分类建单')
|
||
for (const gone of ['class="product-check"', 'class="product-pager"', 'class="product-select-all"',
|
||
'全选本页', '清空勾选', '跨页累计']) {
|
||
assert.ok(!tab.includes(gone), `商品明细 UI 不得残留「${gone}」:客户口径=选分类上架就行`)
|
||
}
|
||
assert.ok(tab.includes('该分类下暂无商品'), '分类空态文案必须保留(整分类口径下这是唯一「没货」信号)')
|
||
})
|