Files
crawler-plugin/frontend-vue/tests/mount/jd-console-pending-menu.mount.test.ts
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

72 lines
2.7 KiB
TypeScript
Raw Permalink 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.
/**
* 京东工作台挂载用例(v1.5):首页「京东」进来后是两个菜单。
*
* 三件事一起判,缺一条就是假绿:
* ① 两个菜单名都在 DOM 里(获取店铺数据 / 商品上架);
* ② 两张卡都是「可用」卡片(有 href → router-link 分支,文案是「打开工具」);
* ③ 商品上架卡(v1.5 Phase 4 由占位转正式)的 router-link 指向 /jd-publish。
*
* 历史锁(2026-11-17):本文件原本钉「商品上架是假菜单(tool-card--pending,点开只弹
* 暂未开通)」;占位随 Phase 4 转正式后这两条断言翻转为可用卡形状,假菜单分支在
* JdConsolePage 保留为通用防御(后续新工具再用)。
*
* 跑法:cd frontend-vue && npx vitest run(tests/mount/** 由 vitest.config.ts 收)。
*/
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { mount, type VueWrapper } from '@vue/test-utils'
import JdConsolePage from '@/pages/jd/JdConsolePage.vue'
let wrapper: VueWrapper | null = null
function mountConsole() {
wrapper = mount(JdConsolePage, {
global: {
stubs: {
NotificationBell: true,
// 2026-11-22 JD 页头部挂了密钥设置按钮:面板替身化,别在挂载用例里真发 /user-secrets fetch
ApiSecretSettingsPanel: true,
RouterLink: { props: ['to'], template: '<a class="router-link-stub" :data-to="to"><slot /></a>' },
'router-link': { props: ['to'], template: '<a class="router-link-stub" :data-to="to"><slot /></a>' },
},
},
})
return wrapper
}
describe('京东工作台两个菜单', () => {
beforeEach(() => {
window.localStorage.setItem('username', 'admin')
})
afterEach(() => {
wrapper?.unmount()
wrapper = null
window.localStorage.clear()
})
it('两个菜单名都渲染出来', () => {
const w = mountConsole()
const text = w.text()
expect(text).toContain('获取店铺数据')
expect(text).toContain('商品上架')
expect(w.findAll('.tool-card').length).toBe(2)
})
it('两张卡都是可用卡片(转正式后无占位态)', () => {
const w = mountConsole()
const cards = w.findAll('.tool-card')
expect(cards[0].classes()).not.toContain('tool-card--pending')
expect(cards[0].text()).toContain('打开工具')
expect(cards[1].classes()).not.toContain('tool-card--pending')
expect(cards[1].text()).toContain('打开工具')
})
it('商品上架卡的 router-link 指向 /jd-publish(占位已转正式)', () => {
const w = mountConsole()
const links = w.findAll('a.router-link-stub').map((a) => a.attributes('data-to'))
expect(links).toContain('/jd-collect')
expect(links).toContain('/jd-publish')
})
})