feat(admin): 为支持单删的管理列表补齐批量删除
This commit is contained in:
@@ -41,7 +41,7 @@ test('align_product_category_row_buttons_old_btn', () => {
|
||||
})
|
||||
|
||||
test('align_product_category_no_indigo_left', () => {
|
||||
const s = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
const s = readSource('src/pages/asin/ProductCategoryPage.vue', true)
|
||||
assert.doesNotMatch(s, /#6366f1|#eef0fe|6366f1|eef0fe/, '靛蓝色点已清')
|
||||
assert.match(s, /--admin-primary-soft/, '折叠钮改用蓝白主色 soft token')
|
||||
})
|
||||
@@ -63,7 +63,7 @@ test('align_dedupe_registry_row_buttons_old_btn', () => {
|
||||
test('align_asin_actions_cell_spacing', () => {
|
||||
// 反馈:查询ASIN操作按钮要有间距——asin-col-actions 统一 flex + gap 8px(对齐全站 ops-cell)。
|
||||
for (const page of ['src/pages/asin/QueryAsinPage.vue', 'src/pages/asin/SkipPricePage.vue']) {
|
||||
const s = readSource(page)
|
||||
const s = readSource(page, true)
|
||||
assert.match(s, /\.asin-col-actions\s*\{[^}]*gap:\s*8px/, `${page} 操作列按钮间距 8px`)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ test('align_invalid_asin_page_has_no_role_branch_left', () => {
|
||||
assert.doesNotMatch(page, /isSuperAdmin/, '品牌库页又出现了角色分支:这一页的可见集不随操作者变')
|
||||
assert.doesNotMatch(page, /useAdminSessionStore/, '同上:页面已经不需要知道操作者是谁')
|
||||
assert.doesNotMatch(page, /lockedGroupId/i, '锁定分组的老模型回流了')
|
||||
assert.doesNotMatch(page, /:disabled="/, '分组下拉又被禁用了:非站点超管也该能选任意分组(CSS 里的 :not(:disabled) 不算,只排绑定)')
|
||||
assert.doesNotMatch(page, /<el-select\b[^>]*:disabled="/, '分组下拉又被禁用了:非站点超管也该能选任意分组(CSS 里的 :not(:disabled) 不算,只排绑定)')
|
||||
})
|
||||
|
||||
test('align_invalid_asin_page_keeps_group_column_and_filter_for_everyone', () => {
|
||||
|
||||
@@ -21,7 +21,7 @@ test('el_message_above_custom_overlays', () => {
|
||||
})
|
||||
|
||||
test('dedupe_overlay_and_warning_kept', () => {
|
||||
const page = readSource('src/pages/asin/DedupeRegistryPage.vue')
|
||||
const page = readSource('src/pages/asin/DedupeRegistryPage.vue', true)
|
||||
assert.match(page, /\.modal-mask\s*\{[^}]*z-index:\s*3000/, '页内遮罩仍为 3000,消息 4000 需保持在其上')
|
||||
assert.match(page, /\.dedupe-export-wait-mask\s*\{[^}]*z-index:\s*3100/, '导出等待遮罩 3100 同样低于消息 4000')
|
||||
assert.match(page, /请选择数据权限分组|请选择分组/, '导入/编辑未选分组需保留警告岔口')
|
||||
|
||||
@@ -105,7 +105,7 @@ function categoryHeaderColumns(page: string): Array<{ label: string; px: number
|
||||
const theadBlocks = page.match(/<thead>[\s\S]*?<\/thead>/g) ?? []
|
||||
assert.equal(theadBlocks.length, 1, '类目页应只有一个 thead(本闸门按单个表头求列宽之和)')
|
||||
const columns: Array<{ label: string; px: number | null }> = []
|
||||
for (const cell of theadBlocks[0].matchAll(/<th\b[^>]*>([^<]*)<\/th>/g)) {
|
||||
for (const cell of theadBlocks[0].matchAll(/<th(?=[\s>])[^>]*>([\s\S]*?)<\/th>/g)) {
|
||||
const style = cell[0].match(/style="([^"]*)"/)?.[1] ?? ''
|
||||
const px = /width:\s*(\d+)px/.exec(style)?.[1]
|
||||
columns.push({ label: cell[1].trim(), px: px === undefined ? null : Number(px) })
|
||||
@@ -120,14 +120,14 @@ function categoryTableMinWidth(page: string): number | null {
|
||||
}
|
||||
|
||||
test('align_category_fixed_layout_never_leaves_a_column_to_be_squeezed', () => {
|
||||
const page = readSource('src/pages/asin/ProductCategoryPage.vue')
|
||||
const page = readSource('src/pages/asin/ProductCategoryPage.vue', true)
|
||||
// 前提也要钉:这条闸门只在 fixed 布局下成立,改成 auto 布局时它该喊,而不是安静地继续绿。
|
||||
// 窗口用 [^}] 而不是定长字符数:本页 CSS 注释里就写着 "table-layout:fixed 下……" 这句话,
|
||||
// 定长窗口能跨过 } 把注释喂成"前提成立"(变异自证时实测过一次 SURVIVED)。
|
||||
assert.match(page, /\.table-scroll\s+table\s*\{[^}]*table-layout:\s*fixed/, '本闸门的前提:表格是 table-layout:fixed')
|
||||
|
||||
const columns = categoryHeaderColumns(page)
|
||||
assert.equal(columns.length, 8, `表头应有 8 列(与 <td colspan="8"> 对齐),实际 ${columns.length}:${JSON.stringify(columns)}`)
|
||||
assert.equal(columns.length, 9, `表头应有 9 列(与 <td colspan="9"> 对齐),实际 ${columns.length}:${JSON.stringify(columns)}`)
|
||||
const unwidthed = columns.filter((c) => c.px === null).map((c) => c.label)
|
||||
assert.deepEqual(unwidthed, [], 'fixed 布局下没写宽度的列会在容器变窄时被第一个压到 0px:' + unwidthed.join('/'))
|
||||
assert.equal(/width:\s*\d+%/.test(page.match(/<thead>[\s\S]*?<\/thead>/)?.[0] ?? ''), false,
|
||||
@@ -137,7 +137,7 @@ test('align_category_fixed_layout_never_leaves_a_column_to_be_squeezed', () => {
|
||||
const minWidth = categoryTableMinWidth(page)
|
||||
assert.notEqual(minWidth, null, '.category-table-scroll > table 必须有 px 下限,否则塌缩区又合法了')
|
||||
assert.ok((minWidth ?? 0) >= sum,
|
||||
`min-width(${minWidth}px) 必须 >= 8 列宽度之和(${sum}px):否则表格落在 [min-width, 列宽和] 这一段时列被等比压缩`)
|
||||
`min-width(${minWidth}px) 必须 >= 9 列宽度之和(${sum}px):否则表格落在 [min-width, 列宽和] 这一段时列被等比压缩`)
|
||||
|
||||
// 控制方圈出的那两列是这次的直接症状:它们是文字列,宽度下限给死,别被"重新调配比"顺手砍回去。
|
||||
for (const label of ['层级路径', '备注']) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { readSource } from './helpers.ts'
|
||||
const PAGE = 'src/pages/tasks/ShopDataTasksPage.vue'
|
||||
|
||||
test('align_shop_data_grid_normal_primary_path', () => {
|
||||
const src = readSource(PAGE)
|
||||
const src = readSource(PAGE, true)
|
||||
assert.match(src, /grid-template-columns:\s*repeat\(4,\s*1fr\)/, '卡片容器应为 4 列宫格')
|
||||
})
|
||||
|
||||
@@ -19,10 +19,10 @@ test('align_shop_data_grid_normal_variant_input', () => {
|
||||
})
|
||||
|
||||
test('align_shop_data_grid_boundary_empty_input', () => {
|
||||
// 卡片区下方有翻页组件(prev/next),与店铺分页并存(均为旧式分页)。
|
||||
// 卡片分页与授权弹窗分页独立,不能用残留样式充当分页入口。
|
||||
const src = readSource(PAGE)
|
||||
const count = (src.match(/class="pagination"/g) || []).length + (src.match(/sd-shop-pager/g) || []).length
|
||||
assert.ok(count >= 2, '页面应含店铺分页 + 卡片分页两处分页')
|
||||
assert.match(src, /<OldPagination[^\n]*:page="cardPage"/, '卡片列表应有可操作的分页')
|
||||
assert.match(src, /<OldPagination[^\n]*:page="permPage"/, '授权弹窗应有独立分页')
|
||||
assert.match(src, /cardPage/, '卡片分页状态')
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { test } from 'node:test'
|
||||
import { batchResultMessage, runBatchDelete, togglePageSelection } from '../src/utils/batch-delete.ts'
|
||||
|
||||
const rows = [{ id: 1, label: '甲' }, { id: 2, label: '乙' }, { id: 3, label: '丙' }]
|
||||
|
||||
test('表头只选择或取消当前页,同一业务行不重复选择', () => {
|
||||
const selected = new Map([[1, rows[0]]])
|
||||
const next = togglePageSelection(selected, [rows[1], rows[1], rows[2]])
|
||||
assert.deepEqual([...next.keys()], [1, 2, 3])
|
||||
assert.deepEqual([...togglePageSelection(next, rows.slice(1)).keys()], [1])
|
||||
assert.deepEqual([...selected.keys()], [1])
|
||||
})
|
||||
|
||||
test('逐条执行,失败不阻塞其他行,受保护行不发请求', async () => {
|
||||
const calls: number[] = []
|
||||
const result = await runBatchDelete({
|
||||
rows: [...rows, { id: 4, label: '丁' }],
|
||||
precheck: (row) => row.id === 2 ? '不能删除当前登录账号' : undefined,
|
||||
deleteOne: async (row) => {
|
||||
calls.push(row.id)
|
||||
if (row.id === 3) throw new Error('分组下还有店铺')
|
||||
},
|
||||
})
|
||||
assert.deepEqual(calls, [1, 3, 4])
|
||||
assert.deepEqual(result.deleted, [1, 4])
|
||||
assert.deepEqual(result.failures.map(({ id, reason }) => [id, reason]), [[2, '不能删除当前登录账号'], [3, '分组下还有店铺']])
|
||||
assert.equal(batchResultMessage(result), '已删除 2 条,失败 2 条:乙(不能删除当前登录账号);丙(分组下还有店铺)')
|
||||
})
|
||||
|
||||
test('范围失效后不再发下一条请求,未处理记录不计为失败或成功', async () => {
|
||||
let current = true
|
||||
const result = await runBatchDelete({
|
||||
rows,
|
||||
isCurrent: () => current,
|
||||
deleteOne: async () => { current = false },
|
||||
})
|
||||
assert.deepEqual(result, { deleted: [1], failures: [], remaining: 2 })
|
||||
assert.equal(batchResultMessage(result), '已删除 1 条,未处理 2 条')
|
||||
})
|
||||
@@ -89,11 +89,11 @@ test('账号页与顶栏的源码里公司维度已摘干净', () => {
|
||||
|
||||
// 「删了列忘了改占位行 colspan」是这类改动最常留下的残行:按表头列数交叉核对
|
||||
// (`<th` 是 `<thead` 的前缀,必须带上后随字符才数得准)。
|
||||
// 2026-11-17 V206:上架上限列 v-if="isJdSide" 按平台动态渲染 ⇒ 表头数 10(含源码里的 v-if th),
|
||||
// 2026-11-17 V206:上架上限列 v-if="isJdSide" 按平台动态渲染 ⇒ 加上批量选择后表头数 11(含源码里的 v-if th),
|
||||
// 占位行走 :colspan 动态绑定;字面量 colspan 在动态列下必然错位一半的 tab,反向钉死。
|
||||
const headers = (page.match(/<th[\s>]/g) || []).length
|
||||
assert.equal(headers, 10, `用户列表表头应为 10 列(9 列存量 + 京东侧上架上限 v-if 列),实际 ${headers}`)
|
||||
assert.match(page, /:colspan="isJdSide \? 10 : 9"/, '空态占位行必须按平台动态切 colspan(静态值与动态列数错位一半 tab)')
|
||||
assert.equal(headers, 11, `用户列表表头应为 11 列(9 列存量 + 批量选择 + 京东侧上架上限 v-if 列),实际 ${headers}`)
|
||||
assert.match(page, /:colspan="isJdSide \? 11 : 10"/, '空态占位行必须按平台动态切 colspan(静态值与动态列数错位一半 tab)')
|
||||
assert.equal(/colspan="\d+"/.test(page), false, '动态列下不许再留字面量 colspan(必有一侧 tab 列数对不上)')
|
||||
|
||||
const dialog = readSource('src/pages/account/CreateUserDialog.vue')
|
||||
|
||||
@@ -110,7 +110,7 @@ test('不许用客户端猜测禁用行内入口:那会误伤真能改的行',
|
||||
const src = readSource(PAGE)
|
||||
const opsCell = /<td class="ops-cell">[\s\S]*?<\/td>/.exec(src)
|
||||
assert.ok(opsCell, '行内操作列结构变了:这条判据要重写')
|
||||
assert.equal(/:disabled=|v-if=/.test(opsCell[0]), false,
|
||||
assert.equal(/:disabled=|v-if=/.test(opsCell[0].replace(':disabled="batch.busy"', '')), false,
|
||||
'行内编辑/删除上加了客户端权限闸——但前端拿不到后端写侧的 companyGroupIds,'
|
||||
+ '按分组下拉收窄会把同事名下"看得见也改得动"的行一起禁掉(静默删功能)。'
|
||||
+ '要收窄请先让后端在列表响应里下发可写标志(先例:用户菜单授权树的 grantable)。')
|
||||
|
||||
@@ -15,8 +15,12 @@ const INDEX_CANDIDATES = ['/index.ts', '/index.tsx', '/index.vue', '/index.js']
|
||||
* (内容逐字节等价,主树 LF 3565 B / 新检出 CRLF 3629 B)在干净检出树上会多红一条与本任务无关的用例。
|
||||
* 归一之后判据只取决于内容,不取决于在哪台机器、哪个 worktree 里跑。
|
||||
*/
|
||||
export function readSource(rel: string): string {
|
||||
return readFileSync(join(ROOT, rel), 'utf8').replace(/\r\n/g, '\n')
|
||||
export function readSource(rel: string, includeVueStyles = false): string {
|
||||
const source = readFileSync(join(ROOT, rel), 'utf8').replace(/\r\n/g, '\n')
|
||||
if (!includeVueStyles) return source
|
||||
const styles = [...source.matchAll(/<style\b[^>]*\bsrc="(\.\/[^"\n]+\.css)"[^>]*>/g)]
|
||||
.map(([, path]) => readSource(join(dirname(rel), path)))
|
||||
return [source, ...styles].join('\n')
|
||||
}
|
||||
|
||||
/** 统计非重叠子串出现次数(幂等、只读)。 */
|
||||
|
||||
@@ -68,6 +68,24 @@ async function mountDialog(editable = true): Promise<VueWrapper<Element>> {
|
||||
return wrapper
|
||||
}
|
||||
|
||||
it('批量删除分类:全选当前页、确认只移除分类、刷新一次;只读模式无入口', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3), group(8, '裤装', 1)])
|
||||
jdApi.deleteJdProductGroup.mockResolvedValue(undefined)
|
||||
const wrapper = await mountDialog()
|
||||
await wrapper.get('.option-head input[type="checkbox"]').setValue(true)
|
||||
await wrapper.get('.batch-delete-actions .btn-danger').trigger('click')
|
||||
await flushPromises()
|
||||
expect(confirmMock).toHaveBeenCalledWith(expect.objectContaining({ message: expect.stringContaining('商品本身不会被删除') }))
|
||||
expect(jdApi.deleteJdProductGroup.mock.calls).toEqual([[7], [8]])
|
||||
expect(jdApi.fetchJdProductGroups).toHaveBeenCalledTimes(2)
|
||||
expect(wrapper.emitted('changed')).toHaveLength(1)
|
||||
expect(wrapper.get('.batch-delete-actions .btn-danger').text()).toBe('批量删除(0)')
|
||||
await wrapper.setProps({ editable: false })
|
||||
expect(wrapper.find('.batch-delete-actions').exists()).toBe(false)
|
||||
expect(wrapper.find('.batch-delete-checkbox').exists()).toBe(false)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
describe('京东分类管理对话框(V204 独立页 2026-11-17 并入京东数据库页)', () => {
|
||||
it('打开即按当前分组取分类(ownerGroupId 必带);标题不带分组名(2026-11-17 用户口径「不要显示周丽娥」)', async () => {
|
||||
jdApi.fetchJdProductGroups.mockResolvedValue([group(7, '裙装', 3)])
|
||||
|
||||
@@ -140,7 +140,7 @@ describe('菜单权限配置页的平台隔离', () => {
|
||||
])
|
||||
const databaseRow = page.findAll('tbody tr')
|
||||
.find((row) => row.find('.menu-name-text').text() === '京东数据库')
|
||||
expect(databaseRow!.findAll('td')[4].text()).toBe('数据管理')
|
||||
expect(databaseRow!.findAll('td')[5].text()).toBe('数据管理')
|
||||
expect(databaseRow!.find('.column-child-mark').exists()).toBe(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { beforeEach, expect, it, vi } from 'vitest'
|
||||
import { flushPromises, mount } from '@vue/test-utils'
|
||||
import { createPinia, setActivePinia } from 'pinia'
|
||||
import QueryAsinPage from '@/pages/asin/QueryAsinPage.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
fetchQueryAsinList: vi.fn(),
|
||||
deleteQueryAsinCountryAsin: vi.fn(),
|
||||
openAdminConfirm: vi.fn(),
|
||||
}))
|
||||
vi.mock('@/pages/asin/query-asin-api.ts', () => ({ ...api, createQueryAsin: vi.fn(), fetchShopNamesByGroup: vi.fn() }))
|
||||
vi.mock('@/pages/asin/query-asin-detail-api.ts', () => ({ ...api, updateQueryAsinCountryAsin: vi.fn() }))
|
||||
vi.mock('@/pages/shop/shop-manage-api.ts', () => ({ fetchShopManageGroups: vi.fn().mockResolvedValue([]) }))
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: api.openAdminConfirm }))
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks()
|
||||
setActivePinia(createPinia())
|
||||
useAdminSessionStore().user = { id: 1, username: 'root', role: 'super_admin' }
|
||||
})
|
||||
|
||||
it('多站点店铺只占一个勾选;部分站点失败时,重试不重删成功站点', async () => {
|
||||
const shop = { id: 7, shopName: '甲店', groupName: '甲组', asinDe: 'B000000001', asinUk: 'B000000002' }
|
||||
api.fetchQueryAsinList.mockResolvedValue({ page: 1, total: 1, items: [shop] })
|
||||
api.deleteQueryAsinCountryAsin.mockResolvedValueOnce(undefined).mockRejectedValueOnce(new Error('暂时无法删除英国站'))
|
||||
api.openAdminConfirm.mockResolvedValue(true)
|
||||
const wrapper = mount(QueryAsinPage, { global: { stubs: ['el-select', 'el-option', 'el-dialog', 'el-drawer', 'el-progress'] } })
|
||||
await flushPromises()
|
||||
expect(wrapper.findAll('tbody .batch-delete-checkbox')).toHaveLength(1)
|
||||
expect(wrapper.get('tbody .batch-delete-cell').attributes('rowspan')).toBe('2')
|
||||
await wrapper.get('thead .batch-delete-checkbox').setValue(true)
|
||||
const button = wrapper.get('.batch-delete-actions .btn-danger')
|
||||
expect(button.text()).toBe('批量删除(1)')
|
||||
await button.trigger('click')
|
||||
await flushPromises()
|
||||
expect(api.openAdminConfirm).toHaveBeenCalledWith(expect.objectContaining({ message: expect.stringContaining('全部站点') }))
|
||||
expect(api.deleteQueryAsinCountryAsin.mock.calls).toEqual([[7, 'DE'], [7, 'UK']])
|
||||
expect(wrapper.get('details').text()).toContain('暂时无法删除英国站')
|
||||
await button.trigger('click')
|
||||
await flushPromises()
|
||||
expect(api.deleteQueryAsinCountryAsin.mock.calls).toEqual([[7, 'DE'], [7, 'UK'], [7, 'UK']])
|
||||
expect(button.text()).toBe('批量删除(0)')
|
||||
wrapper.unmount()
|
||||
})
|
||||
@@ -28,6 +28,22 @@ const secretsApi = vi.hoisted(() => ({
|
||||
}))
|
||||
|
||||
vi.mock('@/api/user-secrets', () => secretsApi)
|
||||
const confirmBatch = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmBatch }))
|
||||
|
||||
it('批量清空点名全部密钥与代理,只调用用户级清空接口', async () => {
|
||||
const wrapper = await mountWith([row(7), row(8)])
|
||||
confirmBatch.mockResolvedValue(true)
|
||||
secretsApi.deleteUserSecret.mockResolvedValue(undefined)
|
||||
await wrapper.get('thead .batch-delete-checkbox').setValue(true)
|
||||
await wrapper.get('.batch-delete-actions .btn-danger').trigger('click')
|
||||
await flushPromises()
|
||||
expect(confirmBatch).toHaveBeenCalledWith(expect.objectContaining({ danger: true, message: expect.stringContaining('全部密钥与代理配置') }))
|
||||
expect(secretsApi.deleteUserSecret.mock.calls).toEqual([[7], [8]])
|
||||
expect(secretsApi.clearUserSecretModule).not.toHaveBeenCalled()
|
||||
expect(wrapper.get('.batch-delete-actions .btn-danger').text()).toBe('批量清空(0)')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
function moduleCell(moduleKey: string, over: Record<string, unknown> = {}) {
|
||||
return {
|
||||
@@ -122,7 +138,7 @@ describe('余额两列接在密钥管理列表上', () => {
|
||||
const headerCount = wrapper.findAll('thead th').length
|
||||
const cellCount = wrapper.findAll('tbody tr')[0].findAll('td').length
|
||||
expect(cellCount, '每行的 td 数必须等于表头列数').toBe(headerCount)
|
||||
expect(headerCount).toBe(12)
|
||||
expect(headerCount).toBe(13)
|
||||
|
||||
const emptyWrapper = await mountWith([])
|
||||
const colspan = Number(emptyWrapper.find('tbody td').attributes('colspan'))
|
||||
@@ -133,7 +149,7 @@ describe('余额两列接在密钥管理列表上', () => {
|
||||
useAdminSessionStore().user = { id: 2, username: 'leader', role: 'admin' }
|
||||
const wrapper = await mountWith([row(7)])
|
||||
const headerCount = wrapper.findAll('thead th').length
|
||||
expect(headerCount).toBe(11)
|
||||
expect(headerCount).toBe(12)
|
||||
expect(wrapper.findAll('tbody tr')[0].findAll('td').length).toBe(headerCount)
|
||||
|
||||
const emptyWrapper = await mountWith([])
|
||||
|
||||
@@ -21,6 +21,8 @@ const usersApi = vi.hoisted(() => ({
|
||||
}))
|
||||
|
||||
vi.mock('@/api/users', () => usersApi)
|
||||
const confirmBatch = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@/components/admin-confirm', () => ({ openAdminConfirm: confirmBatch }))
|
||||
vi.mock('@/api/companies', () => ({ fetchCompanies: vi.fn().mockResolvedValue([]) }))
|
||||
vi.mock('@/pages/account/user-menu-auth-api', () => ({ loadUserMenuAuth: vi.fn() }))
|
||||
|
||||
@@ -48,6 +50,45 @@ beforeEach(() => {
|
||||
const session = useAdminSessionStore()
|
||||
session.user = { id: 1, username: 'root', role: 'super_admin' }
|
||||
usersApi.fetchUserList.mockResolvedValue(pageOf())
|
||||
usersApi.deleteUser.mockReset().mockResolvedValue(undefined)
|
||||
confirmBatch.mockReset().mockResolvedValue(false)
|
||||
})
|
||||
|
||||
it('批量删除取消不发请求;部分失败只保留失败用户', async () => {
|
||||
usersApi.deleteUser.mockRejectedValueOnce(new Error('无权删除此用户'))
|
||||
const wrapper = mount(UsersPage)
|
||||
await flushPromises()
|
||||
const button = wrapper.get('.batch-delete-actions .btn-danger')
|
||||
expect(button.attributes('disabled')).toBeDefined()
|
||||
await wrapper.get('input[aria-label="选择 京东号"]').setValue(true)
|
||||
await wrapper.get('input[aria-label="选择 存量号"]').setValue(true)
|
||||
await button.trigger('click')
|
||||
await flushPromises()
|
||||
expect(confirmBatch).toHaveBeenCalledWith(expect.objectContaining({ message: expect.stringContaining('京东号、存量号') }))
|
||||
expect(usersApi.deleteUser).not.toHaveBeenCalled()
|
||||
confirmBatch.mockResolvedValue(true)
|
||||
await button.trigger('click')
|
||||
await flushPromises()
|
||||
expect(usersApi.deleteUser.mock.calls).toEqual([[7], [8]])
|
||||
expect(button.text()).toBe('批量删除(1)')
|
||||
expect(wrapper.get('details').text()).toContain('京东号:无权删除此用户')
|
||||
expect(usersApi.fetchUserList).toHaveBeenCalledTimes(2)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('确认弹窗期间切平台,旧勾选不发删除请求', async () => {
|
||||
let resolveConfirm!: (ok: boolean) => void
|
||||
confirmBatch.mockReturnValue(new Promise<boolean>((resolve) => { resolveConfirm = resolve }))
|
||||
const wrapper = mount(UsersPage)
|
||||
await flushPromises()
|
||||
await wrapper.get('input[aria-label="选择 京东号"]').setValue(true)
|
||||
await wrapper.get('.batch-delete-actions .btn-danger').trigger('click')
|
||||
usePlatformTabStore().setActive('jd')
|
||||
resolveConfirm(true)
|
||||
await flushPromises()
|
||||
expect(usersApi.deleteUser).not.toHaveBeenCalled()
|
||||
expect(wrapper.get('.batch-delete-actions .btn-danger').text()).toBe('批量删除(0)')
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
describe('UsersPage × 平台 tab(V206)', () => {
|
||||
@@ -60,8 +101,8 @@ describe('UsersPage × 平台 tab(V206)', () => {
|
||||
expect(params).toHaveProperty('companyId')
|
||||
const headers = wrapper.findAll('thead th').map((th) => th.text())
|
||||
expect(headers).not.toContain('上架上限')
|
||||
// 亚马逊侧表头 9 列(存量表头,quota 列不渲染)
|
||||
expect(headers.length).toBe(9)
|
||||
// 亚马逊侧保留原有 9 列,另加 1 列批量选择。
|
||||
expect(headers.length).toBe(10)
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
@@ -78,12 +119,11 @@ describe('UsersPage × 平台 tab(V206)', () => {
|
||||
|
||||
const headers = wrapper.findAll('thead th').map((th) => th.text())
|
||||
expect(headers).toContain('上架上限')
|
||||
expect(headers.length).toBe(10)
|
||||
expect(headers.length).toBe(11)
|
||||
// quota 单元格:0=不限(存量号 8),null/缺省=-(京东号 7、没配号 10),800 原样
|
||||
const quotaCells = wrapper.findAll('tbody tr').map((tr) => {
|
||||
const tds = tr.findAll('td')
|
||||
// 上架上限列在第 5 列(ID/用户名/角色/所属管理员/到期时间 之后)
|
||||
return tds[5]?.text()
|
||||
return tds[6]?.text()
|
||||
})
|
||||
expect(quotaCells).toEqual(['-', '不限', '800', '-'])
|
||||
wrapper.unmount()
|
||||
|
||||
@@ -118,7 +118,7 @@ function opsColDecl(source: string): string | null {
|
||||
}
|
||||
|
||||
function sourcesOfAll(): Array<{ file: string; source: string }> {
|
||||
return vueFiles(SRC).map((file) => ({ file, source: readSource(file) }))
|
||||
return vueFiles(SRC).map((file) => ({ file, source: readSource(file, true) }))
|
||||
}
|
||||
|
||||
test('ops_ruler_actually_sees_the_family', () => {
|
||||
|
||||
@@ -260,7 +260,7 @@ test('行级明细逐字搬后端 check_message:前端不改写、不另拼句
|
||||
})
|
||||
|
||||
test('页面只有一张码表:不留旧 switch、tooltip 取后端 checkMessage、is-retry 真有条配色', () => {
|
||||
const page = readSource('src/pages/account/UserSecretsPage.vue')
|
||||
const page = readSource('src/pages/account/UserSecretsPage.vue', true)
|
||||
// ① 页面不得自带第二张表:两处各判各的,后端加分档时界面只会漏(今天漏的就是 channel_busy)
|
||||
for (const code of BACKEND_CHECK_CODES) {
|
||||
// 'ok' 这种两字母串当子串查必然误报(token/lock 里就有),它也不是会漏进旧 switch 的那族
|
||||
|
||||
Reference in New Issue
Block a user