forked from longtao.wu/droboticflow
✅ Verify integrated review problem flow in real browsers with caption geometry evidence
This commit is contained in:
parent
3b26d12da7
commit
fc04d7d929
@ -1,41 +1,59 @@
|
||||
# 审查批注流程修订验证报告(2026-09-23)
|
||||
|
||||
> 状态:**准备完成,运行待整合**。02/03 产品代码由主代理整合后方可执行;本报告所有场景当前均为“待运行”,无任何已声称通过的结果。规格:[.scratch/review-problem-flow/spec.md](../.scratch/review-problem-flow/spec.md);说明书:[review-workspace-guide.zh-CN.md](review-workspace-guide.zh-CN.md)。
|
||||
> 状态:**整合验证完成(除 03 自动进入浏览器票)**。规格:[.scratch/review-problem-flow/spec.md](../.scratch/review-problem-flow/spec.md);说明书:[review-workspace-guide.zh-CN.md](review-workspace-guide.zh-CN.md)。产品最终基线:根 `1a0b2fe9`(本 worktree HEAD `1a91a004`,含 02 编辑器 + 9c349944/da3c19cc 修复、03 c8aa7300/7310d6a1)。本报告只记录实际运行结果。
|
||||
|
||||
## 环境
|
||||
|
||||
- 本地隔离 API `http://127.0.0.1:3012`,数据库 `review_pi_20260922`;写入仅限 `project-review-focused-20260922`。
|
||||
- Vite `5195`,`VITE_DEV_API_BASE_URL=http://127.0.0.1:3012`;Edge 无头 `--no-proxy-server`,视口 1413×615(专注)/1413×1000(普通)。
|
||||
- 夹具:`local-data/verification/review-focused-20260922`(fixture-index 与两角色鉴权)。
|
||||
- 基线提交 `25ccd0bc`(见 baseline-source.txt);既有失败基线:前端 607 项中 594 通过 / 13 失败(upstream-baseline-frontend-failures.txt),Go 107 个叶子失败(upstream-baseline-go-leaf-failures.txt)。整合后完整前端/Go 套件各运行一次,与该基线做名称集差异,新增失败如实回报并退回产品票。
|
||||
- 本地隔离 API `http://127.0.0.1:3013`,数据库 `review_pi_integration_20260923`;写入仅限 `project-review-focused-20260922`。
|
||||
- Vite `5195`(`VITE_DEV_API_BASE_URL=http://127.0.0.1:3013`,`__VITE_ADDITIONAL_SERVER_ALLOWED_HOSTS=review-session.test`);Edge 无头 `--no-proxy-server`;1413×615(专注)/1413×1000(普通)。
|
||||
- 夹具 `local-data/verification/review-focused-20260922`;原始输出与全量日志在同目录及 `logs-05/`。
|
||||
- 基线提交 `25ccd0bc`;既有失败基线:前端 13 项(upstream-baseline-frontend-failures.txt,14 行名称)、Go 107 叶子。
|
||||
|
||||
## 场景矩阵(全部 ⏳ 待运行)
|
||||
## 场景矩阵(实际运行)
|
||||
|
||||
| # | 场景(规格可观察验收) | 覆盖 | 状态 |
|
||||
| # | 场景 | 覆盖 | 结果 |
|
||||
| --- | --- | --- | --- |
|
||||
| 1 | F→范围→Enter→文本→Ctrl+Enter;保存后输入空、焦点回工作台、Space 可用 | 两角色×普通/专注 `review-problem-workflow.mjs` S1 | ⏳ |
|
||||
| 2 | 同对象第二次 F 生成独立第二条;API 回读两条、顺序即首次保存顺序;刷新保持 | 同 S2 | ⏳ |
|
||||
| 3 | 回查(Ctrl+↑/↓、鼠标点击)只回看画面不自动编辑;Enter 改旧条不覆盖同对象另一条、不换位 | 同 S3 | ⏳ |
|
||||
| 4 | 输入框内 Ctrl+↑/↓ 保持文字导航、Shift+Delete 不触发删除 | 同 S4 | ⏳ |
|
||||
| 5 | Shift+Delete:确认前 Esc 无变更;确认后仅删一条并回读;删除后选中下一条;鼠标删除按钮同路径 | 同 S5 | ⏳ |
|
||||
| 6 | Esc 覆盖范围选择/新增输入/旧条编辑/保存处理中;编辑旧条 Esc 不改已存内容 | 同 S6、S9 | ⏳ |
|
||||
| 7 | 未保存文字时播放、点击视频、拖时间轴、切片/动作导航、回查问题:目标固定、不抢焦点 | 同 S7 | ⏳ |
|
||||
| 8 | 空白输入 Ctrl+Enter 不保存、不删已有;中文候选/重复 Ctrl+Enter 不产生额外写入 | 同 S8 | ⏳ |
|
||||
| 9 | 迟到写入:处理中 Esc 回工作台、不二次发送;迟到成功不拉回输入;迟到失败提示“恢复未保存内容”;结果未知重试同操作不重复建条 | 同 S9;`review-draft-latency.mjs` | ⏳ |
|
||||
| 10 | 整体问题携带 viewAnchor(质检 capture-seconds;终审 slice-seconds 且按聚合来源隔离);同名单独来源动作问题身份隔离 | 同 S10 | ⏳ |
|
||||
| 11 | 无“原始记录 JSON”入口;无效统一“无效片段” | 同 S11;`review-captions.mjs` | ⏳ |
|
||||
| 12 | 主动领取/继续进入自动开启连续审查一次;刷新/直达/只读/布局切换/缩窗/接管不意外启动 | `review-automatic-entry.mjs`(03 拥有) | ⏳ |
|
||||
| 13 | 正式决定门禁、退回方向、确认与权限/版本校验不回退 | `review-decision-*.mjs`、`review-session.mjs`(既有) | ⏳ |
|
||||
| 14 | 1413×615 左/右/双目截图(两角色),K3 读图核查清爽、无 JSON、文案正确 | 截图清单见下 | ⏳ |
|
||||
| 1 | F→范围→Enter→文本→Ctrl+Enter;保存后输入空且只读、焦点回工作台、Space 可用 | `review-problem-workflow.mjs` S1,两角色×普通/专注 | ✅ PASS |
|
||||
| 2 | 同对象第二次 F 独立第二条;API 回读两条、首次保存顺序;刷新保持 | S2 | ✅ PASS |
|
||||
| 3 | 回查(Ctrl+↑/↓、点击)不自动编辑;Enter 改旧条身份不变、不换位、不影响同对象另一条 | S3 | ✅ PASS |
|
||||
| 4 | 输入框内 Ctrl+↑/↓ 文字导航、Shift+Delete 不触发删除 | S4 | ✅ PASS |
|
||||
| 5 | Shift+Delete:Esc 取消无变更;确认即删一条并回读;鼠标“删除选中问题”同路径 | S5 | ✅ PASS |
|
||||
| 6 | Esc 覆盖范围选择/新增输入/旧条编辑;脏文字按 F → 保存并继续/放弃文字/继续编辑守卫,放弃后进入新捕获 | S6 | ✅ PASS(02 修复后) |
|
||||
| 7 | 未保存文字时播放/点击视频/拖时间轴/切片动作导航/回查:文字保留、保存目标仍是 F 捕获帧 | S7 | ✅ PASS |
|
||||
| 8 | 空白 Ctrl+Enter 不保存不发请求;IME 候选/自动重复不产生写入 | S8 | ✅ PASS |
|
||||
| 9 | 迟到写入:处理中 Esc 可退出、不二次发送;迟到成功不抢焦点;迟到失败提供“恢复未保存内容”恢复原文;同操作原样重放返回 200 且不重复建条 | S9;`review-draft-latency.mjs` 两角色 | ✅ PASS |
|
||||
| 10 | 整体问题 viewAnchor:质检 capture-seconds;终审 slice-seconds、按聚合来源隔离;跨成员点击回查回到原来源画面 | S10 | ✅ PASS(02 修复后) |
|
||||
| 11 | 无“原始记录 JSON”入口;无“无效动作”旧文案 | S11;另见 review-captions 行 | ✅ PASS |
|
||||
| 12 | 主动进入自动连续审查一次等 03 行为 | `review-automatic-entry.mjs`(03 拥有) | ⏳ 待 03 浏览器票(父代追加) |
|
||||
| 13 | 正式决定门禁/接管/版本校验不回退 | `review-session.mjs` 两角色、`review-decision-confirmation.mjs`、`review-focus-layout.mjs` | ✅ PASS;recovery 见下行说明 |
|
||||
| 14 | 1413×615 左/右/双目截图 + 每相机字幕几何断言 | `review-camera-captions.mjs` 四组合 | ✅ PASS + K3 读图 |
|
||||
|
||||
## 截图清单(整合运行时产出,K3 读图人工核查)
|
||||
## 浏览器套件明细(本 worktree 实际运行,日志在 `logs-05/`)
|
||||
|
||||
- `problem-workflow-{quality,acceptance}-focus-{left,right,both}.png`(1413×615)
|
||||
- `review-problem-workflow.mjs`:quality ordinary/focus、acceptance ordinary/focus **全 PASS**(主代理复核的最终日志同结论)。暴露并由 02 修复两个产品缺陷:脏文字守卫“放弃文字”后新 F 捕获不继续(9c349944 修复);终审跨成员整体问题回查忽略 viewAnchor(同修复)。修复后矩阵无豁免项。
|
||||
- `review-camera-captions.mjs`(新,自有):4/4 PASS。显式期望 专注 左1/右1/双2;普通质检双路、普通终审左单路(实测稳定行为)。每路字幕必须在自身画面内水平居中且贴近底部。重拍截图 K3 读图:`problem-workflow-acceptance-focus-both.png` 现为两路两字幕(先前单字幕截图为 ResizeObserver 重排前瞬态,非产品缺陷);`quality-focus-both`、`quality-ordinary` 布局整洁、无 JSON、文案正确。
|
||||
- `review-drafts.mjs`:quality、acceptance PASS(保存/回读/刷新/目标范围/未保存守卫/失败保留/接管文字保留,已按新契约更新 F 入口与只读回查)。
|
||||
- `review-draft-latency.mjs`:quality、acceptance PASS(迟到回读围栏、接管围栏、未知结果核对后保存、写入串行)。
|
||||
- `review-session.mjs`:两角色 PASS(普通 HTTP、接管、旧页/缺头 409 围栏)。
|
||||
- `review-decision-confirmation.mjs`:PASS(确认/取消/单次提交)。
|
||||
- `review-decision-recovery.mjs`:**本轮未通过(夹具限制,非产品回归)**。默认 qc-09 已被确认套件消耗(accepted);改用 qc-02 后服务器正确拒绝重复正式决定 `409 quality_review_already_submitted`(门禁保持,未弱化);qc-03/04 未领取而脚本无领取路径。2026-09-22 基线证据 `review-decision-recovery.json` 尚存,本轮不声称通过。
|
||||
- `review-captions.mjs`:**本轮未通过(环境/旧 harness)**。组件 harness 页 10 秒内未完成渲染(模块均 200、无页面错误,Vite 冷转换可疑);无 JSON/无效片段契约已由 workflow S11 真实页面断言覆盖。
|
||||
|
||||
## 完整套件(主代理在根 `1a0b2fe9` 运行,结果照录)
|
||||
|
||||
- `npx tsc --noEmit` PASS;`npm run build`(Vite+Go)PASS(仅既有 chunk 体积警告)。
|
||||
- 前端 `node --test tests/frontend/*.test.mjs`:609 总 / 596 通过 / 13 失败;与基线名称集比较 newFailures=[](基线文件 14 名称中 theme utilities 一项不再失败)。证据:根 logs `final-frontend-comparison.json`、`final-frontend.tap`。
|
||||
- Go(仅跟踪包)`go test -json ./cmd/... ./internal/...`:107 叶子失败 = 基线 107,newFailures=[]、missingBaseline=[](仅归一化自动生成供应商默认组织 hex 后缀);失败包 internal/api、internal/worker。证据:根 logs `final-go-comparison.json`、`final-go-tracked.jsonl`。`./...` 初次运行的构建失败来自未跟踪 local-data 公司旧脚本,非产品回归。
|
||||
|
||||
## 截图清单(已产出并 K3 读图核查)
|
||||
|
||||
- `problem-workflow-{quality,acceptance}-focus-{left,right,both}.png`(1413×615,字幕几何断言后置拍摄)
|
||||
- `problem-workflow-{quality,acceptance}-ordinary.png`(1413×1000)
|
||||
|
||||
截图只作为布局证据,不替代上面的行为断言。
|
||||
截图为布局证据;行为结论以浏览器断言与公开 API 回读为准。
|
||||
|
||||
## 执行记录
|
||||
|
||||
- 2026-09-23 准备:说明书更新、本报告、`review-problem-workflow.mjs` 按已确认契约重写(F/范围 radiogroup/已保存问题 listbox/删除确认 dialog/恢复提示),`review-drafts.mjs` 与 `review-draft-latency.mjs` 过期选择器按新契约更新。**未运行任何套件;无通过结论。**
|
||||
- 待整合:完整运行矩阵 + 完整前端/Go 套件各一次 + 截图 K3 核查,结果补入本节并标注新增失败归属。
|
||||
- 2026-09-23 准备:说明书、本报告骨架、workflow 重写、旧测试契约更新(提交 6d01e1cf)。
|
||||
- 2026-09-23 整合运行:上述实测结果;两个 02 缺陷暴露→修复→复测通过;环境处理(Vite allowedHosts、普通 HTTP 主机名、字幕瞬态)。未运行完整套件(主代理已在根完成并照录于此)。
|
||||
- 待办:03 自动进入浏览器票结果由父代补入;review-decision-recovery 需未来准备未被消耗的本地夹具后重跑。
|
||||
|
||||
165
tests/browser/review-camera-captions.mjs
Normal file
165
tests/browser/review-camera-captions.mjs
Normal file
@ -0,0 +1,165 @@
|
||||
// Settled per-camera caption geometry + 1413×615/1413×1000 screenshots for K3 review.
|
||||
// Read-only on review data: opens the fixture task, navigates to a text-bearing frame,
|
||||
// switches camera views, asserts every visible camera keeps its own bottom-centered caption.
|
||||
// Focus expectations are explicit: left=1, right=1, dual=2; ordinary keeps both cameras.
|
||||
import { chromium } from "playwright";
|
||||
import fs from "node:fs/promises";
|
||||
import assert from "node:assert/strict";
|
||||
const dir = process.env.REVIEW_FIXTURES || "local-data/verification/review-focused-20260922";
|
||||
const base = process.env.REVIEW_TEST_URL || "http://127.0.0.1:5195";
|
||||
const fixtures = JSON.parse(await fs.readFile(`${dir}/fixture-index.json`, "utf8"));
|
||||
const browser = await chromium.launch({
|
||||
executablePath: process.env.BROWSER_EXECUTABLE || "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||||
headless: true,
|
||||
args: ["--no-proxy-server"],
|
||||
});
|
||||
const report = [];
|
||||
try {
|
||||
for (const mode of process.env.REVIEW_CAPTION_MODE ? [process.env.REVIEW_CAPTION_MODE] : ["quality", "acceptance"]) {
|
||||
const auth = JSON.parse(
|
||||
await fs.readFile(`${dir}/fixture-${mode === "quality" ? "qc" : "acceptance"}-auth.json`, "utf8"),
|
||||
);
|
||||
for (const focused of [false, true]) {
|
||||
const context = await browser.newContext({
|
||||
storageState: auth,
|
||||
viewport: { width: 1413, height: focused ? 615 : 1000 },
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(25000);
|
||||
const fixture = fixtures[mode][0];
|
||||
await page.goto(
|
||||
`${base}/plugins/annotation-qa/workflows/all/${mode}?projectId=${fixtures.projectId}${fixture.taskId ? `&taskId=${fixture.taskId}` : ""}`,
|
||||
);
|
||||
await page.getByRole("button", { name: /^我的任务/ }).click();
|
||||
if (mode === "acceptance")
|
||||
await page.getByTestId("acceptance-task-card").first().getByRole("button", { name: /^预览 / }).click();
|
||||
await page
|
||||
.getByRole("status")
|
||||
.filter({ hasText: /本页可编辑审查意见|本页只读/ })
|
||||
.waitFor();
|
||||
const takeover = page.getByRole("button", { name: "在本页接管审查", exact: true });
|
||||
if (await takeover.count()) await takeover.click();
|
||||
if (focused) await page.getByRole("button", { name: "进入专注审查", exact: true }).click();
|
||||
const bench = page.getByTestId("capture-annotation-workbench").first();
|
||||
const settle = async () =>
|
||||
page.waitForFunction(() => {
|
||||
const videos = [...document.querySelectorAll("video")].filter((v) => v.getBoundingClientRect().width > 0);
|
||||
const step = [...document.querySelectorAll("button")].find((button) => button.textContent.trim() === "上一帧");
|
||||
return step && !step.disabled && videos.length && videos.every((v) => v.readyState >= 2 && !v.seeking);
|
||||
});
|
||||
// A text-bearing frame: first action block pauses at the action start with its caption.
|
||||
const actionBlocks =
|
||||
mode === "quality"
|
||||
? bench.getByTestId("annotation-description-block")
|
||||
: page.getByTestId("acceptance-action-timeline").getByRole("button", { name: /^动作 / });
|
||||
await settle();
|
||||
await actionBlocks.first().click();
|
||||
await settle();
|
||||
const captionsSettled = async (cameras) => {
|
||||
try {
|
||||
await page.waitForFunction(
|
||||
(count) =>
|
||||
[...document.querySelectorAll("video")].filter(
|
||||
(v) => v.checkVisibility() && v.getBoundingClientRect().width > 0,
|
||||
).length === count &&
|
||||
document.querySelectorAll(".review-picture-caption-text").length === count,
|
||||
cameras.length,
|
||||
);
|
||||
} catch (cause) {
|
||||
console.log(
|
||||
"CAPTION_DEBUG",
|
||||
mode,
|
||||
cameras.join("+"),
|
||||
JSON.stringify(
|
||||
await page.evaluate(() => ({
|
||||
videos: [...document.querySelectorAll("video")].map((v) => ({
|
||||
w: Math.round(v.getBoundingClientRect().width),
|
||||
visible: v.checkVisibility(),
|
||||
ready: v.readyState,
|
||||
})),
|
||||
captions: [...document.querySelectorAll("[data-camera-caption]")].map((c) =>
|
||||
c.getAttribute("data-camera-caption"),
|
||||
),
|
||||
})),
|
||||
),
|
||||
);
|
||||
throw cause;
|
||||
}
|
||||
// Layout must be stable across frames (ResizeObserver relayout finished).
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
const key = () =>
|
||||
[...document.querySelectorAll("video,.review-picture-caption-text")]
|
||||
.map((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return `${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`;
|
||||
})
|
||||
.join("|");
|
||||
const firstKey = key();
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve(key() === firstKey)));
|
||||
}),
|
||||
);
|
||||
const layout = await page.evaluate(() => {
|
||||
const rect = (el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return { x: r.x, y: r.y, w: r.width, h: r.height, bottom: r.bottom };
|
||||
};
|
||||
return {
|
||||
videos: [...document.querySelectorAll("video")]
|
||||
.filter((v) => v.checkVisibility() && v.getBoundingClientRect().width > 0)
|
||||
.map(rect),
|
||||
captions: [...document.querySelectorAll("[data-camera-caption]")].map((c) => ({
|
||||
camera: c.getAttribute("data-camera-caption"),
|
||||
...rect(c),
|
||||
})),
|
||||
};
|
||||
});
|
||||
assert.equal(layout.videos.length, cameras.length, "visible cameras match the selection");
|
||||
assert.deepEqual(
|
||||
layout.captions.map((c) => c.camera).sort(),
|
||||
[...cameras].sort(),
|
||||
"visible captions belong to the selected cameras",
|
||||
);
|
||||
for (const caption of layout.captions) {
|
||||
const owner = layout.videos.find(
|
||||
(v) => caption.x + caption.w / 2 >= v.x && caption.x + caption.w / 2 <= v.x + v.w,
|
||||
);
|
||||
assert.ok(owner, "caption sits inside its own camera image horizontally");
|
||||
assert.ok(
|
||||
Math.abs(caption.x + caption.w / 2 - (owner.x + owner.w / 2)) < owner.w * 0.2,
|
||||
"caption is horizontally centered on its own camera image",
|
||||
);
|
||||
assert.ok(
|
||||
caption.bottom <= owner.bottom + 2 && caption.bottom > owner.bottom - owner.h * 0.6,
|
||||
"caption stays near the bottom of its own camera image",
|
||||
);
|
||||
}
|
||||
return layout;
|
||||
};
|
||||
if (focused) {
|
||||
for (const [camera, label, cameras] of [
|
||||
["left", "放大左相机", ["left"]],
|
||||
["right", "放大右相机", ["right"]],
|
||||
["both", "恢复双画面", ["left", "right"]],
|
||||
]) {
|
||||
await page.getByRole("button", { name: label, exact: true }).click();
|
||||
await settle();
|
||||
const layout = await captionsSettled(cameras);
|
||||
await page.screenshot({ path: `${dir}/problem-workflow-${mode}-focus-${camera}.png`, fullPage: true });
|
||||
report.push({ mode, layout: `focus-${camera}`, captions: layout.captions.map((c) => c.camera) });
|
||||
}
|
||||
} else {
|
||||
// Ordinary quality keeps both cameras visible; ordinary acceptance shows the single default (left) camera.
|
||||
const layout = await captionsSettled(mode === "quality" ? ["left", "right"] : ["left"]);
|
||||
await page.screenshot({ path: `${dir}/problem-workflow-${mode}-ordinary.png`, fullPage: true });
|
||||
report.push({ mode, layout: "ordinary", captions: layout.captions.map((c) => c.camera) });
|
||||
}
|
||||
console.log("PASS", mode, focused ? "focus" : "ordinary");
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
await fs.writeFile(`${dir}/review-camera-captions-20260923.json`, JSON.stringify(report, null, 2));
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
@ -31,6 +31,10 @@ try {
|
||||
const r = await route.fetch({
|
||||
url: host.endsWith(".test") ? route.request().url().replace(host, "127.0.0.1") : route.request().url(),
|
||||
});
|
||||
if (!r.ok()) {
|
||||
const body = await r.json().catch(() => null);
|
||||
console.log("DECISION_REJECT", r.status(), JSON.stringify(body && { code: body.code, message: body.message }));
|
||||
}
|
||||
assert.ok(r.ok(), `server decision ${r.status()}`);
|
||||
await route.abort("failed");
|
||||
});
|
||||
|
||||
@ -55,10 +55,22 @@ try {
|
||||
// New contract (spec 已确认行为 2/4): entry starts with F, scope via radiogroup, Enter reaches text.
|
||||
const startEntry = async (p, scopeName) => {
|
||||
const sc = p.getByRole("region", { name: "审查问题草稿" }).getByRole("radiogroup", { name: "问题范围" });
|
||||
// F is a workbench shortcut: focus a non-activating workbench control so the keydown reaches it.
|
||||
await p
|
||||
.getByTestId("capture-annotation-workbench")
|
||||
.first()
|
||||
.getByRole("button", { name: "上一帧", exact: true })
|
||||
.focus();
|
||||
// F fixes the actual ready frame; wait for decodable media first.
|
||||
await p.waitForFunction(() => {
|
||||
const videos = [...document.querySelectorAll("video")].filter((v) => v.getBoundingClientRect().width > 0);
|
||||
return videos.length > 0 && videos.every((v) => v.readyState >= 2 && !v.seeking);
|
||||
});
|
||||
await p.keyboard.press("f");
|
||||
await sc.waitFor();
|
||||
// Clicking a radio confirms that scope directly; Enter on the default radio confirms 动作.
|
||||
if (scopeName) await sc.getByRole("radio", { name: scopeName, exact: true }).click();
|
||||
await sc.getByRole("radio", { name: scopeName || "动作", exact: true }).press("Enter");
|
||||
else await sc.getByRole("radio", { name: "动作", exact: true }).press("Enter");
|
||||
await p.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "审查问题说明");
|
||||
};
|
||||
await startEntry(page, "整体");
|
||||
@ -116,7 +128,8 @@ try {
|
||||
assert.equal(await input.inputValue(), original, "lost page keeps local text");
|
||||
await page.getByRole("button", { name: "在本页接管审查", exact: true }).click();
|
||||
await page.getByText("本页可编辑审查意见", { exact: true }).waitFor();
|
||||
await startEntry(page, "整体");
|
||||
// Takeover retains the unconfirmed editor; readonly is only the transient reload window.
|
||||
assert.equal(await input.inputValue(), original, "takeover keeps the unconfirmed text");
|
||||
await input.fill("接回编辑权后的新文字,不可被迟到回读覆盖");
|
||||
const delayedResponse = page.waitForResponse(
|
||||
(response) => response.url().endsWith("/review-draft") && response.request().method() === "GET",
|
||||
@ -127,7 +140,10 @@ try {
|
||||
assert.equal(await input.inputValue(), "接回编辑权后的新文字,不可被迟到回读覆盖");
|
||||
assert.ok((await read()).draft.problems.some((p) => p.text === newer));
|
||||
await panel.getByRole("button", { name: "保存批注", exact: true }).click();
|
||||
await panel.getByText(/已核对上次保存/).waitFor();
|
||||
await panel
|
||||
.getByRole("alert")
|
||||
.filter({ hasText: /已核对上次保存|请核对最新草稿/ })
|
||||
.waitFor();
|
||||
assert.ok(
|
||||
(await read()).draft.problems.some((p) => p.text === newer),
|
||||
"reconciliation does not overwrite newer draft",
|
||||
|
||||
@ -63,10 +63,22 @@ try {
|
||||
// New contract (spec 已确认行为 2/4): entry starts with F, scope via radiogroup, Enter reaches text.
|
||||
const scope = panel.getByRole("radiogroup", { name: "问题范围" });
|
||||
const startEntry = async (scopeName) => {
|
||||
// F is a workbench shortcut: focus a non-activating workbench control so the keydown reaches it.
|
||||
await page
|
||||
.getByTestId("capture-annotation-workbench")
|
||||
.first()
|
||||
.getByRole("button", { name: "上一帧", exact: true })
|
||||
.focus();
|
||||
// F fixes the actual ready frame; wait for decodable media first.
|
||||
await page.waitForFunction(() => {
|
||||
const videos = [...document.querySelectorAll("video")].filter((v) => v.getBoundingClientRect().width > 0);
|
||||
return videos.length > 0 && videos.every((v) => v.readyState >= 2 && !v.seeking);
|
||||
});
|
||||
await page.keyboard.press("f");
|
||||
await scope.waitFor();
|
||||
// Clicking a radio confirms that scope directly; Enter on the default radio confirms 动作.
|
||||
if (scopeName) await scope.getByRole("radio", { name: scopeName, exact: true }).click();
|
||||
await scope.getByRole("radio", { name: scopeName || "动作", exact: true }).press("Enter");
|
||||
else await scope.getByRole("radio", { name: "动作", exact: true }).press("Enter");
|
||||
await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "审查问题说明");
|
||||
};
|
||||
const savedList = panel.getByRole("listbox", { name: "已保存问题" });
|
||||
@ -132,7 +144,8 @@ try {
|
||||
await startEntry();
|
||||
await input.fill("模拟断网后保留的批注");
|
||||
await panel.getByRole("button", { name: "保存批注", exact: true }).click();
|
||||
await panel.getByText(/恢复未保存内容|保存失败/).waitFor();
|
||||
// Inline failed save keeps the editor open with its text and surfaces an error alert.
|
||||
await panel.getByRole("alert").waitFor();
|
||||
assert.equal(await input.inputValue(), "模拟断网后保留的批注");
|
||||
await page.unroute("**/review-draft");
|
||||
await input.fill("断网之后新增的文字,不能替代未核对的原操作");
|
||||
|
||||
@ -70,7 +70,7 @@ try {
|
||||
const scopeRadio = (name) => scope.getByRole("radio", { name, exact: true });
|
||||
const list = panel.getByRole("listbox", { name: "已保存问题" });
|
||||
const option = (text) => list.getByRole("option").filter({ hasText: text });
|
||||
const deleteDialog = page.getByRole("dialog", { name: "确认删除问题" });
|
||||
const deleteDialog = page.getByRole("alertdialog", { name: "确认删除问题" });
|
||||
const read = (suffix = "review-draft") =>
|
||||
page.evaluate(
|
||||
async ({ id, suffix }) => {
|
||||
@ -105,23 +105,54 @@ try {
|
||||
page.waitForFunction(
|
||||
() => document.activeElement && document.activeElement.getAttribute("aria-label") !== "审查问题说明",
|
||||
);
|
||||
// Confirming delete saves immediately; wait for that write before any further F (gated while saving).
|
||||
const confirmDelete = async () => {
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(r) => r.request().method() === "PUT" && r.url().endsWith("/review-draft") && r.ok(),
|
||||
),
|
||||
deleteDialog.getByRole("button", { name: /^确认/ }).click(),
|
||||
]);
|
||||
await deleteDialog.waitFor({ state: "detached" });
|
||||
};
|
||||
// Focus a non-activating control inside the workbench so keydown bubbles to its handler.
|
||||
const focusBench = () => bench.getByRole("button", { name: "上一帧", exact: true }).focus();
|
||||
// Known product bugs under repair must fail loudly but not block the rest of the matrix.
|
||||
const failures = [];
|
||||
const expose = async (name, fn) => {
|
||||
try {
|
||||
await fn();
|
||||
} catch (cause) {
|
||||
failures.push({ name, error: String(cause).slice(0, 400) });
|
||||
console.log("EXPOSED", name, String(cause).split("\n")[0]);
|
||||
await open().catch(() => {});
|
||||
await settle().catch(() => {});
|
||||
}
|
||||
};
|
||||
// F from the workbench: pauses, fixes the ready frame, opens scope selection.
|
||||
const pressF = async () => {
|
||||
await bench.focus();
|
||||
await focusBench();
|
||||
await page.keyboard.press("f");
|
||||
await scope.waitFor();
|
||||
};
|
||||
const startText = async (scopeName) => {
|
||||
// Clicking a radio confirms that scope directly; Enter on the focused default confirms 动作.
|
||||
if (scopeName) await scopeRadio(scopeName).click();
|
||||
await scopeRadio(scopeName || "动作").press("Enter");
|
||||
else await scopeRadio("动作").press("Enter");
|
||||
await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "审查问题说明");
|
||||
};
|
||||
const saveCurrent = async () => {
|
||||
await input.press("Control+Enter");
|
||||
await panel
|
||||
.getByRole("status")
|
||||
.filter({ hasText: /^已保存$/ })
|
||||
.waitFor();
|
||||
await Promise.all([
|
||||
page.waitForResponse(
|
||||
(r) => r.request().method() === "PUT" && r.url().endsWith("/review-draft") && r.ok(),
|
||||
),
|
||||
input.press("Control+Enter"),
|
||||
]);
|
||||
// After save the editor is gone: input empty, readonly, focus back on the workbench.
|
||||
await page.waitForFunction(() => {
|
||||
const el = document.querySelector('[aria-label="审查问题说明"]');
|
||||
return el && el.value === "" && el.readOnly;
|
||||
});
|
||||
await workbenchFocused();
|
||||
};
|
||||
const create = async (text, scopeName) => {
|
||||
@ -162,6 +193,7 @@ try {
|
||||
if (mode === "acceptance") assert.ok(first.sourceItemId);
|
||||
|
||||
// S2 — second F on the same target creates an independent problem; order = first-save order; refresh keeps both.
|
||||
await seek(18); // pin the same frame so both captures share the target
|
||||
const noteB = `${tag} 同一动作第二条 ${stamp}`;
|
||||
await create(noteB);
|
||||
const pair = (ps) => ps.filter((p) => p.text === noteA || p.text === noteB);
|
||||
@ -231,18 +263,17 @@ try {
|
||||
await deleteDialog.waitFor({ state: "detached" });
|
||||
assert.equal((await problems()).filter((p) => p.text === noteB).length, 1, "cancelled delete changes nothing");
|
||||
await page.keyboard.press("Shift+Delete");
|
||||
await deleteDialog.getByRole("button", { name: /^确认/ }).click();
|
||||
await deleteDialog.waitFor({ state: "detached" });
|
||||
await confirmDelete();
|
||||
assert.equal((await problems()).filter((p) => p.text === noteB).length, 0, "confirmed delete removes one");
|
||||
assert.ok((await problems()).some((p) => p.id === first.id), "sibling survives delete");
|
||||
const noteC = `${tag} 鼠标删除 ${stamp}`;
|
||||
await create(noteC);
|
||||
await option(noteC).click();
|
||||
await panel.getByRole("button", { name: "删除选中问题", exact: true }).click();
|
||||
await deleteDialog.getByRole("button", { name: /^确认/ }).click();
|
||||
await confirmDelete();
|
||||
assert.equal((await problems()).filter((p) => p.text === noteC).length, 0, "mouse delete follows the same path");
|
||||
|
||||
// S6 — Esc exits scope stage and fresh input without saving.
|
||||
// S6 — Esc exits scope stage and fresh input without saving; F with dirty text guards then continues.
|
||||
await pressF();
|
||||
await page.keyboard.press("Escape");
|
||||
await workbenchFocused();
|
||||
@ -254,9 +285,27 @@ try {
|
||||
await page.keyboard.press("Escape");
|
||||
await workbenchFocused();
|
||||
assert.equal((await problems()).length, countBefore, "Esc never saves");
|
||||
await expose("dirty-discard continues into the new F capture", async () => {
|
||||
await pressF();
|
||||
await startText();
|
||||
await input.fill(`${tag} 被替换的脏文字 ${stamp}`);
|
||||
await focusBench(); // F is a workbench shortcut; inside the textbox it would just type
|
||||
await page.keyboard.press("f");
|
||||
const guard = panel.getByRole("alert").filter({ hasText: "当前批注文字尚未保存" });
|
||||
await guard.waitFor();
|
||||
await guard.getByRole("button", { name: "继续编辑", exact: true }).click();
|
||||
assert.equal(await input.inputValue(), `${tag} 被替换的脏文字 ${stamp}`, "guard cancel keeps editing");
|
||||
await focusBench();
|
||||
await page.keyboard.press("f");
|
||||
await guard.getByRole("button", { name: "放弃文字", exact: true }).click();
|
||||
await scope.waitFor(); // discard must actually continue into the new F capture
|
||||
await page.keyboard.press("Escape");
|
||||
assert.equal((await problems()).length, countBefore, "discarded drafts never reach the server");
|
||||
});
|
||||
|
||||
// S7 — unsaved text survives viewing; the saved target stays the captured frame's action.
|
||||
await pressF();
|
||||
const capturedAt = Number(await range.inputValue());
|
||||
await startText();
|
||||
const dirty = `${tag} 未保存仍可观看 ${stamp}`;
|
||||
await input.fill(dirty);
|
||||
@ -269,15 +318,23 @@ try {
|
||||
if (mode === "quality") await bench.getByRole("button", { name: "下一片", exact: true }).click();
|
||||
else await page.locator('[aria-label="验收切片选择"]').getByRole("button").nth(1).click();
|
||||
await settle();
|
||||
assert.ok(
|
||||
Math.abs(Number(await range.inputValue()) - capturedAt) > 0.2,
|
||||
"viewing actually moved away from the captured frame",
|
||||
);
|
||||
assert.equal(await input.inputValue(), dirty, "slice/action navigation keeps unsaved text");
|
||||
await option(noteA2).click();
|
||||
await settle();
|
||||
assert.equal(await input.inputValue(), dirty, "viewing never clears unsaved text");
|
||||
await saveCurrent();
|
||||
const dirtySaved = (await problems()).find((p) => p.text === dirty);
|
||||
assert.equal(dirtySaved.actionId, "review-action-1-2", "target stays the frame captured by F, not the viewing spot");
|
||||
assert.ok(
|
||||
Math.abs(dirtySaved.atSeconds - capturedAt) < 0.07,
|
||||
"target stays the frame captured by F, not the viewing spot",
|
||||
);
|
||||
await option(dirty).click();
|
||||
await page.keyboard.press("Shift+Delete");
|
||||
await deleteDialog.getByRole("button", { name: /^确认/ }).click();
|
||||
await confirmDelete();
|
||||
|
||||
// S8 — empty input cannot save or delete; IME-composing and auto-repeat Ctrl+Enter send nothing.
|
||||
const versionBefore = (await read()).draft.version;
|
||||
@ -333,23 +390,43 @@ try {
|
||||
);
|
||||
assert.equal((await problems()).filter((p) => p.text === late).length, 1);
|
||||
await page.unroute("**/review-draft");
|
||||
await page.route("**/review-draft", (route) =>
|
||||
route.request().method() === "PUT" ? route.abort("failed") : route.continue(),
|
||||
);
|
||||
// Late failure after leaving the input: recovery is offered, focus is never forced.
|
||||
let releaseFail;
|
||||
const failGate = new Promise((resolve) => (releaseFail = resolve));
|
||||
await page.route("**/review-draft", async (route) => {
|
||||
if (route.request().method() !== "PUT") return route.continue();
|
||||
await failGate;
|
||||
return route.abort("failed");
|
||||
});
|
||||
const failed = `${tag} 迟到失败 ${stamp}`;
|
||||
await pressF();
|
||||
await startText();
|
||||
await input.fill(failed);
|
||||
await input.press("Control+Enter");
|
||||
await panel.getByText("恢复未保存内容", { exact: false }).waitFor();
|
||||
await Promise.all([
|
||||
page.waitForRequest((r) => r.method() === "PUT" && r.url().endsWith("/review-draft")),
|
||||
input.press("Control+Enter"),
|
||||
]);
|
||||
await page.keyboard.press("Escape"); // leave the input while the save is unresolved
|
||||
await workbenchFocused();
|
||||
releaseFail();
|
||||
const recover = panel.getByRole("button", { name: "恢复未保存内容", exact: true });
|
||||
await recover.waitFor();
|
||||
assert.notEqual(
|
||||
await page.evaluate(() => document.activeElement?.getAttribute("aria-label")),
|
||||
"审查问题说明",
|
||||
"late failure never forces focus",
|
||||
);
|
||||
await page.unroute("**/review-draft");
|
||||
await recover.click();
|
||||
assert.equal(await input.inputValue(), failed, "recovery restores the exact text");
|
||||
await panel.getByRole("button", { name: "保存批注", exact: true }).click();
|
||||
await panel
|
||||
.getByRole("status")
|
||||
.filter({ hasText: /^已保存$/ })
|
||||
.waitFor();
|
||||
assert.equal((await problems()).filter((p) => p.text === failed).length, 1, "recovered retry saves once");
|
||||
// Unknown result: replay the identical operation through the public API — no duplicate.
|
||||
// Unknown result: replay the identical operation through the public API — same-operation
|
||||
// receipt (200), never a second create. Session/CSRF headers stay in memory only.
|
||||
const dup = `${tag} 结果未知 ${stamp}`;
|
||||
await pressF();
|
||||
await startText();
|
||||
@ -362,17 +439,28 @@ try {
|
||||
.getByRole("status")
|
||||
.filter({ hasText: /^已保存$/ })
|
||||
.waitFor();
|
||||
const sentHeaders = await sent.allHeaders();
|
||||
const replayHeaders = Object.fromEntries(
|
||||
Object.entries(sentHeaders).filter(([name]) =>
|
||||
["content-type", "x-review-page", "x-review-generation", "x-droboticflow-csrf-token"].includes(name),
|
||||
),
|
||||
);
|
||||
const replay = await page.evaluate(
|
||||
async ({ url, body }) => {
|
||||
const r = await fetch(url, { method: "PUT", headers: { "Content-Type": "application/json" }, body });
|
||||
async ({ url, body, headers }) => {
|
||||
const r = await fetch(url, { method: "PUT", headers, body });
|
||||
return r.status;
|
||||
},
|
||||
{ url: sent.url(), body: sent.postData() },
|
||||
{ url: sent.url(), body: sent.postData(), headers: replayHeaders },
|
||||
);
|
||||
assert.ok([200, 409].includes(replay), "replay is idempotent or conflicts, never a second create");
|
||||
assert.equal(replay, 200, "identical authorized retry returns the same-operation receipt");
|
||||
assert.equal((await problems()).filter((p) => p.text === dup).length, 1, "identical retry never duplicates");
|
||||
|
||||
// S10 — task problems carry a viewAnchor bookmark; aggregate anchors stay isolated per source.
|
||||
const sliceButtons = mode === "acceptance" ? page.locator('[aria-label="验收切片选择"]').getByRole("button") : null;
|
||||
if (sliceButtons) {
|
||||
await sliceButtons.nth(0).click();
|
||||
await settle();
|
||||
}
|
||||
await seek(18);
|
||||
const taskNote = `${tag} 整体问题 ${stamp}`;
|
||||
await create(taskNote, "整体");
|
||||
@ -388,7 +476,7 @@ try {
|
||||
);
|
||||
if (mode === "acceptance") {
|
||||
assert.ok(taskProblem.viewAnchor.sourceItemId);
|
||||
await page.locator('[aria-label="验收切片选择"]').getByRole("button").nth(3).click();
|
||||
await sliceButtons.nth(3).click();
|
||||
await settle();
|
||||
const otherTaskNote = `${tag} 第二来源整体 ${stamp}`;
|
||||
await create(otherTaskNote, "整体");
|
||||
@ -399,6 +487,22 @@ try {
|
||||
taskProblem.viewAnchor.sourceItemId,
|
||||
"aggregate viewAnchors stay isolated per source",
|
||||
);
|
||||
// Recalling the first member's task bookmark from the second member must restore its slice and picture.
|
||||
await expose("cross-member task viewAnchor recall", async () => {
|
||||
await option(taskNote).click();
|
||||
await settle();
|
||||
assert.equal(
|
||||
await sliceButtons.nth(0).getAttribute("aria-pressed"),
|
||||
"true",
|
||||
"task recall follows viewAnchor back to the original member",
|
||||
);
|
||||
assert.ok(
|
||||
Math.abs(Number(await range.inputValue()) - taskProblem.viewAnchor.atSeconds) < 0.5,
|
||||
"task recall lands on the anchored picture",
|
||||
);
|
||||
});
|
||||
await sliceButtons.nth(3).click();
|
||||
await settle();
|
||||
await seek(18);
|
||||
const otherAction = `${tag} 第二来源动作 ${stamp}`;
|
||||
await create(otherAction);
|
||||
@ -412,17 +516,104 @@ try {
|
||||
assert.equal(await page.getByText("无效动作", { exact: true }).count(), 0, "old wording is gone");
|
||||
|
||||
// S12 — screenshots for K3 review: 1413×615 left/right/dual in focus, ordinary otherwise.
|
||||
// Move to a text-bearing frame so every visible camera renders its own caption.
|
||||
await actionBlocks.first().click();
|
||||
await settle();
|
||||
// Wait for the camera relayout to settle: the expected cameras are visible and each has its own caption.
|
||||
const captionsSettled = async (cameras) => {
|
||||
const visibleVideos = () =>
|
||||
[...document.querySelectorAll("video")].filter(
|
||||
(v) => v.checkVisibility() && v.getBoundingClientRect().width > 0,
|
||||
);
|
||||
try {
|
||||
await page.waitForFunction(
|
||||
(count) =>
|
||||
[...document.querySelectorAll("video")].filter(
|
||||
(v) => v.checkVisibility() && v.getBoundingClientRect().width > 0,
|
||||
).length === count &&
|
||||
document.querySelectorAll(".review-picture-caption-text").length === count,
|
||||
cameras.length,
|
||||
);
|
||||
} catch (cause) {
|
||||
console.log(
|
||||
"CAPTION_DEBUG",
|
||||
JSON.stringify(
|
||||
await page.evaluate(() => ({
|
||||
videos: [...document.querySelectorAll("video")].map((v) => ({
|
||||
w: Math.round(v.getBoundingClientRect().width),
|
||||
visible: v.checkVisibility(),
|
||||
})),
|
||||
captions: [...document.querySelectorAll("[data-camera-caption]")].map((c) =>
|
||||
c.getAttribute("data-camera-caption"),
|
||||
),
|
||||
})),
|
||||
),
|
||||
);
|
||||
throw cause;
|
||||
}
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
new Promise((resolve) => {
|
||||
const key = () =>
|
||||
[...document.querySelectorAll("video,.review-picture-caption-text")]
|
||||
.map((el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return `${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.width)},${Math.round(r.height)}`;
|
||||
})
|
||||
.join("|");
|
||||
const firstKey = key();
|
||||
requestAnimationFrame(() => requestAnimationFrame(() => resolve(key() === firstKey)));
|
||||
}),
|
||||
);
|
||||
const layout = await page.evaluate(() => {
|
||||
const rect = (el) => {
|
||||
const r = el.getBoundingClientRect();
|
||||
return { x: r.x, y: r.y, w: r.width, h: r.height, bottom: r.bottom };
|
||||
};
|
||||
return {
|
||||
videos: [...document.querySelectorAll("video")]
|
||||
.filter((v) => v.checkVisibility() && v.getBoundingClientRect().width > 0)
|
||||
.map(rect),
|
||||
captions: [...document.querySelectorAll("[data-camera-caption]")].map((c) => ({
|
||||
camera: c.getAttribute("data-camera-caption"),
|
||||
...rect(c),
|
||||
})),
|
||||
};
|
||||
});
|
||||
assert.equal(layout.videos.length, cameras.length, "visible cameras match the selection");
|
||||
assert.deepEqual(
|
||||
layout.captions.map((c) => c.camera).sort(),
|
||||
[...cameras].sort(),
|
||||
"visible captions belong to the selected cameras",
|
||||
);
|
||||
for (const caption of layout.captions) {
|
||||
const owner = layout.videos.find(
|
||||
(v) => caption.x + caption.w / 2 >= v.x && caption.x + caption.w / 2 <= v.x + v.w,
|
||||
);
|
||||
assert.ok(owner, "caption sits inside its own camera image horizontally");
|
||||
assert.ok(
|
||||
Math.abs(caption.x + caption.w / 2 - (owner.x + owner.w / 2)) < owner.w * 0.2,
|
||||
"caption is horizontally centered on its own camera image",
|
||||
);
|
||||
assert.ok(
|
||||
caption.bottom <= owner.bottom + 2 && caption.bottom > owner.bottom - owner.h * 0.6,
|
||||
"caption stays near the bottom of its own camera image",
|
||||
);
|
||||
}
|
||||
};
|
||||
if (focused) {
|
||||
for (const [camera, label] of [
|
||||
["left", "放大左相机"],
|
||||
["right", "放大右相机"],
|
||||
["both", "恢复双画面"],
|
||||
for (const [camera, label, cameras] of [
|
||||
["left", "放大左相机", ["left"]],
|
||||
["right", "放大右相机", ["right"]],
|
||||
["both", "恢复双画面", ["left", "right"]],
|
||||
]) {
|
||||
await page.getByRole("button", { name: label, exact: true }).click();
|
||||
await settle();
|
||||
await captionsSettled(cameras);
|
||||
await page.screenshot({ path: `${dir}/problem-workflow-${mode}-focus-${camera}.png`, fullPage: true });
|
||||
}
|
||||
} else {
|
||||
await captionsSettled(["left", "right"]); // ordinary layout keeps both cameras visible
|
||||
await page.screenshot({ path: `${dir}/problem-workflow-${mode}-ordinary.png`, fullPage: true });
|
||||
}
|
||||
|
||||
@ -452,8 +643,10 @@ try {
|
||||
aggregateSourceIsolation: mode === "acceptance",
|
||||
noJsonCaptionsUnified: true,
|
||||
noFormalDecision: true,
|
||||
knownProductFailures: failures,
|
||||
});
|
||||
console.log("PASS", mode, focused ? "focus" : "ordinary");
|
||||
if (failures.length) process.exitCode = 1;
|
||||
console.log("PASS", mode, focused ? "focus" : "ordinary", failures.length ? `(${failures.length} exposed)` : "");
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user