Files
goauto/web/tests/e2e/syb-inner-codes.spec.ts
T

51 lines
3.8 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 { expect, test } from '@playwright/test'
test('档口入库码列表、回写确认与物理删除门禁符合已确认原型', async({ page, context }) => {
await page.setViewportSize({ width: 1920, height: 1080 })
await context.addCookies([{ name: 'Admin-Token', value: 'prototype-test-token', domain: 'localhost', path: '/' }])
const items = [
{ id: 1, businessDate: '2026-08-28', orderNumber: 'ORDER-001', stall: 'A档#101', specRaw: '黑色,L', shopName: '内部店铺', status: 'ready', resultMessage: '唯一匹配,等待确认回写', items: [{ ordinal: 1, sourceRow: 2, code: 'IN-001' }, { ordinal: 2, sourceRow: 3, code: 'IN-002' }], plan: { sybSpec: '黑色,L' }},
{ id: 2, businessDate: '2026-08-28', orderNumber: 'ORDER-002', stall: 'B档#202', specRaw: '白色,M', shopName: '内部店铺', status: 'needs_check', resultMessage: '写入响应不明确', items: [{ ordinal: 1, sourceRow: 4, code: 'IN-003' }], plan: { sybSpec: '白色,M' }},
]
await page.route('**/api/**', async route => {
const url = new URL(route.request().url())
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-inner-codes/apply-preview')) return route.fulfill({ json: { code: 200, data: { records: 1, inboundCodes: 2, placeholderDetails: 1, replaceOldCodes: 1, blocked: [] }}})
if (url.pathname.endsWith('/api/admin/v1/syb-inner-codes')) return route.fulfill({ json: { code: 200, data: { items, total: items.length, page: 1, pageSize: 100 }}})
return route.fulfill({ json: { code: 200, data: {} }})
})
await page.goto('http://localhost:9527/#/syb-inner-codes/index')
await expect(page.getByRole('heading', { name: '档口入库码' })).toBeVisible()
await expect(page.getByPlaceholder('订单号或入库码')).toBeVisible()
await expect(page.getByRole('columnheader', { name: '订单号' })).toBeVisible()
await expect(page.getByRole('columnheader', { name: '入库码' })).toBeVisible()
await expect(page.getByRole('columnheader', { name: '档口' })).toBeVisible()
await expect(page.getByRole('columnheader', { name: '本地规格' })).toBeVisible()
await expect(page.getByRole('columnheader', { name: 'SYB 规格' })).toBeVisible()
await expect(page.getByRole('columnheader', { name: '店铺' })).toHaveCount(0)
await expect(page.getByRole('columnheader', { name: '单件码' })).toHaveCount(0)
await expect(page.getByText('IN-001', { exact: true })).toBeVisible()
const rows = page.locator('.el-table__body-wrapper tbody tr')
await rows.nth(0).locator('.el-checkbox').click()
await page.getByRole('button', { name: '回写(1)' }).click()
await expect(page.getByText('业务记录数', { exact: true })).toBeVisible()
await expect(page.getByText('入库码总数', { exact: true })).toBeVisible()
await expect(page.getByText('预计占位明细数', { exact: true })).toBeVisible()
await expect(page.getByText('替换旧码数', { exact: true })).toBeVisible()
await expect(page.getByRole('button', { name: '回写 1 条' })).toBeEnabled()
await page.getByRole('dialog').getByRole('button', { name: '取消' }).click()
await rows.nth(0).locator('.el-checkbox').click()
await rows.nth(1).locator('.el-checkbox').click()
await expect(rows.nth(1).getByRole('button', { name: '只读复核' })).toBeVisible()
await expect(rows.nth(1).getByRole('button', { name: '重新匹配' })).toHaveCount(0)
await page.getByRole('button', { name: '删除(0)' }).click()
await expect(page.getByText('阻塞数量', { exact: true })).toBeVisible()
await expect(page.getByText(/本次不能部分删除/)).toBeVisible()
await expect(page.getByRole('button', { name: '删除 0 条' })).toBeDisabled()
})