4d38781005
- 新增 GET /api/collect-routing 封装与类型,两个工具页进页各读一次 - 外观专利页恢复本地推送链路(取队列载荷 → guard → activate → enqueue_json), 开关关闭时退回「提交后台执行」;按钮与提示文案随开关切换 - 相似ASIN 开关关闭时只建单不推队列,等 Linux 后台认领 - queue-payload / activate 端点与 DTO 从 943cf2d62^ 原样恢复 - catch 棘轮 blocks 301→303:新增两支都有用户可见出口,silent 未变
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { http } from '../src/shared/api/http.ts'
|
|
import { getCollectRouting } from '../src/shared/api/types/modules/collect-routing.ts'
|
|
|
|
function setupWindow() {
|
|
;(globalThis as Record<string, unknown>).window = {
|
|
localStorage: { getItem: () => '42' },
|
|
location: { origin: 'http://localhost' },
|
|
}
|
|
}
|
|
|
|
function mockRequest(
|
|
t: Parameters<typeof test>[1] extends (t: infer T) => unknown ? T : never,
|
|
impl: (config: { url?: string; method?: string; params?: Record<string, unknown> }) => Promise<unknown>,
|
|
) {
|
|
t.mock.method(http, 'request', impl as never)
|
|
}
|
|
|
|
/**
|
|
* 采集路由开关读取口:前端两个工具页据这两个布尔决定「启动」走本地客户端还是后台。
|
|
* 只钉 URL 与返回值原样透传——开关真值来自服务端,前端不自己造默认。
|
|
*/
|
|
test('test_collect_routing_url_and_payload', async (t) => {
|
|
setupWindow()
|
|
let captured: { url?: string; method?: string } = {}
|
|
mockRequest(t, (config) => {
|
|
captured = config
|
|
return Promise.resolve({
|
|
data: { success: true, message: 'ok', data: { appearancePatentLocal: true, similarAsinLocal: false } },
|
|
})
|
|
})
|
|
|
|
const routing = await getCollectRouting()
|
|
|
|
assert.equal(captured.url, '/newApi/api/collect-routing')
|
|
assert.equal(captured.method, 'GET')
|
|
assert.equal(routing.appearancePatentLocal, true)
|
|
assert.equal(routing.similarAsinLocal, false)
|
|
})
|