36e110d27c
首页在亚马逊/视频右侧新增「京东」一级入口(恒显示),落地页 /jd-console 按亚马逊控制台样式做两张工具卡:获取店铺数据(可用)、商品上架(占位,点开只提示「暂未开通」)。
获取店铺数据改成一键:建单 → 推 jd-shop-collect-run 到本机队列 → 轮询服务端进度。进度只读两处真源——任务行状态 + scope 行合并写游标里的 itemsReceived/cursor.total(客户端抓列表第一页时把 total 写进游标),没有分母就退回不定态动画,不编造百分比;终态即停轮询。后端新增 GET /api/jd-collect/tasks/{taskId}/progress(按 taskId+userId 校归属)。
判据:JdCollectProgressQueryTest(5)、jd-console-tool-catalog.test.ts(5)、jd-console-pending-menu.mount(3)、jd-collect-progress.mount(6);catch 棘轮 blocks 314→315 按名登记(轮询 catch 非静默)。
55 lines
2.7 KiB
TypeScript
55 lines
2.7 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import test from 'node:test'
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
import { join } from 'node:path'
|
|
|
|
import { JD_TOOLS, JD_TOOL_MAP } from '../src/pages/jd/tool-catalog.ts'
|
|
|
|
/** 京东一级入口(v1.5):首页「京东」→ 京东工作台两个菜单(获取店铺数据 / 商品上架占位)。 */
|
|
|
|
const ROOT = process.cwd()
|
|
|
|
function read(relativePath: string): string {
|
|
const path = join(ROOT, relativePath)
|
|
assert.ok(existsSync(path), `文件缺失:${path}`)
|
|
return readFileSync(path, 'utf8')
|
|
}
|
|
|
|
test('京东工作台只有两个菜单:获取店铺数据 + 商品上架', () => {
|
|
assert.equal(JD_TOOLS.length, 2, '京东工作台菜单数应为 2')
|
|
const names = JD_TOOLS.map((tool) => tool.name)
|
|
assert.deepEqual(names, ['获取店铺数据', '商品上架'])
|
|
assert.equal(new Set(JD_TOOLS.map((tool) => tool.id)).size, 2, '工具 id 不应重复')
|
|
assert.ok(JD_TOOL_MAP.get('jd-collect'), 'JD_TOOL_MAP 应按 id 命中获取店铺数据')
|
|
})
|
|
|
|
test('获取店铺数据指向采集页,商品上架先做占位菜单', () => {
|
|
const collect = JD_TOOLS.find((tool) => tool.id === 'jd-collect')
|
|
const publish = JD_TOOLS.find((tool) => tool.id === 'jd-publish')
|
|
assert.equal(collect?.href, '/jd-collect', '获取店铺数据应指向 /jd-collect')
|
|
assert.equal(publish?.href, undefined, '商品上架先做假菜单:不得挂路由')
|
|
})
|
|
|
|
test('路由器注册京东工作台与采集页', () => {
|
|
const router = read('src/router/index.ts')
|
|
assert.ok(router.includes("path: '/jd-console'"), 'router 缺 /jd-console')
|
|
assert.ok(router.includes('JdConsolePage.vue'), 'router 未指向 JdConsolePage')
|
|
assert.ok(router.includes("path: '/jd-collect'"), 'router 缺 /jd-collect')
|
|
})
|
|
|
|
test('首页京东入口与亚马逊/视频并列', () => {
|
|
const home = read('src/pages/home/DesktopHomePage.vue')
|
|
assert.ok(home.includes('jd-console.html'), '首页京东入口未指向京东工作台')
|
|
assert.ok(/>京东</.test(home), '首页缺「京东」按钮文字')
|
|
})
|
|
|
|
test('获取店铺数据页是一键触发 + 服务端进度条', () => {
|
|
const page = read('src/pages/jd/JdCollectTab.vue')
|
|
assert.ok(page.includes('fetchJdCollectProgress'), '采集页必须轮询服务端进度(不拿本地内存数充进度)')
|
|
assert.ok(page.includes('progress-track'), '采集页缺进度条轨道')
|
|
assert.ok(page.includes('jd-progress-indeterminate'),
|
|
'拿不到 total 时必须走不定态进度条,不得编造百分比')
|
|
assert.ok(page.includes('一键获取店铺数据'), '主按钮应是一键获取')
|
|
assert.ok(page.includes('jd-shop-collect-run'), '建单后必须推送本机客户端队列')
|
|
})
|