✨ Add single-camera inspection and aspect fit
This commit is contained in:
parent
db5e6d23ea
commit
ee3d6b16bf
@ -18,7 +18,9 @@
|
||||
|
||||
任务 05 将两类字典放入固定编辑区:搜索、每页 2 项、前后页和返回入口固定,长词条显示两行预览,悬停或辅助技术可读取完整词条,填入后可继续完整阅读。F / D 打开,方向键选择,Enter 填入,Esc 一次返回工作台;选择描述模板不会保存,可继续修改。长描述在同一个文本框内滚动,“展开描述编辑”暂时收起精确边界区域以增加文字空间,保存和取消始终在文本滚动区外;收起、切片导航与布局切换不保存草稿。原布局仍使用原有字典弹层。
|
||||
|
||||
单相机放大和窗口过小时暂停,由后续任务交付。当前双画面尺寸验证使用五档实际浏览器内容区,不代表已覆盖各种操作系统缩放设置。
|
||||
任务 06 在专注视图的视频上方提供“放大左相机”“放大右相机”和“恢复双画面”。单路检查期间只改变呈现:两路视频节点和媒体源都保留,隐藏路继续同步;详细切片/描述时间轴临时收成 Capture 进度条,把高度让给所选画面。切片阶段的当前播放头分割入口、播放与逐帧、当前编辑、保存、撤销/重做及阶段提交仍可达。恢复双画面或切回原布局保留播放帧、草稿、选择和历史;原布局继续使用原来的左右相机显示复选框。
|
||||
|
||||
真实 590×480 双视频在 1280×640 内容区的实测每路有效画面约 410.5×334,单路约 565.4×460;两种模式在五档内容区均随窗口扩大。16:9 与 9:16 的 12 秒、30fps 本地 testsrc2 文件只用于验证左右不同比例时的 `contain` 适配,不代表客户素材或真实工作流覆盖。窗口过小时暂停仍由后续任务交付;当前浏览器尺寸验证不代表已覆盖各种操作系统缩放设置。
|
||||
|
||||
## 源码恢复与业务数据恢复
|
||||
|
||||
@ -37,3 +39,5 @@
|
||||
分页边界拖动验收为 `tests/browser/annotation-workspace-boundaries.mjs`,默认检查切片,传入 `NAVIGATION_PHASE=annotate` 检查描述。它使用真实鼠标手势将页尾边界向两侧移动,并检查同一横坐标不会重复改变边界;描述模式通过现有编辑、确认结束点和保存建立相邻区间,再以公共 API 核对共享精确帧。历史验收还覆盖从另一切片重做已保存描述时,关闭编辑器并显示目标页。
|
||||
|
||||
字典与长文本验收为 `tests/browser/annotation-workspace-dictionaries.mjs`,使用 pool-01 与 annotate-primary。隔离项目需配置多页字典,以及“布局长名称验收”长名称与“布局长文本模板”长描述。脚本验证两类字典在五档内容区的固定入口、搜索分页、原布局回退、一次 Esc、原生剪切/撤销、草稿展开/收起/跨片保存及 API 撤销/重做回读。组合事件检查是浏览器派发的快捷键归属检查,不代表操作系统输入法验收;完整 OS 缩放与输入法矩阵仍需人工验证。
|
||||
|
||||
单路检查与比例适配验收为 `tests/browser/annotation-workspace-camera-inspection.mjs`,使用 annotate-primary 与 pool-01 且不执行保存、生成、送检或领取。脚本以真实 590×480 双视频检查五档双路/单路有效画面、左右放大、播放逐帧、进度条指针、草稿与媒体节点、历史、布局回退和公共 API 版本不变;随后在独立无缓存浏览器上下文中仅把两路 `subject-content` 映射到忽略目录的 16:9 / 9:16 合成文件,验证完整等比显示。合成文件不参与真实帧/API 工作流结论。
|
||||
|
||||
@ -314,6 +314,7 @@ export function CaptureAnnotationWorkbench({
|
||||
const [playbackRate, setPlaybackRate] = useState(1);
|
||||
const [showLeft, setShowLeft] = useState(initialCameraVisibility?.left ?? true);
|
||||
const [showRight, setShowRight] = useState(initialCameraVisibility?.right ?? Boolean(rightVideoSource));
|
||||
const [inspectionCamera, setInspectionCamera] = useState<"left" | "right" | null>(null);
|
||||
const [selectedBoundary, setSelectedBoundary] = useState<Boundary>(null);
|
||||
const [splitPreview, setSplitPreview] = useState<SplitPreview>(null);
|
||||
const [editingAnnotation, setEditingAnnotation] = useState<AnnotationSegment | null>(null);
|
||||
@ -341,6 +342,9 @@ export function CaptureAnnotationWorkbench({
|
||||
const [showDictionary, setShowDictionary] = useState(false);
|
||||
const [expandedDescription, setExpandedDescription] = useState(false);
|
||||
useEffect(() => setExpandedDescription(false), [editingAnnotation?.id]);
|
||||
useEffect(() => {
|
||||
if (!focusedLayout) setInspectionCamera(null);
|
||||
}, [focusedLayout]);
|
||||
useEffect(() => {
|
||||
if (showDictionary && !focusedLayout)
|
||||
(
|
||||
@ -363,6 +367,7 @@ export function CaptureAnnotationWorkbench({
|
||||
setEndSelection(null);
|
||||
setEditingAnnotation(null);
|
||||
setShowDictionary(false);
|
||||
setInspectionCamera(null);
|
||||
shortcutHelpRef.current?.close();
|
||||
setSelectedBoundary(null);
|
||||
setSelectedAnnotationBoundary(null);
|
||||
@ -1431,7 +1436,7 @@ export function CaptureAnnotationWorkbench({
|
||||
};
|
||||
|
||||
const selectedSliceStatus = selectedSlice ? statuses[selectedSlice.id] || "pending" : "pending";
|
||||
const videoClass = showLeft && showRight ? "grid-cols-2" : "grid-cols-1";
|
||||
const videoClass = (focusedLayout && inspectionCamera) || !(showLeft && showRight) ? "grid-cols-1" : "grid-cols-2";
|
||||
useEffect(() => {
|
||||
if (editingAnnotation?.id) {
|
||||
descriptionEditorRef.current?.scrollIntoView({ block: "end", behavior: "instant" });
|
||||
@ -1504,6 +1509,7 @@ export function CaptureAnnotationWorkbench({
|
||||
className="capture-workbench min-w-0 max-w-full rounded-md border border-[color:var(--app-border)] bg-[color:var(--app-panel)] text-[color:var(--app-text)] shadow-[0_8px_28px_rgba(15,23,42,0.06)]"
|
||||
data-testid="capture-annotation-workbench"
|
||||
data-stage={phase}
|
||||
data-camera-inspection={focusedLayout ? inspectionCamera || undefined : undefined}
|
||||
data-adaptive-slice={adaptiveLayout && phase === "slice" && !mediaOnly && !isQualityReview ? true : undefined}
|
||||
tabIndex={0}
|
||||
onPointerDownCapture={(event) => {
|
||||
@ -1893,36 +1899,81 @@ export function CaptureAnnotationWorkbench({
|
||||
data-testid="capture-video-panel"
|
||||
>
|
||||
<div className="capture-camera-selection mb-2 flex gap-4 text-sm font-medium text-[color:var(--app-text)]">
|
||||
<label className="inline-flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showLeft}
|
||||
onChange={(event) => {
|
||||
const left = event.target.checked || !showRight;
|
||||
if (left !== showLeft) transport.prepareCameraChange();
|
||||
setShowLeft(left);
|
||||
onCameraVisibilityChange?.({ left, right: showRight });
|
||||
}}
|
||||
className="accent-orange-500"
|
||||
/>
|
||||
左相机
|
||||
</label>
|
||||
{rightSource ? (
|
||||
<label className="inline-flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showRight}
|
||||
onChange={(event) => {
|
||||
const right = event.target.checked || !showLeft;
|
||||
if (right !== showRight) transport.prepareCameraChange();
|
||||
setShowRight(right);
|
||||
onCameraVisibilityChange?.({ left: showLeft, right });
|
||||
}}
|
||||
className="accent-orange-500"
|
||||
/>
|
||||
右相机
|
||||
</label>
|
||||
) : null}
|
||||
{focusedLayout ? (
|
||||
<div className="capture-camera-inspection-controls" aria-label="单路相机检查">
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={inspectionCamera === "left"}
|
||||
disabled={!showLeft}
|
||||
onClick={() => setInspectionCamera("left")}
|
||||
>
|
||||
放大左相机
|
||||
</button>
|
||||
{rightSource ? (
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={inspectionCamera === "right"}
|
||||
disabled={!showRight}
|
||||
onClick={() => setInspectionCamera("right")}
|
||||
>
|
||||
放大右相机
|
||||
</button>
|
||||
) : null}
|
||||
<button type="button" disabled={!inspectionCamera} onClick={() => setInspectionCamera(null)}>
|
||||
恢复双画面
|
||||
</button>
|
||||
{inspectionCamera && phase === "slice" && !readOnly && !isQualityReview ? (
|
||||
<button
|
||||
type="button"
|
||||
title="在播放头分割当前切片(C)"
|
||||
aria-keyshortcuts="C"
|
||||
disabled={
|
||||
!canEdit ||
|
||||
!onSplitSlice ||
|
||||
!playheadSlice ||
|
||||
currentTime <= playheadSlice.start + 0.001 ||
|
||||
currentTime >= playheadSlice.end - 0.001
|
||||
}
|
||||
onClick={splitAtPlayhead}
|
||||
>
|
||||
在播放头分割切片
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
) : (
|
||||
<div className="capture-camera-visibility-controls">
|
||||
<label className="inline-flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showLeft}
|
||||
onChange={(event) => {
|
||||
const left = event.target.checked || !showRight;
|
||||
if (left !== showLeft) transport.prepareCameraChange();
|
||||
setShowLeft(left);
|
||||
onCameraVisibilityChange?.({ left, right: showRight });
|
||||
}}
|
||||
className="accent-orange-500"
|
||||
/>
|
||||
左相机
|
||||
</label>
|
||||
{rightSource ? (
|
||||
<label className="inline-flex items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showRight}
|
||||
onChange={(event) => {
|
||||
const right = event.target.checked || !showLeft;
|
||||
if (right !== showRight) transport.prepareCameraChange();
|
||||
setShowRight(right);
|
||||
onCameraVisibilityChange?.({ left: showLeft, right });
|
||||
}}
|
||||
className="accent-orange-500"
|
||||
/>
|
||||
右相机
|
||||
</label>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className={cn("capture-video-surface grid overflow-hidden rounded-md bg-slate-950", videoClass)}>
|
||||
<video
|
||||
|
||||
@ -1147,3 +1147,74 @@
|
||||
min-height: 28px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Single-camera inspection is presentation-only: both media nodes remain
|
||||
mounted and synchronized while the selected picture receives the released
|
||||
timeline height. Original-layout camera visibility controls stay unchanged. */
|
||||
.capture-camera-visibility-controls {
|
||||
display: contents;
|
||||
}
|
||||
.capture-camera-inspection-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.capture-camera-inspection-controls button {
|
||||
border: 1px solid var(--app-border);
|
||||
border-radius: 4px;
|
||||
padding: 1px 7px;
|
||||
background: var(--app-panel);
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.capture-camera-inspection-controls button[aria-pressed="true"] {
|
||||
border-color: #f97316;
|
||||
color: #c2410c;
|
||||
}
|
||||
.capture-camera-inspection-controls button:disabled {
|
||||
opacity: 0.45;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact] .capture-workbench[data-camera-inspection] .capture-video-surface {
|
||||
position: relative;
|
||||
grid-template-columns: minmax(0, 1fr) !important;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection="left"]
|
||||
video[data-camera="right"],
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection="right"]
|
||||
video[data-camera="left"] {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection]
|
||||
[data-testid="capture-video-panel"] {
|
||||
grid-row: 1 / 4;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection]
|
||||
.capture-timeline-editor {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 64px;
|
||||
z-index: 30;
|
||||
width: calc(100% - var(--workspace-editor-width) - var(--workspace-region-gap));
|
||||
height: 28px !important;
|
||||
align-self: stretch !important;
|
||||
grid-template-rows: 18px !important;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection]
|
||||
.capture-timeline-editor
|
||||
> :not(input[type="range"]) {
|
||||
display: none;
|
||||
}
|
||||
.annotation-operations-page[data-workspace-compact]
|
||||
.capture-workbench[data-camera-inspection]
|
||||
[data-testid="slice-annotation-timeline"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
441
tests/browser/annotation-workspace-camera-inspection.mjs
Normal file
441
tests/browser/annotation-workspace-camera-inspection.mjs
Normal file
@ -0,0 +1,441 @@
|
||||
// Real local UI/API acceptance: single-camera inspection must enlarge the
|
||||
// effective picture without replacing media/editor state or changing frames.
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const edge = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge";
|
||||
const baseURL = "http://127.0.0.1:5173";
|
||||
const project = "project-workspace-layout-acceptance";
|
||||
const task = process.env.ANNOTATION_TASK_ID || "annotation-task-workspace-layout-acceptance-annotate-primary";
|
||||
assert.match(
|
||||
task,
|
||||
/^annotation-task-workspace-layout-acceptance-(annotate-primary|pool-01)$/,
|
||||
"camera acceptance uses only the reserved editable fixtures",
|
||||
);
|
||||
|
||||
const browser = await chromium.launch({
|
||||
executablePath: edge,
|
||||
headless: true,
|
||||
args: ["--no-proxy-server"],
|
||||
});
|
||||
const context = await browser.newContext({
|
||||
storageState: "local-data/verification/annotation-workspace-layout/auth.json",
|
||||
viewport: { width: 1280, height: 640 },
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(20_000);
|
||||
|
||||
const button = (name) => page.getByRole("button", { name, exact: true });
|
||||
const workbench = page.getByTestId("capture-annotation-workbench");
|
||||
const videos = page.locator("video");
|
||||
const continueOwnedTask = async (targetPage, taskID) => {
|
||||
const row = targetPage.getByRole("button").filter({ hasText: taskID });
|
||||
await row.waitFor();
|
||||
await row.click();
|
||||
await targetPage.getByRole("button", { name: "继续工作", exact: true }).click();
|
||||
};
|
||||
const readItem = async (taskID = task) => {
|
||||
const response = await context.request.get(
|
||||
`${baseURL}/api/human-items/${taskID.replace("annotation-task-", "human-item-")}`,
|
||||
);
|
||||
assert.ok(response.ok(), "fixture is readable through the public API");
|
||||
return (await response.json()).item;
|
||||
};
|
||||
const effectivePictures = () =>
|
||||
page.evaluate(() =>
|
||||
[...document.querySelectorAll("video")].map((video) => {
|
||||
const rect = video.getBoundingClientRect();
|
||||
const scale = Math.min(rect.width / video.videoWidth, rect.height / video.videoHeight);
|
||||
return {
|
||||
camera: video.dataset.camera,
|
||||
intrinsic: [video.videoWidth, video.videoHeight],
|
||||
width: video.videoWidth * scale,
|
||||
height: video.videoHeight * scale,
|
||||
fit: getComputedStyle(video).objectFit,
|
||||
connected: video.isConnected,
|
||||
currentTime: video.currentTime,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const reachable = async (locator, label) => {
|
||||
assert.ok(
|
||||
await locator.evaluate((element) => {
|
||||
const rect = element.getBoundingClientRect();
|
||||
return (
|
||||
rect.width > 0 &&
|
||||
rect.height > 0 &&
|
||||
rect.x >= 0 &&
|
||||
rect.y >= 0 &&
|
||||
rect.right <= innerWidth &&
|
||||
rect.bottom <= innerHeight &&
|
||||
element.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2))
|
||||
);
|
||||
}),
|
||||
`${label} is visible and hit-test reachable`,
|
||||
);
|
||||
};
|
||||
const visible = (locator) => locator.evaluate((element) => getComputedStyle(element).display !== "none");
|
||||
const workspaceScrollers = () =>
|
||||
page.evaluate(() =>
|
||||
[
|
||||
document.documentElement,
|
||||
...document.querySelectorAll("main, main > div,.annotation-operations-page,.capture-workbench-body"),
|
||||
]
|
||||
.filter(
|
||||
(element) =>
|
||||
element.scrollHeight > element.clientHeight + 1 && getComputedStyle(element).overflowY !== "visible",
|
||||
)
|
||||
.map((element) => element.className),
|
||||
);
|
||||
const frameNumber = async () => {
|
||||
const text = await page.locator(".capture-media-controls .font-mono").innerText();
|
||||
const match = text.match(/帧\s+(\d+)/);
|
||||
assert.ok(match, `frame readout is available: ${text}`);
|
||||
return Number(match[1]);
|
||||
};
|
||||
|
||||
const writes = [];
|
||||
page.on("request", (request) => {
|
||||
if (request.method() !== "GET" && /\/tasks\/|random-claims/.test(request.url())) writes.push(request.url());
|
||||
});
|
||||
|
||||
try {
|
||||
const before = await readItem();
|
||||
await page.goto(`${baseURL}/plugins/annotation-qa/workflows/all/work?projectId=${project}&taskId=${task}`, {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await continueOwnedTask(page, task);
|
||||
if (await button("进入专注视图").count()) await button("进入专注视图").click();
|
||||
await workbench.waitFor();
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
document.querySelectorAll("video").length === 2 &&
|
||||
[...document.querySelectorAll("video")].every((video) => video.readyState >= 2),
|
||||
null,
|
||||
{ timeout: 60_000 },
|
||||
);
|
||||
|
||||
const videoHandles = await videos.elementHandles();
|
||||
const firstBlock = page.getByTestId("annotation-description-block").first();
|
||||
let draftInput = null;
|
||||
let draftHandle = null;
|
||||
let draft = "";
|
||||
if (await firstBlock.count()) {
|
||||
await firstBlock.click();
|
||||
draftInput = page.getByRole("textbox", { name: "动作描述", exact: true });
|
||||
draftHandle = await draftInput.elementHandle();
|
||||
draft = `Task06 unsaved camera inspection ${Date.now()}`;
|
||||
await draftInput.fill(draft);
|
||||
}
|
||||
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
const heldFrame = await frameNumber();
|
||||
const detailedSliceTimeline = page.getByTestId("capture-slice-timeline");
|
||||
const detailedDescriptionTimeline = page.getByTestId("slice-annotation-timeline");
|
||||
assert.ok(await visible(detailedSliceTimeline), "dual-camera mode shows the detailed slice timeline");
|
||||
assert.ok(await visible(detailedDescriptionTimeline), "dual-camera mode shows the detailed description timeline");
|
||||
|
||||
let previousDualWidth = 0;
|
||||
let previousSingleWidth = 0;
|
||||
for (const [width, height] of [
|
||||
[1280, 640],
|
||||
[1366, 680],
|
||||
[1440, 800],
|
||||
[1920, 980],
|
||||
[2560, 1320],
|
||||
]) {
|
||||
await page.setViewportSize({ width, height });
|
||||
await button("恢复双画面").waitFor();
|
||||
const dual = await effectivePictures();
|
||||
assert.deepEqual(
|
||||
dual.map((picture) => picture.intrinsic),
|
||||
[
|
||||
[590, 480],
|
||||
[590, 480],
|
||||
],
|
||||
"real acceptance uses the two 590×480 customer-derived fixture videos",
|
||||
);
|
||||
for (const picture of dual) {
|
||||
assert.equal(picture.fit, "contain");
|
||||
assert.ok(picture.width >= 400 && picture.height >= 325, "each real dual picture meets the 400×325 floor");
|
||||
assert.ok(picture.width >= previousDualWidth, "real dual pictures grow with supported viewport sizes");
|
||||
}
|
||||
previousDualWidth = dual[0].width;
|
||||
|
||||
await button("放大左相机").click();
|
||||
await page.locator('[data-camera-inspection="left"]').waitFor();
|
||||
const single = await effectivePictures();
|
||||
console.log(
|
||||
JSON.stringify({
|
||||
viewport: [width, height],
|
||||
realDual: dual.map(({ camera, intrinsic, width: pictureWidth, height: pictureHeight, fit }) => ({
|
||||
camera,
|
||||
intrinsic,
|
||||
width: pictureWidth,
|
||||
height: pictureHeight,
|
||||
fit,
|
||||
})),
|
||||
realSingleLeft: {
|
||||
width: single[0].width,
|
||||
height: single[0].height,
|
||||
fit: single[0].fit,
|
||||
},
|
||||
}),
|
||||
);
|
||||
assert.ok(
|
||||
single[0].width >= 490 && single[0].height >= 398,
|
||||
"the real left picture grows to the 490×398 inspection floor",
|
||||
);
|
||||
assert.ok(single[0].width >= previousSingleWidth, "the inspection picture grows with supported viewport sizes");
|
||||
previousSingleWidth = single[0].width;
|
||||
assert.deepEqual(await workspaceScrollers(), [], "inspection introduces no page or workbench scrolling");
|
||||
assert.equal(await visible(detailedSliceTimeline), false, "inspection compresses the detailed slice timeline");
|
||||
assert.equal(
|
||||
await visible(detailedDescriptionTimeline),
|
||||
false,
|
||||
"inspection compresses the detailed description timeline",
|
||||
);
|
||||
await reachable(page.getByRole("slider", { name: "Capture 播放位置" }), "inspection progress bar");
|
||||
for (const name of ["播放", "上一帧", "下一帧", "恢复双画面", "新增动作描述", "完成任务并提交质检"])
|
||||
await reachable(button(name), name);
|
||||
if (draftInput) {
|
||||
await reachable(draftInput, "current editor");
|
||||
await reachable(button("确认保存描述"), "save action");
|
||||
assert.equal(await draftInput.inputValue(), draft, "inspection retains the unsaved description draft");
|
||||
}
|
||||
assert.equal(await frameNumber(), heldFrame, "inspection does not change the current frame");
|
||||
for (const handle of videoHandles) assert.ok(await handle.evaluate((element) => element.isConnected));
|
||||
if (draftHandle) assert.ok(await draftHandle.evaluate((element) => element.isConnected));
|
||||
|
||||
await button("恢复双画面").click();
|
||||
assert.ok(await visible(detailedSliceTimeline), "restore brings back the detailed slice timeline");
|
||||
assert.ok(await visible(detailedDescriptionTimeline), "restore brings back the description timeline");
|
||||
assert.equal(await frameNumber(), heldFrame, "restore retains the exact frame");
|
||||
}
|
||||
|
||||
await page.setViewportSize({ width: 1280, height: 640 });
|
||||
await button("放大右相机").click();
|
||||
const rightSingle = await effectivePictures();
|
||||
assert.ok(rightSingle[1].width >= 490 && rightSingle[1].height >= 398, "right-camera inspection also grows");
|
||||
assert.ok(
|
||||
Math.abs(rightSingle[0].currentTime - rightSingle[1].currentTime) < 0.05,
|
||||
"the visually hidden camera stays synchronized",
|
||||
);
|
||||
await button("播放").click();
|
||||
await page.waitForFunction(() => [...document.querySelectorAll("video")].every((video) => !video.paused));
|
||||
await button("暂停").click();
|
||||
await page.waitForFunction(() => [...document.querySelectorAll("video")].every((video) => video.paused));
|
||||
const inspectionPlaybackFrame = await frameNumber();
|
||||
await button("恢复双画面").click();
|
||||
|
||||
await button("切回原布局").click();
|
||||
for (const handle of videoHandles) assert.ok(await handle.evaluate((element) => element.isConnected));
|
||||
if (draftInput) assert.equal(await draftInput.inputValue(), draft, "original layout retains the active draft");
|
||||
await reachable(page.getByRole("checkbox", { name: "左相机", exact: true }), "original left-camera control");
|
||||
await reachable(page.getByRole("checkbox", { name: "右相机", exact: true }), "original right-camera control");
|
||||
assert.equal(await button("放大左相机").count(), 0, "inspection controls do not alter the original layout");
|
||||
await button("进入专注视图").click();
|
||||
assert.ok(await visible(detailedSliceTimeline), "layout return restores dual-camera detail mode");
|
||||
assert.equal(await frameNumber(), inspectionPlaybackFrame, "layout toggles retain the post-playback frame");
|
||||
|
||||
if (draftInput) await button("取消编辑").click();
|
||||
assert.equal(writes.length, 0, "inspection, restore and layout toggles never write or claim");
|
||||
assert.equal((await readItem()).version, before.version, "public authoritative version remains unchanged");
|
||||
console.log("PASS real dual/single camera geometry, state continuity and public API non-mutation");
|
||||
|
||||
const sliceTask = "annotation-task-workspace-layout-acceptance-pool-01";
|
||||
const sliceBefore = await readItem(sliceTask);
|
||||
await page.goto(`${baseURL}/plugins/annotation-qa/workflows/all/work?projectId=${project}&taskId=${sliceTask}`, {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await continueOwnedTask(page, sliceTask);
|
||||
if (await button("进入专注视图").count()) await button("进入专注视图").click();
|
||||
await workbench.waitFor();
|
||||
await page.waitForFunction(
|
||||
() =>
|
||||
document.querySelectorAll("video").length === 2 &&
|
||||
[...document.querySelectorAll("video")].every((video) => video.readyState >= 2),
|
||||
null,
|
||||
{ timeout: 60_000 },
|
||||
);
|
||||
const sliceVideoHandles = await videos.elementHandles();
|
||||
const initialSlicePictures = await effectivePictures();
|
||||
assert.ok(
|
||||
initialSlicePictures.every((picture) => picture.width >= 400 && picture.height >= 325),
|
||||
"slicing also defaults to two complete pictures at the minimum viewport",
|
||||
);
|
||||
const deleteSliceButtons = button("删除切片");
|
||||
const initialSliceCount = await deleteSliceButtons.count();
|
||||
await workbench.focus();
|
||||
for (let index = 0; index < 6; index++) await page.keyboard.press("ArrowRight");
|
||||
await page.keyboard.press("c");
|
||||
assert.equal(await deleteSliceButtons.count(), initialSliceCount + 1, "slice history has an unsaved cut");
|
||||
const sliceFrame = await frameNumber();
|
||||
|
||||
await button("放大左相机").click();
|
||||
for (const name of ["播放", "上一帧", "下一帧", "在播放头分割切片", "确认全部切片", "撤销", "重做", "恢复双画面"])
|
||||
await reachable(button(name), name);
|
||||
await workbench.focus();
|
||||
await page.keyboard.press("ArrowRight");
|
||||
assert.equal(await frameNumber(), sliceFrame + 1, "keyboard stepping remains exact during inspection");
|
||||
for (const handle of sliceVideoHandles) assert.ok(await handle.evaluate((element) => element.isConnected));
|
||||
|
||||
const compactProgress = page.getByRole("slider", { name: "Capture 播放位置" });
|
||||
const progressBox = await compactProgress.boundingBox();
|
||||
assert.ok(progressBox);
|
||||
await compactProgress.click({ position: { x: progressBox.width * 0.37, y: progressBox.height / 2 } });
|
||||
const compactMappedFrame = await frameNumber();
|
||||
await button("恢复双画面").click();
|
||||
const restoredProgressBox = await compactProgress.boundingBox();
|
||||
assert.ok(restoredProgressBox);
|
||||
await compactProgress.click({
|
||||
position: { x: restoredProgressBox.width * 0.37, y: restoredProgressBox.height / 2 },
|
||||
});
|
||||
assert.ok(
|
||||
Math.abs((await frameNumber()) - compactMappedFrame) <= 1,
|
||||
"progress pointer mapping remains on the same original frame after restore",
|
||||
);
|
||||
await button("撤销").click();
|
||||
assert.equal(await deleteSliceButtons.count(), initialSliceCount, "undo history survives inspection and restore");
|
||||
await page.waitForTimeout(1100);
|
||||
await button("重做").click();
|
||||
assert.equal(await deleteSliceButtons.count(), initialSliceCount + 1, "redo history survives inspection and restore");
|
||||
assert.equal(writes.length, 0, "slice inspection and in-memory history never write or claim");
|
||||
assert.equal((await readItem(sliceTask)).version, sliceBefore.version, "slice fixture version remains unchanged");
|
||||
console.log("PASS slicing controls, exact frame/pointer mapping, mounted media and history continuity");
|
||||
|
||||
const fixtureFiles = [
|
||||
{
|
||||
label: "synthetic 16:9",
|
||||
body: readFileSync("local-data/verification/annotation-workspace-layout/aspect-fixtures/landscape-16x9.mp4"),
|
||||
},
|
||||
{
|
||||
label: "synthetic 9:16",
|
||||
body: readFileSync("local-data/verification/annotation-workspace-layout/aspect-fixtures/portrait-9x16.mp4"),
|
||||
},
|
||||
];
|
||||
await page.goto("about:blank");
|
||||
const syntheticContext = await browser.newContext({
|
||||
storageState: "local-data/verification/annotation-workspace-layout/auth.json",
|
||||
viewport: { width: 1280, height: 640 },
|
||||
});
|
||||
const syntheticPage = await syntheticContext.newPage();
|
||||
syntheticPage.setDefaultTimeout(20_000);
|
||||
const fixtureByURL = new Map();
|
||||
await syntheticPage.route("**/*", async (route) => {
|
||||
const request = route.request();
|
||||
if (!new URL(request.url()).pathname.endsWith("/subject-content")) {
|
||||
await route.continue();
|
||||
return;
|
||||
}
|
||||
let fixtureIndex = fixtureByURL.get(request.url());
|
||||
if (fixtureIndex === undefined) {
|
||||
fixtureIndex = fixtureByURL.size;
|
||||
fixtureByURL.set(request.url(), fixtureIndex);
|
||||
}
|
||||
const fixture = fixtureFiles[fixtureIndex];
|
||||
assert.ok(fixture, "only the two task media URLs are replaced by synthetic aspect fixtures");
|
||||
const range = request.headers().range?.match(/^bytes=(\d+)-(\d*)$/);
|
||||
const start = range ? Number(range[1]) : 0;
|
||||
const end = range && range[2] ? Math.min(Number(range[2]), fixture.body.length - 1) : fixture.body.length - 1;
|
||||
const body = fixture.body.subarray(start, end + 1);
|
||||
await route.fulfill({
|
||||
status: range ? 206 : 200,
|
||||
contentType: "video/mp4",
|
||||
headers: {
|
||||
"accept-ranges": "bytes",
|
||||
"content-length": String(body.length),
|
||||
...(range ? { "content-range": `bytes ${start}-${end}/${fixture.body.length}` } : {}),
|
||||
},
|
||||
body,
|
||||
});
|
||||
});
|
||||
const syntheticWrites = [];
|
||||
syntheticPage.on("request", (request) => {
|
||||
if (request.method() !== "GET" && /\/tasks\/|random-claims/.test(request.url()))
|
||||
syntheticWrites.push(request.url());
|
||||
});
|
||||
await syntheticPage.goto(
|
||||
`${baseURL}/plugins/annotation-qa/workflows/all/work?projectId=${project}&taskId=${sliceTask}`,
|
||||
{ waitUntil: "domcontentloaded" },
|
||||
);
|
||||
const syntheticButton = (name) => syntheticPage.getByRole("button", { name, exact: true });
|
||||
await continueOwnedTask(syntheticPage, sliceTask);
|
||||
if (await syntheticButton("进入专注视图").count()) await syntheticButton("进入专注视图").click();
|
||||
await syntheticPage.getByTestId("capture-annotation-workbench").waitFor();
|
||||
await syntheticPage.waitForFunction(
|
||||
() =>
|
||||
document.querySelectorAll("video").length === 2 &&
|
||||
[...document.querySelectorAll("video")].every((video) => video.videoWidth > 0 && video.readyState >= 2),
|
||||
null,
|
||||
{ timeout: 60_000 },
|
||||
);
|
||||
const syntheticGeometry = () =>
|
||||
syntheticPage.evaluate(() =>
|
||||
[...document.querySelectorAll("video")].map((video) => {
|
||||
const rect = video.getBoundingClientRect();
|
||||
const scale = Math.min(rect.width / video.videoWidth, rect.height / video.videoHeight);
|
||||
return {
|
||||
camera: video.dataset.camera,
|
||||
intrinsic: [video.videoWidth, video.videoHeight],
|
||||
box: [rect.width, rect.height],
|
||||
picture: [video.videoWidth * scale, video.videoHeight * scale],
|
||||
fit: getComputedStyle(video).objectFit,
|
||||
};
|
||||
}),
|
||||
);
|
||||
const assertSyntheticContain = (pictures) => {
|
||||
assert.deepEqual(
|
||||
pictures.map((picture) => picture.intrinsic).sort((left, right) => left[0] - right[0]),
|
||||
[
|
||||
[360, 640],
|
||||
[640, 360],
|
||||
],
|
||||
"synthetic pair keeps its distinct portrait and landscape intrinsic sizes",
|
||||
);
|
||||
for (const picture of pictures) {
|
||||
assert.equal(picture.fit, "contain");
|
||||
assert.ok(picture.picture[0] <= picture.box[0] + 0.01 && picture.picture[1] <= picture.box[1] + 0.01);
|
||||
assert.ok(
|
||||
Math.abs(picture.picture[0] / picture.picture[1] - picture.intrinsic[0] / picture.intrinsic[1]) < 0.0001,
|
||||
"synthetic picture keeps its native aspect ratio without crop or distortion",
|
||||
);
|
||||
}
|
||||
};
|
||||
const syntheticDual = await syntheticGeometry();
|
||||
assertSyntheticContain(syntheticDual);
|
||||
await syntheticButton("放大左相机").click();
|
||||
const syntheticLeft = await syntheticGeometry();
|
||||
assertSyntheticContain(syntheticLeft);
|
||||
assert.ok(
|
||||
syntheticLeft[0].picture[0] > syntheticDual[0].picture[0] &&
|
||||
syntheticLeft[0].picture[1] > syntheticDual[0].picture[1],
|
||||
"synthetic left inspection grows the complete picture",
|
||||
);
|
||||
await syntheticButton("放大右相机").click();
|
||||
const syntheticRight = await syntheticGeometry();
|
||||
assertSyntheticContain(syntheticRight);
|
||||
assert.ok(
|
||||
syntheticRight[1].picture[0] > syntheticDual[1].picture[0] &&
|
||||
syntheticRight[1].picture[1] > syntheticDual[1].picture[1],
|
||||
"synthetic right inspection grows the complete picture",
|
||||
);
|
||||
await syntheticButton("恢复双画面").click();
|
||||
assertSyntheticContain(await syntheticGeometry());
|
||||
assert.equal(syntheticWrites.length, 0, "synthetic fit presentation performs no task writes");
|
||||
console.log(
|
||||
"PASS SYNTHETIC-ONLY 16:9 / 9:16 differing-camera contain fit; not real customer coverage",
|
||||
JSON.stringify({ fixtures: fixtureFiles.map((fixture) => fixture.label), dual: syntheticDual }),
|
||||
);
|
||||
await syntheticPage.close();
|
||||
await syntheticContext.close();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await page.screenshot({ path: "local-data/verification/annotation-workspace-layout/task06-error.png" });
|
||||
throw error;
|
||||
} finally {
|
||||
await context.close();
|
||||
await browser.close();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user