feat(jd): 京东数据库公共化——数据不区分公司、分组全平台一份(2026-11-15 用户定案)
This commit is contained in:
@@ -148,12 +148,12 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(wrapper.find('.drawer').exists()).toBe(false, '删除按钮 @click.stop,点它不开详情抽屉')
|
||||
expect(confirmMock).toHaveBeenCalledTimes(1, '删除必须过二次确认')
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledTimes(0, '确认弹窗取消时不发删除请求')
|
||||
// 确认后:deleteJdProducts 按公司 tab 下传(id, companyId)。
|
||||
// 确认后:deleteJdProducts 按 id 直删(公共库写侧无公司维度,2026-11-15 公共化)。
|
||||
confirmMock.mockResolvedValue(true)
|
||||
jdApi.deleteJdProducts.mockResolvedValueOnce({ deleted: 1, imagesDeleted: 0, objectsDeleted: 0, objectsKept: 0, objectsSkipped: 0 })
|
||||
await wrapper.findAll('tbody tr')[0].findAll('td')[10].findAll('button').find((b) => b.text() === '删除')!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1], 1)
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1])
|
||||
})
|
||||
|
||||
it('操作列编辑按钮防冒泡且打开编辑抽屉(抽屉自取详情回填,2026-11-15 行级编辑)', async () => {
|
||||
@@ -186,8 +186,8 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.drawer').exists()).toBe(true, '编辑抽屉打开')
|
||||
expect(wrapper.text()).toContain('编辑商品', '抽屉标题点商品')
|
||||
// 抽屉按 (id, companyId) 自取详情回填。
|
||||
expect(jdApi.fetchJdProductDetail).toHaveBeenCalledWith(1, 1)
|
||||
// 抽屉按 id 自取详情回填(公共库详情无公司维度)。
|
||||
expect(jdApi.fetchJdProductDetail).toHaveBeenCalledWith(1)
|
||||
// 编辑抽屉的保存提示文案点名人工编辑锁后果(用户保存前看得见「采集不再覆盖」)。
|
||||
expect(wrapper.text()).toContain('人工维护', '保存后果提示常驻(V199 人工编辑锁)')
|
||||
})
|
||||
@@ -255,7 +255,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
{ id: 8, name: '乙组', sortOrder: 1, productCount: 1 },
|
||||
])
|
||||
const wrapper = await mountWith({ items: [], total: 0, page: 1, pageSize: 20 })
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledWith(1)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledWith()
|
||||
|
||||
const groupSelect = wrapper.find('select')
|
||||
const optionTexts = groupSelect.findAll('option').map((o) => o.text())
|
||||
@@ -330,7 +330,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList).toHaveBeenCalledTimes(1, '下线导出不影响列表首屏')
|
||||
})
|
||||
|
||||
it('点行打开详情抽屉:按 (id, companyId) 取详情,attrGroups 分块渲染', async () => {
|
||||
it('点行打开详情抽屉:按 id 取详情(公共库无公司维度),attrGroups 分块渲染', async () => {
|
||||
jdApi.fetchJdProductDetail.mockImplementation(() =>
|
||||
Promise.resolve({
|
||||
item: item(1),
|
||||
@@ -349,7 +349,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
|
||||
expect(wrapper.find('.drawer-mask').exists()).toBe(true)
|
||||
expect(jdApi.fetchJdProductDetail).toHaveBeenCalledTimes(1)
|
||||
expect(jdApi.fetchJdProductDetail).toHaveBeenCalledWith(1, 1)
|
||||
expect(jdApi.fetchJdProductDetail).toHaveBeenCalledWith(1)
|
||||
expect(wrapper.find('.drawer-mask').text()).toContain('基本信息')
|
||||
expect(wrapper.find('.drawer-mask').text()).toContain('规格')
|
||||
expect(wrapper.find('.drawer-mask').text()).toContain('容量')
|
||||
@@ -419,7 +419,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(wrapper.find('.drawer-mask').text()).toContain('暂无 SKU 矩阵')
|
||||
})
|
||||
|
||||
it('删除:勾选两行点删除 → 二次确认点名数量与桶清理 → 批量端点带 (ids, companyId),成功后刷新并清勾选', async () => {
|
||||
it('删除:勾选两行点删除 → 二次确认点名数量与桶清理 → 批量端点按 id 直删(公共库无公司维度),成功后刷新并清勾选', async () => {
|
||||
jdApi.deleteJdProducts.mockResolvedValue({ deleted: 2, imagesDeleted: 18, objectsDeleted: 16, objectsKept: 2, objectsSkipped: 0 })
|
||||
const wrapper = await mountWith({ items: [item(1), item(2)], total: 2, page: 1, pageSize: 20 })
|
||||
|
||||
@@ -439,7 +439,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(options.danger).toBe(true)
|
||||
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledTimes(1)
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1, 2], 1)
|
||||
expect(jdApi.deleteJdProducts).toHaveBeenCalledWith([1, 2])
|
||||
expect(document.body.textContent).toContain('已删除 2 个商品')
|
||||
expect(document.body.textContent).toContain('2 个共用图片保留', '共用对象计数要透出到反馈')
|
||||
// 成功后重取列表并清勾选:工具栏按钮消失。
|
||||
@@ -480,9 +480,9 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
await flushPromises()
|
||||
|
||||
expect(wrapper.find('.group-modal').exists()).toBe(true)
|
||||
// 打开弹窗 = 拉一次分组列表(第 2 次:首屏已拉过一次)
|
||||
// 打开弹窗 = 拉一次分组列表(第 2 次:首屏已拉过一次;分组全平台一份、不带公司维度)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith(1)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith()
|
||||
|
||||
// 模拟分组管理里删了一个分组:emit changed → 页面刷新分组下拉与列表(回第一页)
|
||||
wrapper.findComponent(JdProductGroupDialog).vm.$emit('changed')
|
||||
@@ -492,7 +492,7 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(jdApi.fetchJdProductList.mock.calls.at(-1)![0]).toMatchObject({ page: 1, companyId: 1 })
|
||||
})
|
||||
|
||||
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径)', async () => {
|
||||
it('切公司 Tab 重取并清掉上一家的筛选(company-tab-wiring 同口径;分组公共不清)', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([{ id: 7, name: '甲组', sortOrder: 0, productCount: 3 }])
|
||||
const wrapper = await mountWith({ items: [item(1)], total: 1, page: 1, pageSize: 20 })
|
||||
const textInputs = wrapper.findAll('.form-group input[type="text"]')
|
||||
@@ -510,10 +510,13 @@ describe('京东数据库页(v1.4 Phase 5)', () => {
|
||||
expect(last.companyId).toBe(2)
|
||||
expect(last.shopName).toBe('', '切公司必须清掉上一家的店铺名')
|
||||
expect(last.titleKeyword).toBe('', '切公司必须清掉上一家的标题关键字')
|
||||
expect(last.groupId).toBe('', '切公司必须清掉上一家选的分组')
|
||||
expect(last.groupId).toBe('7', '分组全平台一份(公共),groupId 与公司维度正交——切 tab 不清')
|
||||
expect(last).not.toHaveProperty('category', '切公司必须清掉上一家选的类目')
|
||||
expect(last.page).toBe(1)
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenLastCalledWith(2)
|
||||
// 分组选项是全局的:切 tab 不重取(首屏那一次之后就不再增长),且任何一次拉取都不带公司维度。
|
||||
for (const call of jdApi.fetchJdProductGroups.mock.calls) {
|
||||
expect(call).toEqual([], '分组选项是全局的,任何一次拉取都不带公司维度')
|
||||
}
|
||||
})
|
||||
|
||||
it('空态与加载失败条(失败给重试,不把整页打死)', async () => {
|
||||
|
||||
Reference in New Issue
Block a user