mirror of
https://github.com/ThearchyHelios/AgentLab.git
synced 2026-11-18 02:42:00 +00:00
审批质询收尾:审批列表取不到时别的审批里问的单独一组写「无法确认提问时的报告版本」并给重试;质询回答的问题摘要截在空格上也补省略号;工件页签里运行结束之后才写下的工件不给航迹跳转
- 审批列表没取到时,那几条以前被标成「报告其他版本上的质询」:同一屏上卡里挂在句子下面的一条,证据页签却说是别的 版本,审批人会以为报告换过稿,也没有办法重取。现在单独一组照实说没能确认、给「重试」,取到后按结果各归其位(这张 审批里问的回到句子下面,审的是另一稿的才算其他版本);取到了列表却没有那张审批的、报告没有报告文档的照旧算对不上 - 质询回答工件的说明:服务端先去掉问题首尾的空白再截前 40 字,摘要以空格结尾只会是截断截在了空白上。以前先去空白再 数字数,少一个字就漏了省略号,半句话读成整个问题;改为按原样数、显示时才去空白 - 运行详情「工件」页签:晚于运行结束的工件(封存后追加的质询回答和它查询的快照)以前也给「T+…」跳转,点了把航迹拖到 运行结束之后几十分钟、几天;现在只写时间。pages/runs/ArtifactsPane.tsx 只加了结束时刻这一道边界,运行中、停在审批上 的运行照旧(航迹还没有结束时刻) - 预览用例 inquiry-run-artifacts 换成带起止时间的航迹、多一件以空格结尾的问题摘要;check-inquiry 补对应断言,以及审批 列表取不到时的标题、重试、重试后的归拢和深浅色对比度
This commit is contained in:
@@ -4329,6 +4329,18 @@
|
||||
"unit": "u2"
|
||||
},
|
||||
"created_at": "2026-10-05T06:58:00"
|
||||
},
|
||||
{
|
||||
"id": "ab8f8dbfb139d3be461bd9b5f4024cc161be5588a2eea9275a47eac160bfc885",
|
||||
"kind": "inquiry_answer",
|
||||
"node_id": null,
|
||||
"size": 2380,
|
||||
"meta": {
|
||||
"report": "write",
|
||||
"unit": "u3",
|
||||
"question": "本周枫岭片区 GMV 环比下降了多少?下降的主要原因是不是 SKU 结构的变化 "
|
||||
},
|
||||
"created_at": "2026-10-05T07:04:00"
|
||||
}
|
||||
],
|
||||
"card_artifact": "757e03414694c3b3480236718d32082ba449e7712d9ce99f4aee39ffdc5c3f4e"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useMemo, useState, type JSX } from 'react'
|
||||
import { createPortal } from 'react-dom'
|
||||
import { parseServerTime } from '../../lib/format'
|
||||
import { ArtifactsPane, useRunArtifacts } from '../../pages/runs/ArtifactsPane'
|
||||
import { EvidencePane } from '../../pages/runs/EvidencePane'
|
||||
import { ApprovalCard } from '../../run/RunPanel'
|
||||
@@ -29,7 +30,8 @@ import fx from './inquiry.json'
|
||||
* - ?syn=inquiry-run-formal:封存了的正式运行,不给入口,审批时问过的照列
|
||||
* - ?syn=inquiry-run-waiting:停在审批上的运行,同运行详情直接打开「证据」页签:时间线里的待审批卡和证据页签同时挂着
|
||||
* 同一份报告的问答串(卡上这张审批里问的直接认,证据页签哪张审批都要对一下)
|
||||
* - ?syn=inquiry-run-artifacts:运行详情的「工件」页签(pages/runs/ArtifactsPane),工件列表里有质询的回答
|
||||
* - ?syn=inquiry-run-artifacts:运行详情的「工件」页签(pages/runs/ArtifactsPane),工件列表里有封存后追加的质询回答
|
||||
* (运行期间产出的能跳到航迹,封存后追加的不能)
|
||||
*
|
||||
* 列表、提问、质询工件、报告文档、证据图、审批列表、工件列表、设置都由检查脚本用 page.route 伪造;直接打开时问答串照实说
|
||||
* 无法读取。
|
||||
@@ -141,13 +143,22 @@ function Waiting({ approval, run }: { approval: Approval; run: Run }) {
|
||||
)
|
||||
}
|
||||
|
||||
/** 运行详情的「工件」页签:工件列表由检查脚本按 inquiry.json 的 run_artifacts 答 */
|
||||
/**
|
||||
* 运行详情的「工件」页签:工件列表由检查脚本按 inquiry.json 的 run_artifacts 答。航迹的起止照这次运行的开始、结束时间
|
||||
* 给(同运行详情):运行期间产出的工件能跳到航迹里那一刻,封存后追加的质询回答和它的查询快照不给跳转。点过的跳转记在
|
||||
* data-fixture-moment 上
|
||||
*/
|
||||
function RunArtifacts({ run }: { run: Run }) {
|
||||
const list = useRunArtifacts(run.id, '0')
|
||||
const trace = useMemo(() => emptyTrace(), [])
|
||||
const trace = useMemo(() => ({
|
||||
...emptyTrace(), phase: 'succeeded' as const,
|
||||
startedAt: parseServerTime(run.started_at ?? null)?.getTime(), endedAt: parseServerTime(run.finished_at ?? null)?.getTime(),
|
||||
}), [run.started_at, run.finished_at])
|
||||
const [moment, setMoment] = useState<number | null>(null)
|
||||
return (
|
||||
<div className="h-screen min-w-0" data-fixture="inquiry-run-artifacts">
|
||||
<ArtifactsPane list={list} graph={null} trace={trace} labelOf={(id) => (id ? LABELS[id] : undefined)} />
|
||||
<div className="h-screen min-w-0" data-fixture="inquiry-run-artifacts" data-fixture-moment={moment ?? ''}>
|
||||
<ArtifactsPane list={list} graph={null} trace={trace} labelOf={(id) => (id ? LABELS[id] : undefined)}
|
||||
onMoment={(at) => setMoment(at)} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3442,6 +3442,12 @@ export const INQUIRY_TEXT = {
|
||||
/** 之前几轮审批里问的、报告后来改写过(句子编号对不上),或者对不上是哪一稿:单独一组 */
|
||||
otherDoc: '报告其他版本上的质询',
|
||||
otherDocHint: '提问时的报告与当前显示的版本不同,或无法确认是否相同,所以不挂到当前报告的句子下面',
|
||||
/**
|
||||
* 别的审批里问的、审批列表又没取到:不知道提问时审的是哪一稿,不能说成「其他版本」(审批人会以为报告换过稿)。
|
||||
* 单独一组照实说没能确认,给重试
|
||||
*/
|
||||
unsureDoc: '无法确认提问时的报告版本',
|
||||
unsureDocHint: '审批记录读取失败,暂不挂到当前报告的句子下面',
|
||||
loadFailed: '无法读取之前的质询记录',
|
||||
retry: '重试',
|
||||
q: '问',
|
||||
@@ -3514,12 +3520,11 @@ export const INQUIRY_TEXT = {
|
||||
artifactKind: '质询回答',
|
||||
/**
|
||||
* 服务端在工件的 meta 里只记问题的前 40 字(engine/inquiry.py 的 QUESTION_BRIEF):满 40 字的多半截断过,末尾补省略号,
|
||||
* 免得半句话读成整个问题
|
||||
* 免得半句话读成整个问题。字数按原样数、显示时才去掉首尾空白:服务端截之前已经去过整个问题的首尾空白,摘要以空格、
|
||||
* 换行结尾只会是截断截在了空白上,先去空白再数就少了一个字、漏掉省略号
|
||||
*/
|
||||
artifactAbout: (question: string) => {
|
||||
const chars = [...question.trim()]
|
||||
return `质询「${chars.join('')}${chars.length >= 40 ? '…' : ''}」的回答`
|
||||
},
|
||||
artifactAbout: (question: string) =>
|
||||
`质询「${question.trim()}${[...question].length >= 40 ? '…' : ''}」的回答`,
|
||||
/** meta 里没有问题摘要时的说法(服务端照理都会记,这里兜底):照报告文档那一句写装的是什么 */
|
||||
artifactAboutNone: '审批质询的回答:逐段的片段和每个数字的出处',
|
||||
}
|
||||
|
||||
@@ -136,6 +136,8 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
|
||||
}
|
||||
|
||||
const t0 = trace.timed ? trace.startedAt : undefined
|
||||
// 运行结束之后才写下的(封存后追加的质询回答和它查询的快照):航迹里没有那一刻,不给跳转,只写时间
|
||||
const t1 = trace.timed ? trace.endedAt : undefined
|
||||
let budget = all ? Infinity : FIRST_ROWS
|
||||
const hidden = Math.max(0, groups.reduce((n, [, g]) => n + g.length, 0) - FIRST_ROWS)
|
||||
|
||||
@@ -174,7 +176,7 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
|
||||
budget -= take.length
|
||||
return (
|
||||
<Group key={nodeId || '—'} nodeId={nodeId} rows={take} total={rows.length} graph={graph} trace={trace}
|
||||
labelOf={labelOf} t0={t0} onOpen={setOpen} onMoment={onMoment} />
|
||||
labelOf={labelOf} t0={t0} t1={t1} onOpen={setOpen} onMoment={onMoment} />
|
||||
)
|
||||
})}
|
||||
{!all && hidden > 0 && (
|
||||
@@ -190,7 +192,7 @@ export function ArtifactsPane({ list, graph, trace, labelOf, onMoment }: {
|
||||
)
|
||||
}
|
||||
|
||||
function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMoment }: {
|
||||
function Group({ nodeId, rows, total, graph, trace, labelOf, t0, t1, onOpen, onMoment }: {
|
||||
nodeId: string
|
||||
rows: RunArtifact[]
|
||||
total: number
|
||||
@@ -198,6 +200,8 @@ function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMomen
|
||||
trace: Trace
|
||||
labelOf: (id?: string | null) => string | undefined
|
||||
t0?: number
|
||||
/** 运行结束的时刻(还没结束的为空):晚于它的工件不给跳转 */
|
||||
t1?: number
|
||||
onOpen: (v: { id: string; title: string }) => void
|
||||
onMoment?: (at: number, nodeId: string | null) => void
|
||||
}) {
|
||||
@@ -226,7 +230,7 @@ function Group({ nodeId, rows, total, graph, trace, labelOf, t0, onOpen, onMomen
|
||||
const kind = artifactKindLabel(a.kind)
|
||||
const attempt = Number(a.meta?.attempt)
|
||||
const created = parseServerTime(a.created_at ?? null)?.getTime()
|
||||
const at = t0 != null && created != null && created >= t0 ? created : null
|
||||
const at = t0 != null && created != null && created >= t0 && (t1 == null || created <= t1) ? created : null
|
||||
const numbered = (perKind.get(a.kind) ?? 0) > 1
|
||||
const title = `${label} · ${kind}${numbered ? ` #${n}` : ''}`
|
||||
return (
|
||||
|
||||
@@ -513,6 +513,13 @@ const groupKey = (t: { unit: string | null; quote: string | null }) =>
|
||||
|
||||
/** 问的不是眼前这一稿报告的那几条:单独一组,排在最后 */
|
||||
const OTHER = 'other'
|
||||
/** 别的审批里问的、审批列表又没取到,不知道是不是眼前这一稿:也单独一组,排在最后,给重试 */
|
||||
const UNSURE = 'unsure'
|
||||
/**
|
||||
* 不按句子挂的两组:句子编号对不上(或者不知道对不对得上),回答引用报告已有的出处时不在眼前这一稿里找;正在回答的、
|
||||
* 提问框也不挂进来
|
||||
*/
|
||||
const offDoc = (key: string) => key === OTHER || key === UNSURE
|
||||
|
||||
interface Group {
|
||||
key: string
|
||||
@@ -610,6 +617,10 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
|
||||
if (a === (cardId ?? null)) return true
|
||||
return !!a && !!docArtifact && docsSlot?.map[a]?.[report] === docArtifact
|
||||
}, [cardId, docArtifact, docsSlot, report])
|
||||
// 审批列表没取到时,别的审批里问的、那张审批又不在之前取到的列表里:不知道是不是眼前这一稿,不能算「其他版本」。
|
||||
// 取到了列表却没有那张审批的(审批记录没了)、这份报告没有报告文档(拿什么都对不上)的,重取也一样,照旧算对不上
|
||||
const unsure = useCallback((x: Inquiry) => !!docArtifact && docsSlot?.status === 'error' && !!x.approval_id
|
||||
&& !(x.approval_id in docsSlot.map), [docArtifact, docsSlot])
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const out = new Map<string, Group>()
|
||||
@@ -619,9 +630,10 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
|
||||
return out.get(k)!
|
||||
}
|
||||
const others: InquiryEntry[] = []
|
||||
const unsures: InquiryEntry[] = []
|
||||
for (const e of entries) {
|
||||
if (sameDoc(e.inquiry)) add(e.inquiry.unit, e.inquiry.quote).entries.push(e)
|
||||
else if (settled) others.push(e)
|
||||
else if (settled) (unsure(e.inquiry) ? unsures : others).push(e)
|
||||
}
|
||||
// 正在回答的、没问成的、开着的提问框挂在它们问的那一句下面(按先后):那句还没有问答时另起一组
|
||||
if (mine) add(mine.target.unit, mine.target.quote)
|
||||
@@ -629,8 +641,11 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
|
||||
if (draft) add(draft.target.unit, draft.target.quote)
|
||||
const list = [...out.values()]
|
||||
if (others.length) list.push({ key: OTHER, unit: null, quote: null, entries: others })
|
||||
if (unsures.length) list.push({ key: UNSURE, unit: null, quote: null, entries: unsures })
|
||||
return list
|
||||
}, [entries, sameDoc, settled, mine, draft, failed])
|
||||
}, [entries, sameDoc, unsure, settled, mine, draft, failed])
|
||||
// 重取审批列表:列表按运行取,一份里各张审批都有。取的时候这两组先收起(同第一次取),取回来按结果重新归拢
|
||||
const retryDocs = useCallback(() => { void loadApprovalDocs(runId, foreign) }, [loadApprovalDocs, runId, foreign])
|
||||
|
||||
// 提交之后提问框拿掉了,焦点接到「正在回答」那一条上;回答回来那一条换掉了,再接到回答上。焦点已经去了别处的不抢;
|
||||
// 没问成(提问框带着报错重新打开)时焦点由提问框自己接。都只在问的那一处:同一张卡挂在两处时另一处不动
|
||||
@@ -697,15 +712,15 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
|
||||
<div className="mt-1.5 space-y-2">
|
||||
{groups.map((g) => (
|
||||
<div key={g.key} className="min-w-0"
|
||||
data-inquiry-group={g.key === OTHER ? OTHER : g.unit ?? (g.quote ? 'quote' : 'report')}>
|
||||
<GroupHead group={g} units={units} />
|
||||
data-inquiry-group={offDoc(g.key) ? g.key : g.unit ?? (g.quote ? 'quote' : 'report')}>
|
||||
<GroupHead group={g} units={units} onRetry={retryDocs} />
|
||||
<div className="mt-1 space-y-2 border-l pl-2">
|
||||
{g.entries.map((e) => (
|
||||
<EntryView key={e.id} runId={runId} entry={e} groupQuote={g.unit ? null : g.quote}
|
||||
otherDoc={g.key === OTHER} onLocate={g.key === OTHER ? undefined : onLocate}
|
||||
otherDoc={offDoc(g.key)} onLocate={offDoc(g.key) ? undefined : onLocate}
|
||||
focusRef={e.id === latest ? (el) => { lastRef.current = el } : undefined} />
|
||||
))}
|
||||
{g.key !== OTHER && (
|
||||
{!offDoc(g.key) && (
|
||||
<>
|
||||
{mine && groupKey(mine.target) === g.key && (
|
||||
<PendingView pending={mine} focusRef={(el) => { pendingRef.current = el }} />
|
||||
@@ -740,9 +755,9 @@ export function ReportInquiry({ runId, report, docArtifact, access, cardId = nul
|
||||
|
||||
/**
|
||||
* 一组的抬头:问的是哪一句(原文从报告文档取,取不到写「报告中的一句」)、哪段原文,或者整份报告。问的不是眼前这一稿的
|
||||
* 那一组只写明这一点:句子编号对不上,不去取原文
|
||||
* 那一组只写明这一点:句子编号对不上,不去取原文。审批列表没取到、不知道是哪一稿的那一组照实说,给重试(onRetry)
|
||||
*/
|
||||
function GroupHead({ group, units }: { group: Group; units: Map<string, string> }) {
|
||||
function GroupHead({ group, units, onRetry }: { group: Group; units: Map<string, string>; onRetry: () => void }) {
|
||||
if (group.key === OTHER) {
|
||||
return (
|
||||
<div className="min-w-0 text-2xs leading-relaxed" data-inquiry-about="">
|
||||
@@ -751,6 +766,17 @@ function GroupHead({ group, units }: { group: Group; units: Map<string, string>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (group.key === UNSURE) {
|
||||
return (
|
||||
<div className="flex min-w-0 flex-wrap items-start gap-x-2 gap-y-1 text-2xs leading-relaxed" data-inquiry-about="">
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="font-medium" style={{ color: 'var(--st-waiting)' }} data-inquiry-about-text="">{INQUIRY_TEXT.unsureDoc}</span>
|
||||
<span className="block text-faint">{INQUIRY_TEXT.unsureDocHint}</span>
|
||||
</span>
|
||||
<button type="button" className="btn btn-xs shrink-0" data-inquiry-docs-retry="" onClick={onRetry}>{INQUIRY_TEXT.retry}</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const text = group.unit ? units.get(group.unit) || group.entries.find((e) => e.inquiry.quote)?.inquiry.quote || ''
|
||||
: group.quote ?? ''
|
||||
return (
|
||||
|
||||
+80
-28
@@ -1,6 +1,7 @@
|
||||
// 审批质询的回归检查:报告上的入口(run/EvidenceDoc.tsx 的句末「质询」、划选原文浮出的「质询」)、问答串和提问框
|
||||
// (run/Inquiry.tsx)、审批卡上的挂法(run/ApprovalReport.tsx、run/RunPanel.tsx)、运行详情「证据」页签的挂法
|
||||
// (pages/runs/EvidencePane.tsx),以及运行详情「工件」页签里质询回答的名字(pages/runs/model.ts)。
|
||||
// (pages/runs/EvidencePane.tsx),以及运行详情「工件」页签里质询回答的名字(pages/runs/model.ts)和航迹跳转
|
||||
// (pages/runs/ArtifactsPane.tsx)。
|
||||
//
|
||||
// 守的是这些「看着没坏、其实用不了」的地方:悬停、键盘聚焦一句都不出「质询」(或者出了 Tab 却到不了、整份报告多出一串
|
||||
// Tab 位)、没有可点内容的句子键盘走不到、划选原文不浮出入口(或者带上的原文混进了徽标和「质询」本身)、提交的请求体
|
||||
@@ -9,8 +10,9 @@
|
||||
// 那一格)、引用报告已有出处的数字点了没反应、查询的 SQL / 行数 / 截断 / 遮罩不显示、触顶和没答成不说、recorded 为假
|
||||
// 不醒目、409 / 422 不照服务端的中文说明显示(或者问题文字丢了)、Esc 关不掉提问框(或者连带收起了别的、焦点掉到页面上)、
|
||||
// 已处理的审批和封存了的正式运行还给入口、封存了的探索运行反而没有;同一次运行的几处问答串要对的审批不同、审批列表
|
||||
// 取不到时后一处一直不列别的审批里问的(头上写着次数,下面一条没有);工件页签里质询的回答只写英文的种类名;
|
||||
// 窄屏(390px)被撑出横向滚动、浅色主题下看不清。
|
||||
// 取不到时后一处一直不列别的审批里问的(头上写着次数,下面一条没有),或者把没能确认的说成「报告其他版本」、不给重试;
|
||||
// 工件页签里质询的回答只写英文的种类名、截断截在空格上的问题摘要不补省略号、封存后追加的工件给一个跳到运行结束之后的
|
||||
// 航迹时刻;窄屏(390px)被撑出横向滚动、浅色主题下看不清。
|
||||
//
|
||||
// 跑在预览页上:/preview.html?syn=inquiry-*(用例见 frontend/src/dev/fixtures/inquiry.tsx)。夹具在
|
||||
// frontend/src/dev/fixtures/inquiry.json,报告文档和回答文档是后端 build_catalog + compose_doc 真实组装的(虚构的数据)。
|
||||
@@ -830,7 +832,7 @@ await section('运行详情「证据」页签:封存了的探索运行有入
|
||||
}
|
||||
})
|
||||
|
||||
await section('运行详情「工件」页签:质询的回答有名字和说明,不出现英文的工件种类名', async () => {
|
||||
await section('运行详情「工件」页签:质询的回答有名字和说明,不出现英文的工件种类名;封存后追加的不给航迹跳转', async () => {
|
||||
const { ctx, page, errors } = await open('inquiry-run-artifacts')
|
||||
await page.locator('[data-run-artifacts] [data-artifact-id]').first().waitFor()
|
||||
// 每一行:种类(行首的标签)、说明(同一种类有几件时末尾带「#n」,去掉再比)、悬停
|
||||
@@ -841,11 +843,27 @@ await section('运行详情「工件」页签:质询的回答有名字和说
|
||||
about: (spans[1]?.textContent ?? '').replace(/\s*#\d+$/, '').trim(), title: open?.getAttribute('title') ?? '' }
|
||||
}))
|
||||
const answers = fx.run_artifacts.filter((a) => a.kind === 'inquiry_answer').map((a) => rows.find((r) => r.id === a.id))
|
||||
check('质询的回答:种类写「质询回答」', answers.length === 3 && answers.every((r) => r?.kind === '质询回答'), JSON.stringify(answers))
|
||||
check('质询的回答:种类写「质询回答」', answers.length === 4 && answers.every((r) => r?.kind === '质询回答'), JSON.stringify(answers))
|
||||
check('有问题摘要的:说明写「质询「问题」的回答」', answers[0]?.about === '质询「退款率怎么算的?」的回答', answers[0]?.about)
|
||||
check('问题摘要满 40 字(服务端只记前 40 字):末尾补省略号',
|
||||
answers[1]?.about === '质询「枫岭区的销售额是否包含线上订单?如果包含,线上订单按下单门店还是按收货地址归到片…」的回答', answers[1]?.about)
|
||||
check('没有问题摘要的:也有一句说明', answers[2]?.about === '审批质询的回答:逐段的片段和每个数字的出处', answers[2]?.about)
|
||||
// 第 40 个字是空格:服务端截下来的摘要以空格结尾(截之前整个问题已经去过首尾空白),去掉空白再数只有 39 字
|
||||
check('截断截在空格上的摘要:照样补省略号,不当成完整的问题',
|
||||
answers[3]?.about === '质询「本周枫岭片区 GMV 环比下降了多少?下降的主要原因是不是 SKU 结构的变化…」的回答', answers[3]?.about)
|
||||
// 航迹跳转:运行期间产出的报告文档能跳到航迹里那一刻;封存后追加的质询回答和它查询的快照晚于运行结束,航迹里没有
|
||||
// 那一刻(以前给「T+」几十分钟、几天的跳转,点了把航迹拖到运行早就结束之后),只写时间
|
||||
const moments = Object.fromEntries(await page.locator('[data-artifact-id]').evaluateAll((els) => els.map((el) =>
|
||||
[el.getAttribute('data-artifact-id'), el.querySelector('[data-action="artifact-moment"]')?.textContent?.trim() ?? null])))
|
||||
const doc = fx.run_artifacts.find((a) => a.kind === 'report_doc')
|
||||
const late = fx.run_artifacts.filter((a) => a.kind !== 'report_doc')
|
||||
check('运行期间产出的报告文档:给航迹跳转', /^T\+/.test(moments[doc.id] ?? ''), moments[doc.id])
|
||||
check('封存后追加的质询回答、它查询的快照:不给航迹跳转,只写时间', late.every((a) => moments[a.id] === null)
|
||||
&& (await page.locator(`[data-artifact-id="${late[0].id}"] > span`).last().innerText()).trim() !== '',
|
||||
JSON.stringify(late.map((a) => moments[a.id])))
|
||||
await page.locator(`[data-artifact-id="${doc.id}"] [data-action="artifact-moment"]`).click()
|
||||
const jumped = await page.locator('[data-fixture="inquiry-run-artifacts"]').getAttribute('data-fixture-moment')
|
||||
check('……点报告文档的跳转:到它产出的那一刻', Number(jumped) === Date.parse(`${doc.created_at}Z`), jumped)
|
||||
check('悬停写「打开质询回答」', answers.every((r) => r?.title.startsWith('打开质询回答')), answers.map((r) => r?.title).join(' / '))
|
||||
const pane = await text(page.locator('[data-run-artifacts]'))
|
||||
check('工件页签里不出现英文的工件种类名', !/inquiry_answer|report_doc|query_snapshot/.test(pane) && rows.every((r) => !/[a-z_]{4,}/.test(r.kind)),
|
||||
@@ -1065,12 +1083,18 @@ await section('之前几轮审批里问的:报告改写过的不按句子编
|
||||
check('页面没有报错', errors.length === 0, errors.join(';'))
|
||||
await ctx.close()
|
||||
{
|
||||
// 审批列表取不到:别的审批里问的一律单独一组(宁可不挂,不挂错)
|
||||
const { ctx, page, errors } = await open('inquiry-approval', { setup: (s) => { s.lists[RUNS.approve] = [prev, level, ...fx.items] } })
|
||||
// 审批列表取不到:别的审批里问的一律单独一组(宁可不挂,不挂错)。不知道是哪一稿,不能说成「其他版本」(审批人会以为
|
||||
// 报告换过稿):写明没能确认、给重试。这里用浅色主题量那句的颜色(深色在下一段量)
|
||||
const { ctx, page, errors } = await open('inquiry-approval', { theme: 'light', setup: (s) => { s.lists[RUNS.approve] = [prev, level, ...fx.items] } })
|
||||
await entry(page, 12).waitFor()
|
||||
const g = await groupsOf(page)
|
||||
check('审批列表取不到:别的审批里问的都单独一组', JSON.stringify(g.at(-1)) !== undefined && g.at(-1).unit === 'other'
|
||||
check('审批列表取不到:别的审批里问的都单独一组', JSON.stringify(g.at(-1)) !== undefined && g.at(-1).unit === 'unsure'
|
||||
&& JSON.stringify(g.at(-1).entries) === JSON.stringify(['12', '20']), JSON.stringify(g.map((x) => [x.unit, x.entries])))
|
||||
check('审批列表取不到:那一组写「无法确认提问时的报告版本」,不说「其他版本」,给重试',
|
||||
g.at(-1)?.about.startsWith('无法确认提问时的报告版本') && !g.at(-1)?.about.includes('其他版本')
|
||||
&& await group(page, 'unsure').locator('[data-inquiry-docs-retry]').count() === 1, g.at(-1)?.about)
|
||||
const unsureRatio = await ratioOf(page, '[data-inquiry-group="unsure"] [data-inquiry-about-text]')
|
||||
check('审批列表取不到(浅色):那一句对比度 ≥ 4.5', unsureRatio >= 4.5, unsureRatio.toFixed(2))
|
||||
check('审批列表取不到:页面没有报错', errors.length === 0, errors.join(';'))
|
||||
await ctx.close()
|
||||
}
|
||||
@@ -1099,7 +1123,7 @@ const tally = async (page, scope) => ({
|
||||
shown: await page.locator(`${scope} [data-inquiry-entry]`).count(),
|
||||
})
|
||||
|
||||
await section('两处要对的审批不同、审批列表取不到:两处的问答都列出来,次数和条数一致', async () => {
|
||||
await section('两处要对的审批不同、审批列表取不到:两处的问答都列出来,次数和条数一致,写明没能确认、重试取到后各归其位', async () => {
|
||||
// 一张卡审两份报告:写月报上有 ap-x 里问的,写周报上有 ap-y 里问的,两份报告的问答串共用这次运行的审批列表。先发的那一处
|
||||
// 请求还在路上时,后一处要对的审批也得记上:不然请求回来(这里是 404)之后后一处一直等着,头上写「· 1 次」,下面一条没有
|
||||
const x = { ...clone(fx.items[0]), seq: 41, approval_id: 'ap-x', question: '写月报上一轮问的:退款率怎么算?', at: '2026-10-05T05:30:00Z' }
|
||||
@@ -1120,10 +1144,10 @@ await section('两处要对的审批不同、审批列表取不到:两处的
|
||||
const both = await until(async () => (await tally(page, '[data-inquiry="write"]')).shown === 1
|
||||
&& (await tally(page, '[data-inquiry="write2"]')).shown === 1)
|
||||
const [gw, gw2] = [await groupsOf(page, '[data-inquiry="write"]'), await groupsOf(page, '[data-inquiry="write2"]')]
|
||||
check('写月报:查不到那张审批,问答单独一组', JSON.stringify(gw.map((g) => [g.unit, g.entries])) === JSON.stringify([['other', ['41']]]),
|
||||
check('写月报:审批列表没取到,那张审批里问的单独一组(没能确认)', JSON.stringify(gw.map((g) => [g.unit, g.entries])) === JSON.stringify([['unsure', ['41']]]),
|
||||
JSON.stringify(gw.map((g) => [g.unit, g.entries])))
|
||||
check('写周报:请求是另一处先发的,回来之后照样列出、单独一组', both
|
||||
&& JSON.stringify(gw2.map((g) => [g.unit, g.entries])) === JSON.stringify([['other', ['42']]]), JSON.stringify(gw2.map((g) => [g.unit, g.entries])))
|
||||
&& JSON.stringify(gw2.map((g) => [g.unit, g.entries])) === JSON.stringify([['unsure', ['42']]]), JSON.stringify(gw2.map((g) => [g.unit, g.entries])))
|
||||
const [tw, tw2] = [await tally(page, '[data-inquiry="write"]'), await tally(page, '[data-inquiry="write2"]')]
|
||||
check('两份报告头上的次数都和列出的条数一致', tw.head === '1' && tw.shown === 1 && tw2.head === '1' && tw2.shown === 1,
|
||||
JSON.stringify({ tw, tw2 }))
|
||||
@@ -1134,7 +1158,7 @@ await section('两处要对的审批不同、审批列表取不到:两处的
|
||||
// 运行详情直接打开「证据」页签、运行停在审批上:时间线里的待审批卡只为更早那一轮(ap-inq-0)取审批列表,证据页签不认
|
||||
// 任何审批,ap-inq-0 和这张卡的 ap-inq-1 都要对。卡那一处先发了请求,证据页签那一处的条目在请求回来之后也得列出来
|
||||
const early = { ...clone(fx.items[0]), seq: 12, approval_id: 'ap-inq-0', question: '上一轮:退款率 3.5% 是怎么算的?', at: '2026-10-05T05:40:00Z' }
|
||||
const { ctx, page, hits, errors } = await open('inquiry-run-waiting', { waitUntil: 'load', setup: (s) => {
|
||||
const { ctx, page, hits, state, errors } = await open('inquiry-run-waiting', { waitUntil: 'load', setup: (s) => {
|
||||
s.lists[RUNS.approve] = [early, clone(fx.items[1])]
|
||||
s.approvalsGate = new Promise((r) => { release = r })
|
||||
} })
|
||||
@@ -1147,14 +1171,37 @@ await section('两处要对的审批不同、审批列表取不到:两处的
|
||||
release()
|
||||
const listed = await until(async () => (await tally(page, card)).shown === 2 && (await tally(page, pane)).shown === 2)
|
||||
const [gc, gp] = [await groupsOf(page, card), await groupsOf(page, pane)]
|
||||
check('待审批卡:这张审批里问的挂句子下面,查不到的那一轮单独一组',
|
||||
JSON.stringify(gc.map((g) => [g.unit, g.entries])) === JSON.stringify([['u3', ['34']], ['other', ['12']]]),
|
||||
check('待审批卡:这张审批里问的挂句子下面,没能确认的那一轮单独一组',
|
||||
JSON.stringify(gc.map((g) => [g.unit, g.entries])) === JSON.stringify([['u3', ['34']], ['unsure', ['12']]]),
|
||||
JSON.stringify(gc.map((g) => [g.unit, g.entries])))
|
||||
check('证据页签:两条都列出来,查不到审批的单独一组(不再一直等着)', listed
|
||||
&& JSON.stringify(gp.map((g) => [g.unit, g.entries])) === JSON.stringify([['other', ['12', '34']]]), JSON.stringify(gp.map((g) => [g.unit, g.entries])))
|
||||
check('证据页签:两条都列出来,没能确认的单独一组(不再一直等着)', listed
|
||||
&& JSON.stringify(gp.map((g) => [g.unit, g.entries])) === JSON.stringify([['unsure', ['12', '34']]]), JSON.stringify(gp.map((g) => [g.unit, g.entries])))
|
||||
const [tc, tp] = [await tally(page, card), await tally(page, pane)]
|
||||
check('两处头上的次数都和列出的条数一致', tc.head === '2' && tc.shown === 2 && tp.head === '2' && tp.shown === 2, JSON.stringify({ tc, tp }))
|
||||
check('运行详情:按运行只取一次审批列表', hits.approvals.length === 1, JSON.stringify(hits.approvals))
|
||||
// 没读到审批记录不能说成「其他版本」:卡上同一条挂在句子下面,下面证据页签却说是别的版本,审批人会以为报告换过稿
|
||||
const heads = (await page.locator('[data-inquiry-group="unsure"] [data-inquiry-about-text]').allInnerTexts()).map((t) => t.trim())
|
||||
check('没能确认的那一组(两处):写「无法确认提问时的报告版本」,不说「其他版本」',
|
||||
heads.length === 2 && heads.every((t) => t === '无法确认提问时的报告版本'), heads.join(' | '))
|
||||
check('……两处都给「重试」', await page.locator(`${card} [data-inquiry-group="unsure"] [data-inquiry-docs-retry]`).count() === 1
|
||||
&& await page.locator(`${pane} [data-inquiry-group="unsure"] [data-inquiry-docs-retry]`).count() === 1)
|
||||
const unsureRatio = await ratioOf(page, `${pane} [data-inquiry-group="unsure"] [data-inquiry-about-text]`)
|
||||
check('……那一句(深色)对比度 ≥ 4.5', unsureRatio >= 4.5, unsureRatio.toFixed(2))
|
||||
// 重试,这回取得到:这张审批审的就是眼前这一稿,更早那一轮审的是另一稿
|
||||
state.approvals[RUNS.approve] = [approvalRow(fx.approval_id, RUNS.approve, fx.reports.approve.doc_artifact),
|
||||
approvalRow('ap-inq-0', RUNS.approve, '0'.repeat(64))]
|
||||
await page.locator(`${pane} [data-inquiry-docs-retry]`).click()
|
||||
const want = JSON.stringify([['u3', ['34']], ['other', ['12']]])
|
||||
const placed = await until(async () => JSON.stringify((await groupsOf(page, pane)).map((g) => [g.unit, g.entries])) === want
|
||||
&& JSON.stringify((await groupsOf(page, card)).map((g) => [g.unit, g.entries])) === want)
|
||||
const [gc2, gp2] = [await groupsOf(page, card), await groupsOf(page, pane)]
|
||||
check('重试取到之后(证据页签):这张审批里问的回到句子下面,更早那一轮算报告其他版本', placed
|
||||
&& JSON.stringify(gp2.map((g) => [g.unit, g.entries])) === want, JSON.stringify(gp2.map((g) => [g.unit, g.entries])))
|
||||
check('重试取到之后(待审批卡):更早那一轮也改写成报告其他版本', JSON.stringify(gc2.map((g) => [g.unit, g.entries])) === want
|
||||
&& gc2.at(-1)?.about.startsWith('报告其他版本上的质询'), JSON.stringify(gc2.map((g) => [g.unit, g.about.slice(0, 12)])))
|
||||
check('……重试只再取一次审批列表,两处共用', hits.approvals.length === 2, JSON.stringify(hits.approvals))
|
||||
const [tc2, tp2] = [await tally(page, card), await tally(page, pane)]
|
||||
check('……两处的次数仍和条数一致', tc2.head === '2' && tc2.shown === 2 && tp2.head === '2' && tp2.shown === 2, JSON.stringify({ tc2, tp2 }))
|
||||
check('运行详情:页面没有报错', errors.length === 0, errors.join(';'))
|
||||
await ctx.close()
|
||||
}
|
||||
@@ -1379,18 +1426,23 @@ function contrast(fg, bg, base) {
|
||||
return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05)
|
||||
}
|
||||
|
||||
/** 某个元素的字色对它所在那一块底色的对比度:底色往上找第一个不透明的,最底下是 body */
|
||||
const ratioOf = (page, sel) => page.evaluate((s) => {
|
||||
const el = document.querySelector(s)
|
||||
if (!el) return null
|
||||
let bgEl = el
|
||||
let bg = 'rgba(0, 0, 0, 0)'
|
||||
while (bgEl && /rgba\(0, 0, 0, 0\)|transparent/.test(bg)) {
|
||||
bg = getComputedStyle(bgEl).backgroundColor
|
||||
bgEl = bgEl.parentElement
|
||||
}
|
||||
return { fg: getComputedStyle(el).color, bg, base: getComputedStyle(document.body).backgroundColor }
|
||||
}, sel).then((c) => (c ? contrast(c.fg, c.bg, c.base) : 0))
|
||||
/**
|
||||
* 某个元素的字色对它所在那一块底色的对比度:底色往上找第一个不透明的,最底下是 body。写成函数声明:前面几段(审批列表
|
||||
* 取不到的那一组)也要用
|
||||
*/
|
||||
function ratioOf(page, sel) {
|
||||
return page.evaluate((s) => {
|
||||
const el = document.querySelector(s)
|
||||
if (!el) return null
|
||||
let bgEl = el
|
||||
let bg = 'rgba(0, 0, 0, 0)'
|
||||
while (bgEl && /rgba\(0, 0, 0, 0\)|transparent/.test(bg)) {
|
||||
bg = getComputedStyle(bgEl).backgroundColor
|
||||
bgEl = bgEl.parentElement
|
||||
}
|
||||
return { fg: getComputedStyle(el).color, bg, base: getComputedStyle(document.body).backgroundColor }
|
||||
}, sel).then((c) => (c ? contrast(c.fg, c.bg, c.base) : 0))
|
||||
}
|
||||
|
||||
await section('窄屏与深浅色', async () => {
|
||||
for (const theme of ['dark', 'light']) {
|
||||
|
||||
Reference in New Issue
Block a user