test(web): close review gaps for SYB collection (#162)

This commit is contained in:
QiuSW
2026-08-31 10:49:33 +08:00
parent 4e05048044
commit 5270390a2e
2 changed files with 31 additions and 1 deletions
+1
View File
@@ -79,6 +79,7 @@ test('采购准备失败不清空 SYB 列表且不弹全局错误', async({ page
})
await page.goto('/#/syb-products')
await expect(page.getByText('仍然可见的商品')).toBeVisible()
await expect(page.getByText('采购准备检查失败,请点击刷新重试')).toBeVisible()
await expect(page.getByText('预检测试失败')).toHaveCount(0)
})
+30 -1
View File
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test'
const sybProductRoute = [{ path: '/goauto-order-workbench', component: 'Layout', menuName: 'GoAutoOrderWorkbench', title: '订单工作台', visible: '0', children: [{ path: '/syb-products', component: '/goauto/syb-products/index', menuName: 'GoAutoSybProducts', title: 'SYB 商品', visible: '0' }] }]
const sybProductRoute = [{ path: '/goauto-order-workbench', component: 'Layout', menuName: 'GoAutoOrderWorkbench', title: '订单工作台', visible: '0', children: [{ path: '/syb-products', component: '/goauto/syb-products/index', menuName: 'GoAutoSybProducts', title: 'SYB 商品', visible: '0' }, { path: '/shopee-products/index', component: '/goauto/shopee-products/index', menuName: 'GoAutoShopeeProducts', title: '虾皮商品', visible: '0' }] }]
test('SYB 商品工具栏与列宽按紧凑布局显示', async({ page, context }) => {
await page.setViewportSize({ width: 1920, height: 1080 })
@@ -143,6 +143,7 @@ test('未关联 PDD 显示去关联并直接打开 PDD 商品选择器', async({
await page.getByRole('button', { name: '去关联', exact: true }).click()
const popup = await popupPromise
await expect.poll(() => popup.url()).toContain('/#/shopee-products/index?productId=9&action=link_pdd')
await expect(popup.getByText('搜索并选择 PDD 商品', { exact: true })).toBeVisible()
})
test('SYB 商品页不读取或展示后台同步状态', async({ page, context }) => {
@@ -225,3 +226,31 @@ test('混选后采购与采集分别提交候选子集且采集按 PDD 去重',
expect(collectionBodies[0].pddProductIds).toEqual([302])
await expect(page.getByText('设备当前不可用', { exact: true })).toBeVisible()
})
test('去重后超过 100 个 PDD 商品时给出提示且不调用批量接口', async({ page, context }) => {
await context.addCookies([{ name: 'Admin-Token', value: 'prototype-test-token', domain: 'localhost', path: '/' }])
const collectionCalls: unknown[] = []
const rows = Array.from({ length: 101 }, (_, index) => ({ id: 400 + index, orderCode: `OVER-${400 + index}`, shopeeItemId: `94${index}`, productTitle: `超限采集候选 ${index}`, quantity: 1, parseStatus: 'success' }))
await page.route('**/api/**', async route => {
const url = new URL(route.request().url())
if (url.pathname.endsWith('/api/v1/menurole')) return route.fulfill({ json: { code: 200, data: sybProductRoute }})
if (url.pathname.startsWith('/src/api/')) return route.continue()
if (url.pathname.endsWith('/api/v1/getinfo')) return route.fulfill({ json: { code: 200, data: { roles: ['admin'], name: '管理员', avatar: '', introduction: '', permissions: [] }}})
if (url.pathname.endsWith('/api/admin/v1/syb-products')) return route.fulfill({ json: { code: 200, data: { items: rows, total: rows.length, page: 1, pageSize: 200 }}})
if (url.pathname.endsWith('/api/admin/v1/purchase-tasks/batch-preview')) {
const items = rows.map((row, index) => ({ sybProductId: row.id, pddProductId: 500 + index, pddGoodsId: `88${index}`, eligible: false, processStage: 'pdd_pending', processStageLabel: 'PDD 待采集', processStageReason: 'PDD 商品待采集', processNextAction: 'open_pdd' }))
return route.fulfill({ json: { code: 200, data: { items, eligibleCount: 0, skippedCount: items.length }}})
}
if (url.pathname.endsWith('/api/admin/v1/collection-tasks/batch')) { collectionCalls.push(route.request().postDataJSON()); return route.fulfill({ json: { code: 200, data: { items: [], successCount: 0, failureCount: 0 }}}) }
return route.fulfill({ json: { code: 200, data: [] }})
})
await page.goto('/#/syb-products')
await expect(page.locator('.el-table__body-wrapper tbody tr')).toHaveCount(101)
await page.locator('.el-table__header-wrapper .el-checkbox').first().click()
await expect(page.getByRole('button', { name: '创建 PDD 采集(101)', exact: true })).toBeEnabled()
await page.getByRole('button', { name: '创建 PDD 采集(101)', exact: true }).click()
await expect(page.getByText('一次最多创建 100 个去重后的 PDD 商品采集任务', { exact: true })).toBeVisible()
await expect(page.getByRole('dialog', { name: '批量创建 PDD 采集任务' })).toHaveCount(0)
expect(collectionCalls).toHaveLength(0)
})