Files
crawler-plugin/frontend-vue/tests/jd-secret-entry.test.ts
T
huangzd1997 6a52e24eb9 feat(web): 京东工具台三页头部加密钥设置入口(2026-11-22 用户口径「这边也要加密钥设置」,京东上架 AI 补值要读登录用户 LLM 密钥)
- BrandApiSecretSettingsButton 加可选 showProxy(默认 true,亚马逊侧现有调用零变化);透传面板既有 showProxy(708/771 行已按它条件保存/余额);副标题按 showProxy 派生(隐藏代理时不再提「代理设置保存在当前客户端」)
- JdConsolePage/JdCollectTab/JdPublishTab 头部 .top-right(铃铛与用户名之间)各插 <BrandApiSecretSettingsButton variant="topbar" :show-proxy="false"/>——京东特性无代理消费方,隐藏代理区防「没配代理影响京东采集吗」误判(铁律 27 同款)
- 弹窗/保存/检测/余额走既有 /newApi/api/user-secrets 链,零新端点零新权限 key
- 判据:jd-secret-entry.test.ts(三页头部精确匹配+按钮四钉)+jd-secret-entry.mount.test.ts(top-right 触发钮/showProxy 透传/副标题三用例);四支既有 JD mount 补 ApiSecretSettingsPanel stub 防真发 fetch(31 绿+mount 59 绿零噪声+vue-tsc rc=0)

随下一 app-web 窗上线
2026-11-22 21:51:45 +08:00

61 lines
2.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import assert from 'node:assert/strict'
import test from 'node:test'
import { existsSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
/**
* 2026-11-22 京东工具台密钥设置入口(用户拍板「这边也要加密钥设置」)的源码绊线。
*
* 三件钉:
* 1. 三个京东页(工具台/采集/上架)头部 .top-right 都挂 BrandApiSecretSettingsButton
* (variant=topbar、show-proxy=false——京东特性没有代理消费方,面板代理区不许出现);
* 2. 按钮组件把 showProxy 透传给面板、副标题随代理区开关派生、默认仍 true(亚马逊侧零变化);
* 3. 面板本体与 setup 强制门不在本文件射程(不动)。
*/
const ROOT = process.cwd()
function read(relativePath: string, what: string): string {
const path = join(ROOT, relativePath)
assert.ok(existsSync(path), `${what} 尚未落地:${path}`)
return readFileSync(path, 'utf8')
}
const JD_PAGES = [
['src/pages/jd/JdConsolePage.vue', '京东工具台首页'],
['src/pages/jd/JdCollectTab.vue', '京东采集页'],
['src/pages/jd/JdPublishTab.vue', '京东上架页'],
] as const
const ENTRY_LINE = '<BrandApiSecretSettingsButton variant="topbar" :show-proxy="false" />'
test('三个京东页头部都挂密钥设置入口(variant=topbar、show-proxy=false)', () => {
for (const [file, what] of JD_PAGES) {
const src = read(file, what)
assert.ok(src.includes(ENTRY_LINE), `${what}(${file})头部没有密钥设置入口:${ENTRY_LINE}`)
assert.ok(
/import BrandApiSecretSettingsButton from '@\/pages\/brand\/components\/BrandApiSecretSettingsButton\.vue'/.test(src),
`${what}(${file})没有 import BrandApiSecretSettingsButton`,
)
// 入口必须画在 .top-right(铃铛与用户名之间),不得挪去别处
assert.ok(
/<div class="top-right">\s*<NotificationBell \/>\s*<BrandApiSecretSettingsButton[^>]*\/>\s*<span class="admin-name">/.test(src),
`${what}(${file})的密钥设置入口不在 top-right(NotificationBell 与用户名之间)`,
)
}
})
test('按钮组件把 showProxy 透传给面板,副标题随代理区开关派生,默认 true(亚马逊侧零变化)', () => {
const src = read('src/pages/brand/components/BrandApiSecretSettingsButton.vue', '密钥设置按钮')
assert.ok(
/<ApiSecretSettingsPanel ref="panelRef" :show-proxy="showProxy" \/>/.test(src),
'按钮组件没有把 showProxy 透传给面板:京东入口传 false 也只会照常显示代理区',
)
assert.ok(/showProxy\?: boolean/.test(src), '按钮组件没有 showProxy prop')
assert.ok(
/props\.showProxy\s*\?/.test(src),
'副标题没有按 showProxy 派生:隐藏代理时不得再提「代理设置保存在当前客户端」',
)
assert.ok(/showProxy: true,/.test(src), 'showProxy 默认值必须是 true(亚马逊侧现有调用零变化)')
})