commit content
This commit is contained in:
@@ -1,49 +1,125 @@
|
||||
import { test, expect } from '@playwright/test'
|
||||
import { login, clickSubMenu, clickMenuItem, expectBasicList } from './utils/erpTestUtils'
|
||||
import { login, clickSubMenu, clickMenuItem, expectBasicList, closeMessageBox } from './utils/erpTestUtils'
|
||||
|
||||
test.describe('产品 BOM(EBOM)页面', () => {
|
||||
test('明细/单据视图切换与搜索', async ({ page }) => {
|
||||
await login(page)
|
||||
test('列表页基础测试', async ({ page }) => {
|
||||
await test.step('步骤1:登录系统', async () => {
|
||||
await login(page)
|
||||
})
|
||||
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await expect(page).toHaveURL(/\/rd\/ebom/)
|
||||
await expectBasicList(page)
|
||||
await test.step('步骤2:导航到产品BOM页面', async () => {
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await expect(page).toHaveURL(/\/rd\/ebom/)
|
||||
})
|
||||
|
||||
// 明细视图:物料分类筛选存在
|
||||
await expect(page.getByText('物料分类')).toBeVisible()
|
||||
await test.step('步骤3:检查页面基本布局', async () => {
|
||||
await expectBasicList(page)
|
||||
await closeMessageBox(page)
|
||||
})
|
||||
|
||||
// 切换到单据视图
|
||||
await page.getByRole('button', { name: '单据' }).click()
|
||||
await expect(page.getByText('业务状态')).toBeVisible()
|
||||
await test.step('步骤4:检查主要功能按钮', async () => {
|
||||
const buttons = ['新增', '导出', '搜索', '重置']
|
||||
for (const btnName of buttons) {
|
||||
const btn = page.getByRole('button', { name: btnName }).first()
|
||||
if (await btn.count() > 0) {
|
||||
await expect(btn).toBeVisible()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 单据视图按单据状态/业务状态查询
|
||||
const statusSelect = page.getByLabel('单据状态')
|
||||
await statusSelect.click()
|
||||
await page.getByRole('option').first().click()
|
||||
await page.getByRole('button', { name: /搜索/ }).click()
|
||||
await test.step('步骤5:检查搜索表单', async () => {
|
||||
const searchForm = page.locator('.el-form').first()
|
||||
await expect(searchForm).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
test('新增 BOM 表单基本交互', async ({ page }) => {
|
||||
await login(page)
|
||||
test('搜索功能测试', async ({ page }) => {
|
||||
await test.step('步骤1:登录系统并导航到产品BOM页面', async () => {
|
||||
await login(page)
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await closeMessageBox(page)
|
||||
})
|
||||
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await test.step('步骤2:点击搜索按钮', async () => {
|
||||
const searchBtn = page.getByRole('button', { name: /搜索|查询/ }).first()
|
||||
if (await searchBtn.count() > 0) {
|
||||
await searchBtn.click()
|
||||
await page.waitForTimeout(500)
|
||||
await closeMessageBox(page)
|
||||
}
|
||||
})
|
||||
|
||||
await page.getByRole('button', { name: /新增/ }).click()
|
||||
await expect(page).toHaveURL(/\/ebom\/(new|edit)/)
|
||||
await expect(page.locator('.el-form').first()).toBeVisible()
|
||||
await test.step('步骤3:点击重置按钮', async () => {
|
||||
const resetBtn = page.getByRole('button', { name: /重置/ }).first()
|
||||
if (await resetBtn.count() > 0) {
|
||||
await resetBtn.click()
|
||||
await closeMessageBox(page)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 母件物料选择弹窗
|
||||
const itemSelectBtn = page.getByRole('button', { name: /选择物料|选择/ }).first().catch(() => null)
|
||||
if (itemSelectBtn) {
|
||||
await itemSelectBtn
|
||||
await expect(page.locator('.el-dialog').filter({ hasText: /选择物料/ })).toBeVisible()
|
||||
await page.getByRole('button', { name: /关 闭|关闭|取 消/ }).click().catch(() => {})
|
||||
}
|
||||
test('新增产品BOM页面测试', async ({ page }) => {
|
||||
await test.step('步骤1:登录系统并导航到产品BOM页面', async () => {
|
||||
await login(page)
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await closeMessageBox(page)
|
||||
})
|
||||
|
||||
// 明细表格存在
|
||||
await expect(page.locator('.el-table').first()).toBeVisible()
|
||||
await test.step('步骤2:点击新增按钮', async () => {
|
||||
const addBtn = page.getByRole('button', { name: /新增|新建/ }).first()
|
||||
if (await addBtn.count() > 0 && await addBtn.isVisible()) {
|
||||
await addBtn.click()
|
||||
await page.waitForTimeout(1000)
|
||||
await closeMessageBox(page)
|
||||
}
|
||||
})
|
||||
|
||||
await test.step('步骤3:检查新增页面表单', async () => {
|
||||
const form = page.locator('.el-form').first()
|
||||
if (await form.count() > 0) {
|
||||
await expect(form).toBeVisible()
|
||||
}
|
||||
})
|
||||
|
||||
await test.step('步骤4:检查主要操作按钮', async () => {
|
||||
const actionButtons = ['保存', '提交', '删除', '返回']
|
||||
for (const btnName of actionButtons) {
|
||||
const btn = page.getByRole('button', { name: btnName }).first()
|
||||
if (await btn.count() > 0) {
|
||||
await expect(btn).toBeVisible()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
await test.step('步骤5:返回列表页', async () => {
|
||||
await page.goBack()
|
||||
await page.waitForTimeout(500)
|
||||
await closeMessageBox(page)
|
||||
})
|
||||
})
|
||||
|
||||
test('导出功能测试', async ({ page }) => {
|
||||
await test.step('步骤1:登录系统并导航到产品BOM页面', async () => {
|
||||
await login(page)
|
||||
await clickSubMenu(page, '研发管理')
|
||||
await clickMenuItem(page, '/rd/ebom')
|
||||
await closeMessageBox(page)
|
||||
})
|
||||
|
||||
await test.step('步骤2:测试导出按钮', async () => {
|
||||
const exportBtn = page.getByRole('button', { name: /导出/ }).first()
|
||||
if (await exportBtn.count() > 0 && await exportBtn.isVisible()) {
|
||||
try {
|
||||
await exportBtn.click()
|
||||
await page.waitForTimeout(500)
|
||||
await closeMessageBox(page)
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user