forked from longtao.wu/droboticflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit c6ddc91b49b688469bfe56386478b96d900863ee)
138 lines
7.5 KiB
JavaScript
138 lines
7.5 KiB
JavaScript
import assert from "node:assert/strict";
|
|
const fixture = "/tests/browser/fixtures/platform-feedback.html";
|
|
export async function runOpinionRoundFocusRegression(tab, origin) {
|
|
await tab.goto(origin + fixture + "?rail");
|
|
const rail = tab.playwright.getByTestId("rework-opinion-rail");
|
|
await rail.getByText("第3轮意见0", { exact: true }).click();
|
|
assert.equal(await rail.locator('[data-rework-focus="true"]').count(), 1, "跨轮同 ID 只能定位到点击的轮次");
|
|
assert.match(await rail.locator('[data-rework-focus="true"]').innerText(), /第3轮意见0/);
|
|
await tab.playwright.evaluate(() => {
|
|
document.querySelector(".capture-rework-rail-scroll").scrollTo({ top: 350, behavior: "instant" });
|
|
});
|
|
const top = await tab.playwright.evaluate(() => document.querySelector(".capture-rework-rail-scroll").scrollTop);
|
|
await tab.playwright.getByRole("button", { name: /页面更新/ }).click();
|
|
assert.equal(
|
|
await tab.playwright.evaluate(() => document.querySelector(".capture-rework-rail-scroll").scrollTop),
|
|
top,
|
|
"无新的定位请求时保留手动滚动",
|
|
);
|
|
await rail.getByText("第1轮意见0", { exact: true }).click();
|
|
assert.equal(await rail.locator('[data-rework-focus="true"]').count(), 1);
|
|
assert.match(await rail.locator('[data-rework-focus="true"]').innerText(), /第1轮意见0/);
|
|
return { roundIdentity: "passed", manualScrollSurvivesRender: "passed" };
|
|
}
|
|
export async function runParkedDraftSliceRegression(tab, origin) {
|
|
await tab.goto(origin + fixture);
|
|
await tab.playwright.evaluate(() => sessionStorage.removeItem("feedback-saved"));
|
|
await tab.goto(origin + fixture);
|
|
const wb = tab.playwright.getByTestId("capture-annotation-workbench");
|
|
await wb.getByRole("listbox", { name: "动作区间", exact: true }).getByRole("option").first().click();
|
|
await wb.getByRole("textbox", { name: "动作描述", exact: true }).fill("合成跨切片草稿");
|
|
await wb.getByRole("combobox", { name: "切片列表", exact: true }).selectOption("s2");
|
|
await wb.focus();
|
|
await tab.pressKey(null, "e");
|
|
await tab.playwright.getByRole("button", { name: "首帧前移1帧", exact: true }).click();
|
|
await tab.playwright.getByTestId("slice-edit-panel-apply").click();
|
|
assert.equal(
|
|
await wb.getByText("请先保存或取消未保存的描述草稿,再应用切片改动。", { exact: true }).count(),
|
|
0,
|
|
"其他切片的完整描述草稿不应全局阻断切片应用",
|
|
);
|
|
// Extending the second slice cuts the first action: the normal conflict UI
|
|
// must see the parked text rather than dropping it or blocking globally.
|
|
const conflicts = tab.playwright.getByTestId("slice-edit-conflict-list");
|
|
if (await conflicts.count()) {
|
|
await tab.playwright.getByRole("button", { name: /1 截断/ }).click();
|
|
await tab.pressKey(null, "Return");
|
|
}
|
|
await tab.playwright.getByTestId("slice-edit-panel").waitFor({ state: "hidden" });
|
|
let state = JSON.parse(await tab.playwright.getByTestId("feedback-state").innerText());
|
|
assert.equal(state.applied, 1);
|
|
assert.equal(state.drafts.length, 0);
|
|
assert.equal(state.actions.find((a) => a.id === "a1" || a.id.startsWith("a1:split:")).description, "合成跨切片草稿");
|
|
assert.equal(state.actions.find((a) => a.id === "a1" || a.id.startsWith("a1:split:")).status, "described");
|
|
await tab.goto(origin + fixture);
|
|
state = JSON.parse(await tab.playwright.getByTestId("feedback-state").innerText());
|
|
assert.equal(
|
|
state.actions.find((a) => a.id === "a1" || a.id.startsWith("a1:split:")).description,
|
|
"合成跨切片草稿",
|
|
"已应用草稿刷新后仍存在",
|
|
);
|
|
for (const mode of ["cancel", "refuse"]) {
|
|
await tab.playwright.evaluate(() => sessionStorage.removeItem("feedback-saved"));
|
|
await tab.goto(origin + fixture + "?" + mode);
|
|
await wb.getByRole("listbox", { name: "动作区间", exact: true }).getByRole("option").first().click();
|
|
await wb.getByRole("textbox", { name: "动作描述", exact: true }).fill("失败和取消都保留的草稿");
|
|
await wb.getByRole("combobox", { name: "切片列表", exact: true }).selectOption("s2");
|
|
await wb.focus();
|
|
await tab.pressKey(null, "e");
|
|
await tab.playwright.getByRole("button", { name: "首帧前移1帧", exact: true }).click();
|
|
if (mode === "cancel") {
|
|
await tab.pressKey(null, "Escape");
|
|
} else {
|
|
await tab.playwright.getByTestId("slice-edit-panel-apply").click();
|
|
await tab.playwright.getByRole("button", { name: /1 截断/ }).click();
|
|
await tab.pressKey(null, "Return");
|
|
await tab.playwright
|
|
.getByText("当前状态暂不能应用切片改动,请稍后重试,或按 Esc 取消。", { exact: true })
|
|
.waitFor({ state: "visible" });
|
|
}
|
|
state = JSON.parse(await tab.playwright.getByTestId("feedback-state").innerText());
|
|
assert.equal(state.applied, 0);
|
|
assert.equal(state.drafts[0].annotation.description, "失败和取消都保留的草稿");
|
|
assert.equal(state.slices[0].end, 4, "失败或取消不能修改原工作区");
|
|
if (mode === "refuse") {
|
|
await tab.pressKey(null, "Return");
|
|
await tab.playwright.getByTestId("slice-edit-panel").waitFor({ state: "hidden" });
|
|
state = JSON.parse(await tab.playwright.getByTestId("feedback-state").innerText());
|
|
assert.equal(state.applied, 1);
|
|
assert.equal(state.drafts.length, 0);
|
|
}
|
|
}
|
|
return {
|
|
parkedDraftParticipatesInConflicts: "passed",
|
|
refreshRetainsText: "passed",
|
|
cancelRetainsDraft: "passed",
|
|
failedSaveAndRetry: "passed",
|
|
};
|
|
}
|
|
|
|
export async function runCaptionVisibilityRegression(tab, origin) {
|
|
await tab.goto(origin + fixture + "?caption");
|
|
const caption = tab.playwright.getByLabel("左相机字幕", { exact: true });
|
|
await caption.waitFor({ state: "visible" });
|
|
assert.match(await caption.innerText(), /测试切片一.*未填写动作描述/);
|
|
const boxes = await tab.playwright.evaluate(() => {
|
|
const box = (selector) => {
|
|
const r = document.querySelector(selector).getBoundingClientRect();
|
|
return { top: r.top, bottom: r.bottom, height: r.height };
|
|
};
|
|
return {
|
|
video: box(".capture-video-surface"),
|
|
caption: box(".review-picture-caption-text"),
|
|
controls: box(".capture-media-controls"),
|
|
};
|
|
});
|
|
assert(boxes.caption.height > 15);
|
|
assert(boxes.caption.top >= boxes.video.top, "字幕位于视频画面内");
|
|
assert(boxes.caption.bottom <= boxes.video.bottom + 1, "字幕位于画面内底部");
|
|
assert(boxes.caption.bottom <= boxes.controls.top + 1, "字幕不覆盖播放控制");
|
|
await tab.playwright.getByRole("button", { name: "invalid", exact: true }).click();
|
|
assert.match(await caption.innerText(), /测试切片一.*无效片段/);
|
|
await tab.playwright.getByRole("button", { name: "described", exact: true }).click();
|
|
assert.match(await caption.innerText(), /合成有效动作描述/);
|
|
await tab.playwright.getByRole("button", { name: "error", exact: true }).click();
|
|
assert.match(await caption.innerText(), /动作证据读取失败/);
|
|
await tab.playwright.getByRole("button", { name: "隐藏字幕", exact: true }).click();
|
|
await caption.waitFor({ state: "hidden" });
|
|
await tab.playwright.getByRole("button", { name: "显示字幕", exact: true }).click();
|
|
await caption.waitFor({ state: "visible" });
|
|
assert.match(await tab.playwright.getByTestId("review-history-summary").innerText(), /旧版本.*新版本 3.*复查/);
|
|
return {
|
|
captionPlacement: "passed",
|
|
emptyInvalidDescribedAndError: "passed",
|
|
visibilityToggle: "passed",
|
|
historyVersions: "passed",
|
|
};
|
|
}
|