import assert from 'node:assert/strict' import { createRequire } from 'node:module' import { mkdir, writeFile, unlink } from 'node:fs/promises' import { resolve } from 'node:path' 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 file = resolve('ruoyi-ui-vue3/node_modules/.vite-pm/subtasks-render.html') // 仅组件浏览器验收夹具,不代替真实 MySQL 的权限、事务和并发测试,也不宣称登录端到端。 const base = { projectId: 1, type: 'TASK', description: '', assigneeId: 1, priority: 'MEDIUM', version: 3, timezone: 'Asia/Shanghai', actualStartAt: null, actualEndAt: null, plannedStartAt: '2026-10-01T09:00:00+08:00', plannedEndAt: '2026-10-04T18:00:00+08:00', canStart: false, dependencyConditions: [], blockedReasons: [], dependencyBlocked: false, scheduleConstraints: { earliestPlannedStartAt: null, scheduleValidationStatus: 'VALID', sources: [], scheduleBlockedReasons: [] } } const items = [ { ...base, id: 1, stageId: 1, title: '客户门户升级', status: 'IN_PROGRESS', overdue: true, canCreateChild: true, childCount: 1, childTerminalCount: 0 }, { ...base, id: 2, stageId: 1, title: '登录界面子任务', status: 'READY', parentTaskId: 1, parentTaskTitle: '客户门户升级', overdue: true, canStart: true, dependencyConditions: [{ id: 1, sourceId: 3, sourceWorkItemId: 3, sourceName: '跨父任务接口开发', currentStatus: 'CLOSED', expectedStatus: 'COMPLETED', satisfied: true }] }, { ...base, id: 3, stageId: 2, title: '跨父任务接口开发', status: 'CLOSED', overdue: false, plannedStartAt: '2026-09-29T09:00:00+08:00', plannedEndAt: '2026-09-30T18:00:00+08:00' }, ] const counts = { total: 0, READY: 0, IN_PROGRESS: 0, COMPLETED: 0, CANCELLED: 0, CLOSED: 0, overdue: 0, blocked: 0, scheduleIncomplete: 0 } const stages = ['开发', '联调'].map((name, index) => ({ id: index + 1, name, sortOrder: index + 1, ownerId: 1, ownerName: '项目成员', version: 0, counts: { ...counts }, plannedStartAt: base.plannedStartAt, plannedEndAt: base.plannedEndAt, fullyScheduled: 0 })) for (const item of items) { const stage = stages.find(stage => stage.id === item.stageId); stage.counts.total++; stage.counts[item.status]++; stage.counts.overdue += Number(item.overdue); stage.counts.blocked += Number(item.dependencyBlocked); stage.fullyScheduled++ } const layout = { version: 0, positions: {}, collapsedStages: [], viewport: null, filters: null } const view = { items, stages, dependencies: [{ id: 1, predecessorTaskId: 3, successorTaskId: 2 }], unassigned: { counts, fullyScheduled: 0 }, sharedLayout: layout, personalLayout: layout } const html = `子任务与状态组件验收
` await mkdir(resolve('ruoyi-ui-vue3/node_modules/.vite-pm'), { recursive: true }); await writeFile(file, html) const browser = await chromium.launch({ channel: 'chrome', headless: true }) try { const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } }), errors = [] page.on('pageerror', error => errors.push(error.message)) await page.goto((process.env.PM_FRONTEND_URL || 'http://127.0.0.1:8093') + '/node_modules/.vite-pm/subtasks-render.html', { waitUntil: 'networkidle' }) await page.locator('.flow-item').first().waitFor() assert.equal(await page.locator('.vue-flow__edge').count(), 1); assert.equal(await page.locator('.flow-item .vue-flow__handle').count(), 0) const child = page.locator('.flow-item[data-work-item="2"]'); assert.ok((await child.innerText()).includes('父任务:客户门户升级')); assert.ok((await child.innerText()).includes('超期未完成')); assert.ok((await child.innerText()).includes('跨父任务接口开发')) const board = page.locator('.board'); assert.equal(await board.locator('.lane').count(), 5); assert.ok((await board.innerText()).includes('关闭')); assert.ok((await board.innerText()).includes('子任务 · 客户门户升级')) await page.locator('.flow-item[data-work-item="1"]').getByRole('button', { name: '创建子任务', exact: true }).click() const dialog = page.locator('.el-dialog').filter({ hasText: '新建子任务' }); await dialog.waitFor() assert.equal(await dialog.locator('.picker-only .el-date-editor').count(), 2) assert.ok((await dialog.innerText()).includes('父任务:客户门户升级')); assert.ok((await dialog.innerText()).includes('最早')); assert.ok((await dialog.innerText()).includes('最晚')) assert.equal(await dialog.locator('.el-form-item').filter({ hasText: '所属阶段' }).locator('.el-select__wrapper.is-disabled').count(), 1) await mkdir('.codex-tmp/pm-ui', { recursive: true }); await page.screenshot({ path: '.codex-tmp/pm-ui/subtasks-editor.png', fullPage: true, animations: 'disabled' }) await dialog.getByRole('button', { name: '取消', exact: true }).click(); await page.screenshot({ path: '.codex-tmp/pm-ui/subtasks-flow-board.png', fullPage: true, animations: 'disabled' }) assert.deepEqual(errors, []) console.log('PASS: Chrome 子任务父归属/跨父前置摘要/超期与关闭/五列看板/子任务弹窗继承阶段/双时间选择器;仅组件渲染验收') } finally { await browser.close(); await unlink(file) }