forked from longtao.wu/droboticflow
Six follow-ups from the round8-12 hotfix retrospective: - web-ci.yml: lint + Go/frontend tests on every push and PR (nothing ran app checks before; the round10 dev-mode regression shipped green) - tests/known-failures.json + check-test-baseline.mjs: gate by exact failing-test id instead of hand-counted failure totals (14 frontend, 70 Go upstream debts recorded from the dev tip) - devboot.test.mjs: boots the real Vite dev server and pins the movi loader contract that broke round10 (query-less DEV url, /vendor stays off the module pipeline) - scripts/local/smoke-workbench.mjs: pre-release smoke covering the seven recurring acceptance points (login/pool/claim/play-while-loading/ captions/4x/playhead), 3x green against the local replica - docs/CODING_STANDARDS.md + AGENTS pointer: eligibility flags are server-shipped, the UI renders them (rounds 9+12 lesson) - vendor README host-element quirks section, HANDOFF gate pointers and movi-path verification rule, perf-audit report pinned with the post-round12 production 500 observation - husky pre-commit: lint-staged (repo prettier scope) + tsc + gofmt - gofmt: restore lint:go green on the dev tip (drift shipped silently in the perf merge and round12 because nothing gated it)
246 lines
10 KiB
JavaScript
246 lines
10 KiB
JavaScript
#!/usr/bin/env node
|
||
// Pre-release workbench smoke against the LOCAL replica stack only.
|
||
//
|
||
// Covers the seven acceptance points that recurred across the 2026-10-12
|
||
// hotfix rounds 8-12, replacing per-round hand-written probe scripts:
|
||
// 1 reviewer login 2 quality pool renders
|
||
// 3 random claim works 4 play-while-loading starts without a drag
|
||
// 5 caption overlay on claimed task (movi path, not the native fallback)
|
||
// 6 4x rate selectable 7 playhead advances while playing
|
||
//
|
||
// Prereqs (see docs/HANDOFF.md §2): snapshot Mongo on 27018, API on 3001
|
||
// (source scripts/local/env-local-snapshot.sh && npm run dev:api), vite dev
|
||
// on 5173 (npx vite --port 5173 --strictPort), and a Chromium/Edge binary.
|
||
//
|
||
// node scripts/local/smoke-workbench.mjs
|
||
//
|
||
// Env: LOCAL_TEST_PASSWORD (default Test1234!local), BROWSER_EXECUTABLE,
|
||
// REPRO_URL (default http://localhost:5173). The random claim WRITES a claim
|
||
// into the local snapshot replica — never point REPRO_URL at a cluster.
|
||
import { chromium } from "playwright";
|
||
|
||
const base = process.env.REPRO_URL || "http://localhost:5173";
|
||
const phone = "local-test-user-workspace-layout-qc-reviewer";
|
||
const password = process.env.LOCAL_TEST_PASSWORD || "Test1234!local";
|
||
|
||
const results = [];
|
||
const step = (name, status, evidence) => {
|
||
results.push({ name, status, evidence });
|
||
console.log(`${status === "PASS" ? "✔" : status === "FAIL" ? "✖" : "⚠"} ${name}: ${evidence}`);
|
||
};
|
||
|
||
async function preflight() {
|
||
const problems = [];
|
||
for (const [label, url] of [
|
||
["API 3001", "http://127.0.0.1:3001/api/health"],
|
||
["web 5173", `${base}/`],
|
||
]) {
|
||
try {
|
||
const res = await fetch(url, { signal: AbortSignal.timeout(3000) });
|
||
if (!res.ok) problems.push(`${label} unhealthy (${res.status})`);
|
||
} catch {
|
||
problems.push(`${label} unreachable — start the stack per docs/HANDOFF.md §2/§3`);
|
||
}
|
||
}
|
||
if (problems.length) {
|
||
console.error("preflight failed:\n " + problems.join("\n "));
|
||
process.exit(2);
|
||
}
|
||
}
|
||
|
||
function findBrowser() {
|
||
if (process.env.BROWSER_EXECUTABLE) return process.env.BROWSER_EXECUTABLE;
|
||
for (const candidate of [
|
||
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
||
"/usr/bin/chromium",
|
||
"/usr/bin/google-chrome",
|
||
]) {
|
||
try {
|
||
require("node:fs").accessSync(candidate);
|
||
return candidate;
|
||
} catch {
|
||
// try next
|
||
}
|
||
}
|
||
return undefined; // playwright bundled chromium
|
||
}
|
||
|
||
async function findVideoElement(page) {
|
||
return page.evaluate(() => {
|
||
const host = document.querySelector("movi-player");
|
||
const shadowVideo = host?.shadowRoot?.querySelector("video");
|
||
const native = document.querySelector("video");
|
||
const video = shadowVideo || native;
|
||
return video
|
||
? { path: shadowVideo ? "movi-shadow" : "native", paused: video.paused, time: video.currentTime }
|
||
: null;
|
||
});
|
||
}
|
||
|
||
async function main() {
|
||
await preflight();
|
||
const browser = await chromium.launch({
|
||
...(findBrowser() ? { executablePath: findBrowser() } : {}),
|
||
headless: true,
|
||
args: ["--no-proxy-server"],
|
||
});
|
||
const context = await browser.newContext({ viewport: { width: 1500, height: 900 } });
|
||
const page = await context.newPage();
|
||
page.setDefaultTimeout(30000);
|
||
const pageErrors = [];
|
||
page.on("pageerror", (e) => pageErrors.push(e.message));
|
||
|
||
try {
|
||
// 1) login
|
||
await page.goto(`${base}/login`, { waitUntil: "domcontentloaded" });
|
||
await page.fill("input[type='text'], input[name='identifier'], input[placeholder*='手机']", phone);
|
||
await page.fill("input[type='password']", password);
|
||
await page.click("button:has-text('登录')");
|
||
await page.waitForTimeout(4000);
|
||
const loggedIn = !(await page.locator("input[type='password']").count());
|
||
step("login (qc reviewer)", loggedIn ? "PASS" : "FAIL", loggedIn ? "session established" : "still on login form");
|
||
if (!loggedIn) throw new Error("login failed — check LOCAL_TEST_PASSWORD");
|
||
|
||
// 2) quality pool
|
||
await page.goto(`${base}/plugins/annotation-qa/workflows/all/quality`, { waitUntil: "domcontentloaded" });
|
||
await page.waitForTimeout(9000);
|
||
const poolCards = await page.locator("[data-testid='annotation-task-card']").count();
|
||
step("quality pool renders", "PASS", `${poolCards} pool card(s) visible`);
|
||
|
||
// 3) random claim
|
||
const claimButton = page.locator("button", { hasText: "随机领取" }).first();
|
||
let enteredSession = false;
|
||
if (await claimButton.count()) {
|
||
await claimButton.click();
|
||
await page.waitForTimeout(8000);
|
||
const body = (await page.locator("main").textContent()) || "";
|
||
const video = await findVideoElement(page);
|
||
enteredSession = Boolean(video) || /继续处理|当前切片|画面标注/.test(body);
|
||
if (enteredSession) {
|
||
step("random claim", "PASS", "entered a review session");
|
||
} else if (body.includes("没有领取权限")) {
|
||
step("random claim", "PASS", "explicit no-permission notice (server-shipped flag)");
|
||
} else if (body.includes("当前暂无可领取") && poolCards > 0) {
|
||
step("random claim", "FAIL", `misleading empty notice while pool shows ${poolCards} card(s) (round12 class)`);
|
||
} else {
|
||
step("random claim", "FAIL", "no session, no explicit notice");
|
||
}
|
||
} else {
|
||
step("random claim", "FAIL", "随机领取 button not visible in the workbench (round9 class)");
|
||
}
|
||
|
||
// 4-7) video checks inside the claimed session
|
||
let video = await findVideoElement(page);
|
||
if (!video) {
|
||
await page.waitForTimeout(5000);
|
||
video = await findVideoElement(page);
|
||
}
|
||
if (!video) {
|
||
step("video session", "FAIL", "no video element after claim — check wire-local-capture.sh wiring");
|
||
} else {
|
||
step(
|
||
"player engine",
|
||
video.path === "movi-shadow" ? "PASS" : "WARN",
|
||
video.path === "movi-shadow"
|
||
? "movi-player mounted (quirks path)"
|
||
: "native <video> fallback — movi path untested (HANDOFF §4)",
|
||
);
|
||
|
||
// 4) play while loading, without any drag (round11). Session-entry
|
||
// overlays can swallow a single early click, so re-click while the
|
||
// button still reads 播放 (paused) instead of clicking blindly.
|
||
const playButton = page.locator("button[title='播放/暂停(Space,填写文本时不触发)']").first();
|
||
let playing = false;
|
||
let clicks = 0;
|
||
const stateTrail = [];
|
||
for (let i = 0; i < 36 && !playing; i++) {
|
||
const state = await findVideoElement(page);
|
||
if (state) stateTrail.push(`${state.paused ? "paused" : "playing"}@${state.time.toFixed(2)}`);
|
||
if (state && !state.paused && state.time > 0) {
|
||
playing = true;
|
||
break;
|
||
}
|
||
if (i > 0 && i % 5 === 0 && (await playButton.count())) {
|
||
const label = ((await playButton.textContent()) || "").trim();
|
||
if (label === "播放") {
|
||
clicks += 1;
|
||
await playButton.click({ timeout: 3000 }).catch(() => {});
|
||
}
|
||
}
|
||
await page.waitForTimeout(500);
|
||
}
|
||
if (!playing && (await playButton.count())) {
|
||
const label = ((await playButton.textContent()) || "").trim();
|
||
if (label === "播放") {
|
||
clicks += 1;
|
||
await playButton.click({ timeout: 3000 }).catch(() => {});
|
||
for (let i = 0; i < 10 && !playing; i++) {
|
||
await page.waitForTimeout(500);
|
||
const state = await findVideoElement(page);
|
||
if (state) stateTrail.push(`${state.paused ? "paused" : "playing"}@${state.time.toFixed(2)}`);
|
||
if (state && !state.paused && state.time > 0) playing = true;
|
||
}
|
||
}
|
||
}
|
||
step(
|
||
"play-while-loading (round11)",
|
||
playing ? "PASS" : "FAIL",
|
||
playing
|
||
? `playback started after ${clicks} click(s), no timeline drag`
|
||
: `video never played (${clicks} clicks): ${stateTrail.slice(-6).join(" → ")}`,
|
||
);
|
||
|
||
// 5) caption overlay on claimed task (round11/12)
|
||
const body = (await page.locator("main").textContent()) || "";
|
||
step(
|
||
"caption overlay (round11/12)",
|
||
/当前切片|当前画面标注/.test(body) ? "PASS" : "FAIL",
|
||
/当前切片|当前画面标注/.test(body) ? "caption panel present" : "no caption markers found",
|
||
);
|
||
|
||
// 6) 4x rate present (round10) — native select[aria-label=播放速度]
|
||
const rateSelect = page.locator("select[aria-label='播放速度']").first();
|
||
if (await rateSelect.count()) {
|
||
const options = await rateSelect.locator("option").allTextContents();
|
||
const has4x = options.some((t) => /^4(\.0)?×$/.test(t.trim()));
|
||
step(
|
||
"4x rate (round10)",
|
||
has4x ? "PASS" : "FAIL",
|
||
has4x ? `rate options: ${options.join("/")}` : `no 4x in ${options.join("/")}`,
|
||
);
|
||
if (has4x) {
|
||
await rateSelect.selectOption("4");
|
||
await page.waitForTimeout(500);
|
||
}
|
||
} else {
|
||
step("4x rate (round10)", "FAIL", "playback-rate select not found");
|
||
}
|
||
|
||
// 7) playhead advances (round8) — ensure playing first (4x may have re-buffered)
|
||
const playAgain = page.locator("button[title='播放/暂停(Space,填写文本时不触发)']").first();
|
||
if ((await findVideoElement(page))?.paused && (await playAgain.count())) await playAgain.click();
|
||
const first = (await findVideoElement(page))?.time ?? 0;
|
||
await page.waitForTimeout(2500);
|
||
const second = (await findVideoElement(page))?.time ?? 0;
|
||
step(
|
||
"playhead advance (round8)",
|
||
second > first ? "PASS" : "FAIL",
|
||
`currentTime ${first.toFixed(2)}s → ${second.toFixed(2)}s`,
|
||
);
|
||
}
|
||
|
||
if (pageErrors.length) step("page errors", "WARN", pageErrors.slice(0, 3).join(" | ").slice(0, 300));
|
||
} finally {
|
||
await browser.close();
|
||
}
|
||
|
||
const failed = results.filter((r) => r.status === "FAIL");
|
||
console.log(
|
||
`\n${failed.length ? "SMOKE FAILED" : "SMOKE PASSED"}: ${results.filter((r) => r.status === "PASS").length} pass, ${results.filter((r) => r.status === "WARN").length} warn, ${failed.length} fail`,
|
||
);
|
||
process.exit(failed.length ? 1 : 0);
|
||
}
|
||
|
||
await main();
|