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,87 @@
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/plan-order')
await expect(page).toHaveURL(/\/production\/plan-order/)
await expectBasicList(page)
// 明细视图:包含销售订单号/物料编码等字段
await expect(page.getByText('销售订单号')).toBeVisible()
await expect(page.getByText('物料编码')).toBeVisible()
// 切换到单据视图
await page.getByRole('button', { name: '单据' }).click()
await expect(page.getByText('业务状态')).toBeVisible()
// 在单据视图中按单据编码+状态查询
const codeInput = page.getByLabel('单据编码').locator('input')
await codeInput.fill('TEST')
await page.getByRole('button', { name: /搜索/ }).click()
})
test('新增生产计划单基础表单交互', async ({ page }) => {
await login(page)
await clickSubMenu(page, '生产计划')
await clickMenuItem(page, '/production/plan-order')
// 打开新增页
await page.getByRole('button', { name: /新增/ }).click()
await expect(page).toHaveURL(/\/production\/plan-order\/(new|edit)/)
await expect(page.locator('.el-form').first()).toBeVisible()
// 表头基本字段存在(生产计划单文档:计划单号/计划日期/业务类型/工作类型等)
await expect(page.getByText(/单据编码|计划单号/)).toBeVisible()
await expect(page.getByText(/单据日期|计划日期/)).toBeVisible()
// 引入订单弹窗:根据 PRD通过「引入」按钮选择销售订单/备货订单
const importBtn = page.getByRole('button', { name: /引入/ }).first()
if (await importBtn.isVisible().catch(() => false)) {
await importBtn.click()
await expect(page.getByText('订单信息')).toBeVisible()
await expect(page.locator('.el-dialog').locator('.el-table').first()).toBeVisible()
await page.getByRole('button', { name: /关 闭|关闭|取 消/ }).click()
}
// 订单 BOM 选择弹窗
const bomSelectBtn = page.getByRole('button', { name: /选择BOM|选择/ }).first().catch(() => null)
if (bomSelectBtn) {
await bomSelectBtn
await expect(page.getByText(/选择EBOM|选择BOM/)).toBeVisible()
await page.getByRole('button', { name: /关 闭|关闭|取 消/ }).click()
}
})
test('物料清单BOM运算结果区域交互', async ({ page }) => {
await login(page)
await clickSubMenu(page, '生产计划')
await clickMenuItem(page, '/production/plan-order')
// 打开一个已存在的计划单(若有)
const firstLink = page.locator('.el-table').first().getByRole('link').first()
if (!(await firstLink.isVisible().catch(() => false))) test.skip()
await firstLink.click()
await expect(page.locator('.section-title', { hasText: '物料清单' })).toBeVisible()
// BOM 运算按钮存在且可点(如果该单据允许)
const bomBtn = page.getByRole('button', { name: 'BOM运算' }).first()
if (await bomBtn.isVisible().catch(() => false)) {
await bomBtn.click()
// 可能出现 loading 或消息提示,这里只校验不会报错
}
// 物料清单表格中的下发车间、供应方式、齐套检查/补料列存在
const mbomTable = page.locator('.material-section').nth(0).locator('.el-table').first()
await expect(mbomTable).toBeVisible()
await expect(page.getByText(/供应方式/)).toBeVisible()
await expect(page.getByText(/下发车间/)).toBeVisible()
})
})