Files
dacli/tests/e2e/spike-clone-verify.spec.ts
T

55 lines
2.3 KiB
TypeScript

/**
* tests/e2e/spike-clone-verify.spec.ts
*
* 用 web 自动生成的菜单 enCode (spike_dm7db71) 实际访问, 看能用吗
*/
import { test, expect } from '@playwright/test'
test('VERIFY: spike_dm 真能通过菜单访问吗', async ({ page }) => {
test.setTimeout(60_000)
// 用 web 自动生成的菜单 enCode
const url = `/jnpf_app_tdd/model/spike_dm7db71`
console.log(`[VERIFY] 打开: ${url}`)
await page.goto(url)
await page.waitForLoadState('networkidle')
await page.waitForTimeout(3_000)
await page.screenshot({ path: 'screenshots/spike_dm-real-page.png', fullPage: true })
// 检查是否 404
const is404 = await page.locator('text=/未找到页面|404/').count()
console.log(`[VERIFY] 是否 404: ${is404 > 0}`)
// 检查表单字段
const hasInput = await page.locator('input[placeholder*="名称"], input[placeholder*="名称"]').count()
const hasTable = await page.locator('.vxe-table, .ant-table').count()
const newBtn = await page.locator('button:has-text("新增"), button:has-text("新 增")').count()
console.log(`[VERIFY] input=${hasInput}, table=${hasTable}, 新增按钮=${newBtn}`)
if (newBtn > 0) {
console.log(`[VERIFY] 点"新增"试一下`)
await page.locator('button:has-text("新增"), button:has-text("新 增")').first().click()
await page.waitForTimeout(2_000)
await page.screenshot({ path: 'screenshots/spike_dm-new-modal.png', fullPage: true })
const modalCount = await page.locator('.ant-modal:visible').count()
console.log(`[VERIFY] 新增弹窗数: ${modalCount}`)
if (modalCount > 0) {
// 填字段 + 提交
const inputInModal = page.locator('.ant-modal input[placeholder*="名称"]').first()
if ((await inputInModal.count()) > 0) {
await inputInModal.fill('spike_dm_验证值')
await page.waitForTimeout(300)
// 点确定
const okBtn = page.locator('.ant-modal button.ant-btn-primary, .ant-modal button:has-text("确 定")').first()
if ((await okBtn.count()) > 0) {
await okBtn.click({ force: true })
await page.waitForTimeout(3_000)
await page.screenshot({ path: 'screenshots/spike_dm-after-submit.png', fullPage: true })
console.log(`[VERIFY] 提交完成, 看数据是否入库`)
}
}
}
}
})