test(preview): --live 覆盖取消/成果修订/成果失效三条真实路径
- cancel:派工 accepted 后取消,task.status=cancelled、applied=true,按钮消失 - revise:真实 POST /artifact/revision,kind=revision + scope.artifact-revision - missing:fileRef 不存在 → existence=missing,界面虚线淡红卡且账本保留 - 验收记录 A12/A22/A23 补真实路由证据
This commit is contained in:
parent
f32ed10949
commit
b72efd7093
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 67 KiB |
|
|
@ -37,7 +37,7 @@ node --test --test-isolation=none test/policy.test.js workbench/test/*.test.mjs
|
|||
| A09 | 丞相带文件交接工部,材料可读、引用可追溯 | 已验(单测,附件级已通) | `A09 交接材料:附件引用原样进 packet,成果引用带版本,文本里可读`:`{attachmentId}` 保留 name/mime/size,`{artifactId}` 自动补 `revision` 与成果显示名;`buildDispatchText` 渲染成 `成果 预算表 art_x(第 1 版)`、`附件 att_abc(预算.xlsx · application/vnd.ms-excel · 2048 字节)`;缺 ID / 未知 ID 报 `INVALID_INPUT` / `NOT_FOUND`。真机"从聊天里带附件"仍需重启后确认 |
|
||||
| A10 | 正常完成:有效报告+终态+成果核验 | 已验(单测) | `完成判定分支一:报告+终态成功+成果有效 → completed` |
|
||||
| A11 | 仅变 idle 或输出"已完成"不标记完成 | 已验(单测) | `对账:运行结束但无报告 → needs_attention`;`契约解析只认四动作`(正文里的"已完成"不进状态机) |
|
||||
| A12 | 重复投递/重复完成/乱序事件不重复、不倒退 | 已验(单测) | `重复点击同一幂等键:不重复投递`;`结果去重:同 (attemptId, reportVersion) 与同 sourceMessageRef 只登记一次`;`isRegressingEvent` 拒绝倒退终态 |
|
||||
| A12 | 重复投递/重复完成/乱序事件不重复、不倒退 | 已验(单测 + 真实路由) | `重复点击同一幂等键:不重复投递`;`结果去重:同 (attemptId, reportVersion) 与同 sourceMessageRef 只登记一次`;`isRegressingEvent` 拒绝倒退终态;`--live` 场景 cancel:派工 accepted 后 `POST /task/cancel` 200,`task.status=cancelled`、`applied=true`,界面按钮消失并发绿条(`docs/preview/v01-live-cancel-400-light.png`) |
|
||||
| A13 | 回执超时 → unknown 对账,不自动重发 | 已验(单测) | `投递超时:dispatch 记 unknown,不自动重发` + `verifyUnknown` |
|
||||
| A14 | 用户直聊与派工同时到达,同 session 串行 | 已验(单测)+ 待真机 | 错误分类 `busy`;真实串行由宿主 inbox 保证,需真机观察 |
|
||||
| A15 | A/B 同时跑,停止 A,B 继续 | 已验(单测)+ 待真机 | `cancelTask:业务落 cancelled,运行中的尝试只到 cancel_requested`;取消带 `attemptId`,不会误停 B |
|
||||
|
|
@ -47,8 +47,8 @@ node --test --test-isolation=none test/policy.test.js workbench/test/*.test.mjs
|
|||
| A19 | B 不自动获得 A 的材料/记忆 | 已验(单测,材料侧) | `A09/A19 跨项目成果引用被拒`:B 项目引用 A 的 `artifactId` → `CROSS_PROJECT`,`details` 不含 A 的归属;B 的 packet 只装本任务材料(无跨项目串带)。**记忆隔离属宿主能力,仍需真机** |
|
||||
| A20 | 相同目录/父子目录识别为冲突,不宣称完全隔离 | 已验(单测) | `A20 同目录/父子目录登记成另一个项目时明确报冲突`:`DUPLICATE_PROJECT` + `relation: same/nested` + `allowSharedRoot` 显式放行 |
|
||||
| A21 | 两窗口同时改设置/消费队列不覆盖 | 已验(单测) | `saveDepartmentConfig 走 CAS:旧 revision 冲突并带回当前值`;事件日志为只读游标,多标签页不互相偷事件 |
|
||||
| A22 | 主责部门局部修改成果,保留来源/版本,不重跑全链 | 已验(单测)+ UI 接线中 | `A22 成果修订只开一条修订任务给原主责部门`:`kind:'revision'`、`reviseOfArtifactId`、版本 +1、派发自动带 `materialRefs:[{artifactId,revision}]` |
|
||||
| A23 | 删除 session 或成果文件后显示失效并保留历史 | 已验(单测)+ UI 接线中 | `A23 成果文件不见了显示 missing…`:`existence: ok/missing/unknown`,账本不改写;session 侧 `binding.status='unavailable'` |
|
||||
| A22 | 主责部门局部修改成果,保留来源/版本,不重跑全链 | 已验(单测 + 真实路由/真实 bundle) | `--live` 场景 revise:真实 `POST /artifact/revision` 200,返回 `kind:revision`、`scope.kind:artifact-revision`、`artifactRevision:1`,界面自动切任务页并显示带「修订」标签的新任务(`docs/preview/v01-live-revise-400-light.png`)。单测另验「只开一条修订任务、不重跑三省」
|
||||
| A23 | 删除 session 或成果文件后显示失效并保留历史 | 已验(单测 + 真实路由/真实 bundle) | `--live` 场景 missing:`fileRef` 指向不存在文件时 `existence=missing`,界面显示虚线淡红卡 +「· 文件已失效」,账本记录保留(`docs/preview/v01-live-missing-400-light.png`)。注意 `verification.status` 仍为 `verified` —— 那是「结果被核验过」,与「文件现在还在不在」是两个维度,不去改写它
|
||||
| A24 | 2560×1440 浅/深色、拖宽右栏 | 已验(预览) | `docs/preview/v01-workbench-rail-400-light.png` / `-dark.png`(800×1220,真 Chrome 渲染真实 bundle);拖宽逻辑 340–600 + `sansheng.workbench.railWidth` |
|
||||
| A25 | 约 390 CSS px 手机宽度抽屉可用 | 已验(预览) | `docs/preview/v01-workbench-rail-390-light.png` / `-dark.png`(780×1220):三列卡片不再折行,「未接通」保持一行、模型名省略号;抽屉本身在真机里才展开(待真机) |
|
||||
| A26 | 切主题/项目/部门后草稿、绑定、配置各归所属 | 已验(单测,数据归属)+ 待真机界面 | `A26 切项目后草稿、绑定、配置各归所属`:两个项目各自 `gongbu` 配置不同模型、绑不同会话、各存一条 draft 任务;`bootstrap(A)/(B)` 的席位配置、`binding.currentSessionId`、任务标题互不串带。界面切换时草稿保留仍需真机点一遍 |
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ function parseArgs(argv) {
|
|||
chrome: null,
|
||||
view: 'court',
|
||||
open: '',
|
||||
scenario: '',
|
||||
live: false,
|
||||
help: false,
|
||||
}
|
||||
|
|
@ -82,6 +83,7 @@ function parseArgs(argv) {
|
|||
chrome: 'chrome',
|
||||
view: 'view',
|
||||
open: 'open',
|
||||
scenario: 'scenario',
|
||||
}
|
||||
for (let index = 0; index < argv.length; index += 1) {
|
||||
const arg = argv[index]
|
||||
|
|
@ -117,6 +119,15 @@ function parseArgs(argv) {
|
|||
return options
|
||||
}
|
||||
|
||||
function inferLiveScenario(name, view) {
|
||||
if (/cancel/i.test(name)) return 'cancel'
|
||||
if (/revise/i.test(name)) return 'revise'
|
||||
if (/missing/i.test(name)) return 'missing'
|
||||
if (view === 'tasks') return 'tasks'
|
||||
if (view === 'artifacts') return 'revise'
|
||||
return 'court'
|
||||
}
|
||||
|
||||
function usage() {
|
||||
return [
|
||||
'用法:',
|
||||
|
|
@ -133,6 +144,7 @@ function usage() {
|
|||
' --chrome Chrome/Edge 可执行文件路径,默认自动探测',
|
||||
' --view court | tasks | artifacts,先切到该页签再截图,默认 court',
|
||||
' --open 切到成果页后点开匹配这段文字的成果行(看详情抽屉)',
|
||||
' --scenario live 场景:court | tasks | cancel | revise | missing(默认按 --name 推断)',
|
||||
' --live 不打死数据:把 bundle 的 fetch 接到仓库内真实 Host 路由(内存账本)',
|
||||
' --help 显示本帮助',
|
||||
].join('\n')
|
||||
|
|
@ -1674,6 +1686,14 @@ function createLiveFetch(handlers, live) {
|
|||
})
|
||||
log(`[live] dispatch.status=${record ? (record.status || record.state) : '(无)'}`)
|
||||
}
|
||||
if (path.endsWith('/task/cancel')) {
|
||||
live.cancellations.push({ httpStatus: res.statusCode, payload })
|
||||
log(`[live] cancel.status=${payload?.value?.task?.status ?? '(无)'}`)
|
||||
}
|
||||
if (path.endsWith('/artifact/revision')) {
|
||||
live.revisions.push({ httpStatus: res.statusCode, payload })
|
||||
log(`[live] revision.task.kind=${payload?.value?.task?.kind ?? '(无)'}`)
|
||||
}
|
||||
|
||||
return {
|
||||
ok: res.statusCode >= 200 && res.statusCode < 300,
|
||||
|
|
@ -1698,6 +1718,8 @@ async function setupLiveHost() {
|
|||
const live = {
|
||||
requests: [],
|
||||
dispatches: [],
|
||||
cancellations: [],
|
||||
revisions: [],
|
||||
prompts: [],
|
||||
projectId: null,
|
||||
controller: null,
|
||||
|
|
@ -1926,12 +1948,163 @@ async function dispatchTaskLive(hooks, rootVNode, tree, title) {
|
|||
return { tree: waited.tree, before, after, ok: waited.ok, passes: waited.passes }
|
||||
}
|
||||
|
||||
async function runLiveScenario({ hooks, rootVNode, view, live, projectId }) {
|
||||
async function createDraftTaskThroughFormLive(hooks, rootVNode, tree, title, objective) {
|
||||
let next = await openTaskFormLive(hooks, rootVNode, tree)
|
||||
let passes = 0
|
||||
for (const [className, value] of [
|
||||
['wb-input', title],
|
||||
['wb-textarea', objective],
|
||||
['wb-select', 'gongbu'],
|
||||
]) {
|
||||
next = await setFormFieldLive(hooks, rootVNode, next, className, value)
|
||||
passes += 1
|
||||
}
|
||||
next = await submitTaskFormLive(hooks, rootVNode, next)
|
||||
const drafted = await liveWait(
|
||||
hooks,
|
||||
rootVNode,
|
||||
(candidate) => Boolean(findMounted(candidate, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes(title))),
|
||||
'等待草稿任务出现在列表',
|
||||
)
|
||||
if (!drafted.ok) fail(`[live] 表单提交后任务列表没有出现「${title}」`)
|
||||
next = drafted.tree
|
||||
passes += drafted.passes
|
||||
log(`[live] 表单已存为草稿:${title}`)
|
||||
return { tree: next, passes }
|
||||
}
|
||||
|
||||
async function cancelTaskLive(hooks, rootVNode, tree, title) {
|
||||
const taskCard = findMounted(tree, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes(title))
|
||||
if (!taskCard) fail(`[live] 任务列表里找不到「${title}」`)
|
||||
const before = textOf(taskCard)
|
||||
const button = findClickableByText(taskCard, '取消')
|
||||
if (!button) fail(`[live]「${title}」没有「取消」按钮:${before}`)
|
||||
log(`[live] 点击「取消」;点击前:${before}`)
|
||||
clickMounted(button)
|
||||
const waited = await liveWait(
|
||||
hooks,
|
||||
rootVNode,
|
||||
(next) => {
|
||||
const card = findMounted(next, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes(title))
|
||||
if (!card) return false
|
||||
const text = textOf(card)
|
||||
return text.includes('已取消') && !findClickableByText(card, '取消')
|
||||
},
|
||||
'等待任务变成已取消且取消按钮消失',
|
||||
)
|
||||
const afterCard = findMounted(waited.tree, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes(title))
|
||||
const after = afterCard ? textOf(afterCard) : '(任务消失)'
|
||||
log(`[live]「取消」后:${after}`)
|
||||
return { tree: waited.tree, before, after, ok: waited.ok, passes: waited.passes }
|
||||
}
|
||||
|
||||
async function openArtifactLive(hooks, rootVNode, tree, name) {
|
||||
const row = findMounted(tree, (node) => classNameOf(node).includes('wb-artifact') && textOf(node).includes(name))
|
||||
if (!row) fail(`[live] 成果列表里找不到「${name}」`)
|
||||
const before = textOf(row)
|
||||
const className = classNameOf(row)
|
||||
clickMounted(row)
|
||||
const opened = await liveWait(hooks, rootVNode, (next) => Boolean(findClass(next, 'wb-drawer')), '等待成果详情抽屉')
|
||||
if (!opened.ok) fail('[live] 点击成果行后详情抽屉没有出现')
|
||||
log(`[live] 已打开成果「${name}」;行 class="${className}"`)
|
||||
return { tree: opened.tree, before, className, passes: opened.passes }
|
||||
}
|
||||
|
||||
async function openRevisionFormLive(hooks, rootVNode, tree) {
|
||||
const drawer = findClass(tree, 'wb-drawer')
|
||||
if (!drawer) fail('[live] 成果抽屉不存在')
|
||||
const button = findClickableByText(drawer, '找主责部门修改')
|
||||
if (!button) fail('[live] 成果抽屉里没有「找主责部门修改」')
|
||||
clickMounted(button)
|
||||
const opened = await liveWait(
|
||||
hooks,
|
||||
rootVNode,
|
||||
(next) => Boolean(findClass(findClass(next, 'wb-drawer'), 'wb-form')),
|
||||
'等待修订表单展开',
|
||||
)
|
||||
if (!opened.ok) fail('[live] 点击「找主责部门修改」后表单没有出现')
|
||||
return { tree: opened.tree, passes: opened.passes }
|
||||
}
|
||||
|
||||
async function submitRevisionLive(hooks, rootVNode, tree, instruction) {
|
||||
const field = findClass(findClass(tree, 'wb-drawer'), 'wb-textarea')
|
||||
if (!field || !field.props || typeof field.props.onChange !== 'function') fail('[live] 修订表单里没有可输入的 textarea')
|
||||
field.props.onChange({ target: { value: instruction }, currentTarget: { value: instruction } })
|
||||
let next = await liveSettle(hooks, rootVNode, '填写修订说明')
|
||||
const form = findClass(findClass(next, 'wb-drawer'), 'wb-form')
|
||||
if (!form || !form.props || typeof form.props.onSubmit !== 'function') fail('[live] 修订表单没有 onSubmit')
|
||||
log('[live] 点击「存为草稿」提交修订')
|
||||
form.props.onSubmit({ preventDefault() {}, target: {}, currentTarget: {} })
|
||||
const waited = await liveWait(
|
||||
hooks,
|
||||
rootVNode,
|
||||
(candidate) => Boolean(findMounted(candidate, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes('修订'))),
|
||||
'等待修订任务出现在任务页',
|
||||
)
|
||||
next = waited.tree
|
||||
log(`[live] 修订后任务页可见:${Boolean(findMounted(next, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes('修订')))}`)
|
||||
return { tree: next, ok: waited.ok, passes: waited.passes + 1 }
|
||||
}
|
||||
|
||||
async function postLiveJson(live, path, body) {
|
||||
const response = await live.fetchLive(`${ROUTE_PREFIX}${path}`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
const payload = await response.json()
|
||||
if (!response.ok || !payload?.ok) {
|
||||
fail(`[live] POST ${path} 失败:HTTP ${response.status} ${JSON.stringify(payload)}`)
|
||||
}
|
||||
return { response, payload }
|
||||
}
|
||||
|
||||
async function prepareLiveScenario(live, scenario) {
|
||||
if (scenario !== 'revise' && scenario !== 'missing') return
|
||||
log(`[live] 准备 ${scenario} 场景:真实 POST /connect + POST /task,成果走 service.registerArtifact`)
|
||||
await postLiveJson(live, '/connect', { projectId: live.projectId, roleId: 'gongbu' })
|
||||
const created = await postLiveJson(live, '/task', {
|
||||
projectId: live.projectId,
|
||||
title: scenario === 'revise' ? '修订载体任务' : '失效载体任务',
|
||||
objective: '为成果页场景准备一条真实任务。',
|
||||
ownerRoleId: 'gongbu',
|
||||
sourceRoleId: 'lead',
|
||||
status: 'draft',
|
||||
})
|
||||
const task = created.payload.value && created.payload.value.task
|
||||
if (!task || typeof task.id !== 'string') fail('[live] /task 没有返回 task.id')
|
||||
const artifactInput = scenario === 'missing'
|
||||
? {
|
||||
projectId: live.projectId,
|
||||
taskId: task.id,
|
||||
ownerRoleId: 'gongbu',
|
||||
fileRef: join(SCRATCH, 'live-missing', '不存在的验收单.pdf'),
|
||||
displayName: '已失效验收单.pdf',
|
||||
mediaType: 'application/pdf',
|
||||
verification: { status: 'verified' },
|
||||
}
|
||||
: {
|
||||
projectId: live.projectId,
|
||||
taskId: task.id,
|
||||
ownerRoleId: 'gongbu',
|
||||
fileRef: join(ROOT, 'docs/preview/v01-live-court-400-light.png'),
|
||||
displayName: '待修订预览截图.png',
|
||||
mediaType: 'image/png',
|
||||
verification: { status: 'verified' },
|
||||
}
|
||||
// 仓库没有 POST /artifact 端点(routes.mjs 只有 /artifact/revision),
|
||||
// 所以按 Lead 允许的方式直接调 service.registerArtifact;这条不是 HTTP。
|
||||
const registered = live.host.service.registerArtifact(artifactInput)
|
||||
log(`[live] 直接调用 service.registerArtifact(非 HTTP):${registered.artifact.id},existence=${registered.artifact.existence}`)
|
||||
live.preparedArtifact = registered.artifact
|
||||
}
|
||||
|
||||
async function runLiveScenario({ hooks, rootVNode, view, live, projectId, scenario }) {
|
||||
let tree = await liveSettle(hooks, rootVNode, '首屏 bootstrap')
|
||||
const assertions = []
|
||||
let passes = 0
|
||||
|
||||
if (view === 'court') {
|
||||
if (scenario === 'court') {
|
||||
const connected = await connectSeatLive(hooks, rootVNode, tree, '丞相')
|
||||
tree = connected.tree
|
||||
passes += connected.passes
|
||||
|
|
@ -1951,7 +2124,7 @@ async function runLiveScenario({ hooks, rootVNode, view, live, projectId }) {
|
|||
before: '(无)',
|
||||
after: courtNoticeText,
|
||||
})
|
||||
} else if (view === 'tasks') {
|
||||
} else if (scenario === 'tasks' || scenario === 'cancel') {
|
||||
const connected = await connectSeatLive(hooks, rootVNode, tree, '工部')
|
||||
tree = connected.tree
|
||||
passes += connected.passes
|
||||
|
|
@ -1970,26 +2143,9 @@ async function runLiveScenario({ hooks, rootVNode, view, live, projectId }) {
|
|||
const title = '实机验证:预览器直连 Host'
|
||||
const objective = '确认 --live 模式能把任务单真正送进工部会话。'
|
||||
// 真实路径:新建 → 存为草稿 → 任务行点「派工」,不经过 queued 接口。
|
||||
tree = await openTaskFormLive(hooks, rootVNode, tree)
|
||||
const fields = [
|
||||
['wb-input', title],
|
||||
['wb-textarea', objective],
|
||||
['wb-select', 'gongbu'],
|
||||
]
|
||||
for (const [className, value] of fields) {
|
||||
tree = await setFormFieldLive(hooks, rootVNode, tree, className, value)
|
||||
}
|
||||
tree = await submitTaskFormLive(hooks, rootVNode, tree)
|
||||
const drafted = await liveWait(
|
||||
hooks,
|
||||
rootVNode,
|
||||
(next) => Boolean(findMounted(next, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes(title))),
|
||||
'等待草稿任务出现在列表',
|
||||
)
|
||||
if (!drafted.ok) fail(`[live] 表单提交后任务列表没有出现「${title}」`)
|
||||
const drafted = await createDraftTaskThroughFormLive(hooks, rootVNode, tree, title, objective)
|
||||
tree = drafted.tree
|
||||
passes += drafted.passes
|
||||
log(`[live] 表单已存为草稿:${title}`)
|
||||
|
||||
const dispatched = await dispatchTaskLive(hooks, rootVNode, tree, title)
|
||||
const dispatchRecord = live.dispatches.length > 0 ? live.dispatches[live.dispatches.length - 1] : null
|
||||
|
|
@ -2015,8 +2171,101 @@ async function runLiveScenario({ hooks, rootVNode, view, live, projectId }) {
|
|||
before: '(无)',
|
||||
after: noticeText,
|
||||
})
|
||||
|
||||
if (scenario === 'cancel') {
|
||||
const cancelled = await cancelTaskLive(hooks, rootVNode, tree, title)
|
||||
tree = cancelled.tree
|
||||
passes += cancelled.passes
|
||||
const cancelRecord = live.cancellations.length > 0 ? live.cancellations[live.cancellations.length - 1] : null
|
||||
if (cancelRecord) {
|
||||
log(`[live] /task/cancel 返回:HTTP ${cancelRecord.httpStatus} ${JSON.stringify(cancelRecord.payload)}`)
|
||||
}
|
||||
const cancelledTask = cancelRecord?.payload?.value?.task
|
||||
assertions.push({
|
||||
name: '任务状态变为已取消且取消按钮消失',
|
||||
ok: cancelled.ok && cancelled.after.includes('已取消') && !cancelled.after.includes('派工')
|
||||
&& !cancelled.after.includes('取消取消'),
|
||||
before: cancelled.before,
|
||||
after: cancelled.after,
|
||||
})
|
||||
assertions.push({
|
||||
name: 'POST /task/cancel 返回 task.status=cancelled',
|
||||
ok: cancelRecord?.httpStatus === 200 && cancelledTask?.status === 'cancelled',
|
||||
before: '(无)',
|
||||
after: `HTTP ${cancelRecord?.httpStatus ?? '(无)'} status=${cancelledTask?.status ?? '(无)'}`,
|
||||
})
|
||||
}
|
||||
} else if (scenario === 'revise') {
|
||||
const switched = await switchPreviewState(hooks, rootVNode, 'artifacts', '', tree)
|
||||
tree = switched.tree
|
||||
passes += switched.passes
|
||||
log(`[live] 已切到成果页:${switched.clickedTab || '(未切换)'}`)
|
||||
|
||||
const name = live.preparedArtifact?.displayName
|
||||
if (!name) fail('[live] revise 场景没有准备好的成果')
|
||||
const opened = await openArtifactLive(hooks, rootVNode, tree, name)
|
||||
tree = opened.tree
|
||||
passes += opened.passes
|
||||
|
||||
const reviseOpened = await openRevisionFormLive(hooks, rootVNode, tree)
|
||||
tree = reviseOpened.tree
|
||||
passes += reviseOpened.passes
|
||||
|
||||
const submitted = await submitRevisionLive(
|
||||
hooks,
|
||||
rootVNode,
|
||||
tree,
|
||||
'请把标题改得更清楚,并补一张 800px 宽的截图。',
|
||||
)
|
||||
tree = submitted.tree
|
||||
passes += submitted.passes
|
||||
|
||||
const revisionRecord = live.revisions.length > 0 ? live.revisions[live.revisions.length - 1] : null
|
||||
const revisionTask = revisionRecord?.payload?.value?.task
|
||||
if (revisionRecord) {
|
||||
log(`[live] /artifact/revision 返回:HTTP ${revisionRecord.httpStatus} ${JSON.stringify(revisionRecord.payload)}`)
|
||||
}
|
||||
assertions.push({
|
||||
name: 'POST /artifact/revision 返回 200 且任务是 artifact-revision',
|
||||
ok: revisionRecord?.httpStatus === 200
|
||||
&& revisionTask?.kind === 'revision'
|
||||
&& revisionTask?.scope?.kind === 'artifact-revision',
|
||||
before: '(无)',
|
||||
after: `HTTP ${revisionRecord?.httpStatus ?? '(无)'} kind=${revisionTask?.kind ?? '(无)'} scope=${revisionTask?.scope?.kind ?? '(无)'}`,
|
||||
})
|
||||
const revisionRow = findMounted(submitted.tree, (node) => classNameOf(node).includes('wb-task') && textOf(node).includes('修订'))
|
||||
assertions.push({
|
||||
name: '任务页出现带「修订」标签的新任务行',
|
||||
ok: Boolean(revisionRow) && submitted.ok,
|
||||
before: '(无)',
|
||||
after: revisionRow ? textOf(revisionRow) : '(未找到)',
|
||||
})
|
||||
} else if (scenario === 'missing') {
|
||||
const switched = await switchPreviewState(hooks, rootVNode, 'artifacts', '', tree)
|
||||
tree = switched.tree
|
||||
passes += switched.passes
|
||||
log(`[live] 已切到成果页:${switched.clickedTab || '(未切换)'}`)
|
||||
|
||||
const name = live.preparedArtifact?.displayName
|
||||
if (!name) fail('[live] missing 场景没有准备好的成果')
|
||||
const row = findMounted(tree, (node) => classNameOf(node).includes('wb-artifact') && textOf(node).includes(name))
|
||||
const rowClass = row ? classNameOf(row) : ''
|
||||
const rowText = row ? textOf(row) : ''
|
||||
log(`[live] 失效成果行:class="${rowClass}" text="${rowText}"`)
|
||||
assertions.push({
|
||||
name: '缺失文件显示虚线淡红卡(is-missing)',
|
||||
ok: Boolean(row) && rowClass.includes('is-missing'),
|
||||
before: '(无)',
|
||||
after: rowClass,
|
||||
})
|
||||
assertions.push({
|
||||
name: '缺失文件行显示「· 文件已失效」',
|
||||
ok: Boolean(row) && rowText.includes('文件已失效'),
|
||||
before: '(无)',
|
||||
after: rowText,
|
||||
})
|
||||
} else {
|
||||
fail(`--live 目前只编排 court / tasks 两个场景,收到:${view}`)
|
||||
fail(`--live 未知场景:${scenario}`)
|
||||
}
|
||||
|
||||
const dispatch = live.dispatches.length > 0 ? live.dispatches[live.dispatches.length - 1] : null
|
||||
|
|
@ -2026,6 +2275,9 @@ async function runLiveScenario({ hooks, rootVNode, view, live, projectId }) {
|
|||
assertions,
|
||||
requests: live.requests,
|
||||
dispatches: live.dispatches,
|
||||
cancellations: live.cancellations,
|
||||
revisions: live.revisions,
|
||||
preparedArtifact: live.preparedArtifact ?? null,
|
||||
dispatchStatus: dispatch ? dispatch.status : null,
|
||||
prompts: live.prompts,
|
||||
projectId,
|
||||
|
|
@ -2518,7 +2770,13 @@ async function main() {
|
|||
const view = String(options.view || 'court')
|
||||
if (!['court', 'tasks', 'artifacts'].includes(view)) fail(`--view 只能是 court / tasks / artifacts,收到:${view}`)
|
||||
const openText = String(options.open || '')
|
||||
const effectiveView = openText && view === 'court' ? 'artifacts' : view
|
||||
const scenario = options.live ? String(options.scenario || inferLiveScenario(name, view)) : ''
|
||||
if (options.live && !['court', 'tasks', 'cancel', 'revise', 'missing'].includes(scenario)) {
|
||||
fail(`--scenario 只能是 court / tasks / cancel / revise / missing,收到:${scenario}`)
|
||||
}
|
||||
const effectiveView = scenario === 'revise' || scenario === 'missing'
|
||||
? 'artifacts'
|
||||
: (scenario === 'cancel' ? 'tasks' : (openText && view === 'court' ? 'artifacts' : view))
|
||||
|
||||
const bundlePath = resolve(ROOT, options.bundle)
|
||||
const outDir = resolve(ROOT, options.out)
|
||||
|
|
@ -2539,6 +2797,7 @@ async function main() {
|
|||
log('模式:--live(真实 Host 路由,内存账本,不使用固定数据)')
|
||||
live = await setupLiveHost()
|
||||
await registerLiveProject(live)
|
||||
await prepareLiveScenario(live, scenario)
|
||||
}
|
||||
|
||||
log(`加载 bundle:${bundlePath}`)
|
||||
|
|
@ -2607,6 +2866,7 @@ async function main() {
|
|||
view: effectiveView,
|
||||
live,
|
||||
projectId: live.projectId,
|
||||
scenario,
|
||||
})
|
||||
tree = liveScenario.tree
|
||||
settleResult.passes += liveScenario.passes
|
||||
|
|
@ -2659,6 +2919,9 @@ async function main() {
|
|||
projectId: liveScenario.projectId,
|
||||
requests: liveScenario.requests,
|
||||
dispatches: liveScenario.dispatches,
|
||||
cancellations: liveScenario.cancellations,
|
||||
revisions: liveScenario.revisions,
|
||||
preparedArtifact: liveScenario.preparedArtifact,
|
||||
dispatchStatus: liveScenario.dispatchStatus,
|
||||
prompts: liveScenario.prompts.map((entry) => ({
|
||||
sessionId: entry.sessionId,
|
||||
|
|
@ -2674,6 +2937,7 @@ async function main() {
|
|||
width,
|
||||
scale,
|
||||
view: effectiveView,
|
||||
scenario: scenario || null,
|
||||
openedArtifact: stateSwitch.openedArtifact,
|
||||
html: htmlPath,
|
||||
png: pngPath,
|
||||
|
|
@ -2706,6 +2970,9 @@ async function main() {
|
|||
projectId: liveScenario.projectId,
|
||||
requests: liveScenario.requests,
|
||||
dispatches: liveScenario.dispatches,
|
||||
cancellations: liveScenario.cancellations,
|
||||
revisions: liveScenario.revisions,
|
||||
preparedArtifact: liveScenario.preparedArtifact,
|
||||
dispatchStatus: liveScenario.dispatchStatus,
|
||||
prompts: liveScenario.prompts,
|
||||
assertions: liveScenario.assertions,
|
||||
|
|
|
|||
Loading…
Reference in New Issue