37 lines
2.0 KiB
JavaScript
37 lines
2.0 KiB
JavaScript
import test from 'node:test'
|
||
import assert from 'node:assert/strict'
|
||
import { setupService, seatById } from './helpers.js'
|
||
|
||
async function setupFlow() {
|
||
const env = await setupService({ prompt: true })
|
||
const opened = await env.service.open({ path: '/lead-report', name: '回报项目' })
|
||
const projectId = opened.project.id
|
||
const sessions = {}
|
||
for (const seatId of ['lead', 'zhongshu', 'menxia', 'shangshu', 'gongbu']) {
|
||
const view = await env.service.enableSeat(projectId, seatId)
|
||
sessions[seatId] = seatById(view, seatId).sessionId
|
||
}
|
||
const created = await env.service.requirementUpsert(projectId, {
|
||
title: '回报测试', originalText: '回报测试', summary: '回报测试', judgement: 'can_do',
|
||
scope: '测试', acceptanceCriteria: '测试',
|
||
})
|
||
const req = created.requirement
|
||
const published = await env.service.requirementPublish(projectId, req.id, {
|
||
expectedRevision: req.revision, command: '按这个做', commandRef: { seq: 1, messageId: 'm1' },
|
||
}, { seatId: 'lead', sessionId: sessions.lead })
|
||
assert.ok(published.taskId)
|
||
return { env, projectId, req, taskId: published.taskId, sessions }
|
||
}
|
||
|
||
test('service:流程阶段在业务事务内写入 leadReports', async () => {
|
||
const { env, projectId, taskId, sessions } = await setupFlow()
|
||
const submit = await env.service.workflowSubmitDraft(projectId, taskId, { draft: '拟案内容' }, { seatId: 'zhongshu', sessionId: sessions.zhongshu })
|
||
assert.equal(submit.ok, true, submit.error)
|
||
const review = await env.service.workflowReview(projectId, taskId, { action: 'approve', note: '通过' }, { seatId: 'menxia', sessionId: sessions.menxia })
|
||
assert.equal(review.ok, true, review.error)
|
||
const reports = (await env.service.leadReports(projectId)).reports
|
||
assert.ok(reports.some(report => report.event === 'zhongshu_submit'))
|
||
assert.ok(reports.some(report => report.event === 'menxia_approve'))
|
||
assert.equal(reports.filter(report => report.event === 'zhongshu_submit').length, 1)
|
||
})
|