feat(erp-frontend-vue): add Playwright E2E tests and update layout

Add Playwright configuration and E2E specs for key production, purchasing, and warehouse flows, and update layout/login to align with the new testing setup.

Made-with: Cursor
This commit is contained in:
panchengyong
2026-03-02 21:44:03 +08:00
parent e45616a09b
commit 283f727857
16 changed files with 3230 additions and 818 deletions

View File

@@ -0,0 +1,52 @@
import { test, expect } from '@playwright/test'
import { login, clickSubMenu, clickMenuItem, expectBasicList } from './utils/erpTestUtils'
test.describe('生产订单页面', () => {
test('列表搜索与基本操作按钮存在', async ({ page }) => {
await login(page)
await clickSubMenu(page, '生产管理')
await clickMenuItem(page, '/production/work-order')
await expect(page).toHaveURL(/\/production\/work-order/)
await expectBasicList(page)
// 搜索区字段
await expect(page.getByLabel('工单编码')).toBeVisible()
await expect(page.getByLabel('计划单号')).toBeVisible()
await page.getByRole('button', { name: /搜索/ }).click()
await page.getByRole('button', { name: '重置' }).click()
// 工具栏按钮:新增/修改/删除/导出
await expect(page.getByRole('button', { name: /新增/ })).toBeVisible()
await expect(page.getByRole('button', { name: /修改/ })).toBeVisible()
await expect(page.getByRole('button', { name: /删除/ })).toBeVisible()
await expect(page.getByRole('button', { name: /导出/ })).toBeVisible()
})
test('查看工单详情与状态相关操作按钮', async ({ page }) => {
await login(page)
await clickSubMenu(page, '生产管理')
await clickMenuItem(page, '/production/work-order')
const firstRow = page.locator('.el-table__row').first()
if (!(await firstRow.isVisible().catch(() => false))) test.skip()
// 查看按钮
const viewBtn = firstRow.getByRole('button', { name: '查看' }).first()
await viewBtn.click()
await expect(page.locator('.el-dialog, .el-drawer, .page-container').first()).toBeVisible()
await page.goBack().catch(() => {})
// 根据不同状态可能出现:审核、一键领料、完工、取消等按钮
// 这里只做存在性和可点击性检查(不强制业务成功)
const quickIssueBtn = firstRow.getByRole('button', { name: /一键领料/ }).first()
if (await quickIssueBtn.isVisible().catch(() => false)) {
await quickIssueBtn.click()
// 可能弹确认框,选择取消
const confirm = page.getByRole('button', { name: /取 消|取消/ }).first()
await confirm.click().catch(() => {})
}
})
})