cmvr-wms/ruoyi-project/scripts/flow-removal-ui-check.mjs

56 lines
4.4 KiB
JavaScript
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 assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { mkdir } from 'node:fs/promises'
import { seedDemo } from './demo.mjs'
const require = createRequire(import.meta.url)
const { chromium } = require(process.env.PM_PLAYWRIGHT || 'C:/Users/Administrator/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright')
const demo = await seedDemo(), frontend = process.env.PM_FRONTEND_URL || 'http://127.0.0.1:8093'
for (const item of demo.items) { assert.ok(!('flowId' in item)); assert.ok(item.dependencyConditions.every(c => c.conditionType === 'TASK_COMPLETED')) }
for (const endpoint of [`/projects/${demo.project.id}/flows`, '/nodes/1/successors']) {
const response = await fetch(`${demo.base}/project/manage${endpoint}`, { headers: { Authorization: `Bearer ${demo.token}` } })
if (response.status !== 404) console.error('移除路由响应:', response.status, (await response.clone().text()).slice(0, 500))
assert.equal(response.status, 404, '已移除路由不能重新启用流程或节点')
}
const browser = await chromium.launch({ channel: 'chrome', headless: true })
try {
const context = await browser.newContext({ viewport: { width: 1440, height: 900 } })
await context.addCookies([{ name: 'Admin-Token', value: demo.token, url: frontend }])
const page = await context.newPage(), errors = [], flowCalls = []
page.on('pageerror', error => errors.push(error.message))
page.on('request', request => { if (request.url().includes('/flows') || request.url().includes('/nodes/')) flowCalls.push(request.url()) })
await page.goto(`${frontend}/project/collaboration`, { waitUntil: 'networkidle' })
await page.locator('.workspace-select .el-select').nth(1).click()
await page.getByRole('option').filter({ hasText: demo.project.name }).click()
await page.locator('.work-surface .el-link').filter({ hasText: '任务 C:联调测试' }).click()
const drawer = page.locator('.el-drawer').filter({ hasText: '任务 C:联调测试' })
await drawer.waitFor()
assert.ok(!(await drawer.innerText()).includes('流程节点实例'))
await drawer.getByRole('button', { name: '添加前置条件', exact: true }).click()
let dialog = page.locator('.el-dialog').filter({ hasText: '添加前置条件' })
assert.ok(!(await dialog.innerText()).includes('节点'))
assert.equal(await dialog.locator('.el-radio').count(), 0)
await dialog.getByRole('button', { name: '取消', exact: true }).click()
await drawer.getByRole('button', { name: '编辑', exact: true }).first().click()
dialog = page.locator('.el-dialog').filter({ hasText: '编辑工作项' })
assert.equal(await dialog.locator('.picker-only .el-date-editor').count(), 2)
assert.equal(await dialog.locator('.picker-only > .el-input:not(.el-date-editor)').count(), 0)
assert.ok(!(await dialog.innerText()).includes('最多六位小数'))
assert.equal(await dialog.locator('.el-form-item__label').filter({ hasText: /^流程$/ }).count(), 0)
await mkdir('.codex-tmp/pm-ui', { recursive: true })
await page.screenshot({ path: '.codex-tmp/pm-ui/edit-without-flow.png', fullPage: true, animations: 'disabled' })
await dialog.getByRole('button', { name: '取消', exact: true }).click()
await drawer.locator('.el-drawer__close-btn').click()
await page.getByRole('button', { name: '批量排期', exact: true }).click()
dialog = page.locator('.el-dialog').filter({ hasText: '批量排期(整批最终状态校验)' })
assert.equal(await dialog.locator('.picker-only .el-date-editor').count(), demo.items.length * 2)
assert.equal(await dialog.locator('.picker-only > .el-input:not(.el-date-editor)').count(), 0)
assert.ok(!(await dialog.innerText()).includes('最多六位小数'))
await page.screenshot({ path: '.codex-tmp/pm-ui/batch-picker-only.png', fullPage: true, animations: 'disabled' })
await dialog.getByRole('button', { name: '取消', exact: true }).click()
await page.getByRole('tab', { name: '成员', exact: true }).click()
assert.equal(await page.getByRole('tab', { name: '成员与流程', exact: true }).count(), 0)
assert.ok(!(await page.locator('.settings-grid').innerText()).includes('流程'))
assert.deepEqual(flowCalls, []); assert.deepEqual(errors, [])
console.log('PASS: 流程/节点接口移除、仅任务依赖、编辑/批量双选择器、无精度提示、成员页仅成员;未保存或修改工作项')
} finally { await browser.close() }