⚡ Scope acceptance pools and defer auxiliary reports
This commit is contained in:
parent
88f61c6ff2
commit
979ed87f64
@ -6,7 +6,15 @@
|
||||
- 质检详情仅刷新一次。审核决定保存成功后立即移除当前待处理项并显示结果,任务池后台同步;后台刷新不触发整页阻塞。
|
||||
- 首次进入项目仍有必要的加载状态。切换用户、项目或审核环节后,过期领取/提交响应不会打开或关闭新上下文中的任务。
|
||||
- 质检不请求无关交付包;退回记录独立加载,工时统计进入对应页签才加载。后台错误明确提示并可刷新重试。
|
||||
- 切片标注与管理员页面保留原有主要加载行为。
|
||||
- 切片标注与其他管理员工作台保留原有主要加载行为;管理员的最终验收页采用下述限定范围加载。
|
||||
|
||||
## 验收任务池(2026-09-29)
|
||||
|
||||
- 最终验收页使用现有 `stageId` 查询参数,分别读取 `prepackage_acceptance` 与历史 `acceptance` 阶段,再按任务 ID 去重、创建时间倒序合并。不同响应中同一任务的版本不同时保留较新版本。任一阶段加载失败都明确报错,不把部分列表当作完整结果。
|
||||
- 管理员只读取这两个阶段的 `all` 池,再从服务器已授权返回的记录中得到可领取和本人任务;普通终审员只读取两个阶段各自的 `available`、`mine` 池。组织、项目、供应商与角色权限仍由服务端校验,不新增接口或放宽权限。
|
||||
- “可领取/我的任务/全部任务”在已加载列表内切换,不重新读取项目。领取响应继续即时更新归属;手动刷新仍会重新读取服务器。
|
||||
- 验收页的工时统计、退回记录进入对应页签才请求,不占用首屏任务池加载。切换项目后丢弃旧项目的慢响应。
|
||||
- 历史验收任务、标注任务及交付包读取路径继续保留;非“全部任务”视图仍只显示待验收交付包。没有迁移或改写客户任务、审核意见、标注 JSON,也没有改变验收提交规则。回退前端不需要回退数据。
|
||||
|
||||
## 验收首屏
|
||||
|
||||
@ -32,4 +40,12 @@
|
||||
|
||||
浏览器用实际组件和应用路由、受控的慢接口,验证质检/验收领取与提交不依赖慢任务池或统计、首个验收切片先于最后一页可播放、证据齐全前批准禁用。API 测试覆盖 450 文件的分页复用、并发、过期、版本变化、权限拒绝和缓存后的符号链接替换。
|
||||
|
||||
这些是本地测试,不是 Fanyu 现场耗时。全量前端基线仍有 10 项既有失败(571 通过),本次无新增失败。
|
||||
### 2026-09-29 任务池优化验证
|
||||
|
||||
- `node tests/browser/acceptance-pool-loading.mjs`:实际应用与 API 封装,覆盖管理员/终审员、新旧阶段、任务池切换不重载、报表延迟不阻塞、跨项目慢响应隔离及历史阶段失败提示。使用本地合成响应,不调用生产写接口;可用 `BROWSER_PATH` 指定浏览器。
|
||||
- 独立本地 Mongo 数据库和 API 实测:管理员/终审员分阶段任务池返回正确,无权限项目不返回记录,普通终审员访问 `all` 池返回 403。
|
||||
- 验收证据渐进加载浏览器回归通过:首片可先查看,目录完整前不能通过验收。本机使用 Edge 运行原测试,仅替换测试副本的浏览器启动配置。
|
||||
- 类型检查、生产构建通过;全量前端测试 623 项,609 通过、14 项既有失败,逐项名称、位置和失败断言与改动前一致,无新增失败。
|
||||
- 额外 Go 权限回归发现两项当前基线失败:`TestHumanPoolsFollowAnnotatorReviewerStageOwnership` 的旧阶段角色预期,及 `TestAdminCanReassignHumanItemToEligibleWorkerOrReturnItToPool` 的测试用户缺少项目角色。`internal/`、`cmd/`、`go.mod`、`go.sum` 与改动前 HEAD 完全一致;未为本次前端优化修改这些权限规则。
|
||||
|
||||
本次证据保存在本机忽略目录 `local-data/verification/acceptance-loading-fix-20260929/`。这些是本地验证;本次没有部署公司集群,也没有修改客户数据。之前线上只读测得同一项目全阶段查询约 30.5 秒、15.35 MB,而限定新验收阶段查询约 190 ms、280 KB;这是当时单次接口观测,不是本次上线后的整页性能承诺。
|
||||
|
||||
@ -797,6 +797,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
const isManager = isOrganizationAdminRole(role);
|
||||
const reviewOnly =
|
||||
!isManager && (workspaceMode === "quality" || workspaceMode === "clip-quality" || workspaceMode === "acceptance");
|
||||
const acceptanceWorkspace = workspaceMode === "acceptance";
|
||||
const deferReviewReports = reviewOnly || acceptanceWorkspace;
|
||||
// Acceptance pools are loaded together. Switching their local view must not
|
||||
// reload the same project, evidence prerequisites and package history.
|
||||
const projectPoolView = acceptanceWorkspace ? "all" : taskPoolView;
|
||||
const projectDataScope = JSON.stringify([
|
||||
currentUser?.id,
|
||||
role,
|
||||
@ -943,7 +948,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
|
||||
const loadProject = useCallback(async () => {
|
||||
const requestID = ++projectLoadRequestRef.current;
|
||||
const foreground = !reviewOnly || loadedProjectScope.current !== projectDataScope;
|
||||
const foreground = !deferReviewReports || loadedProjectScope.current !== projectDataScope;
|
||||
setLoading(foreground);
|
||||
setRefreshingProject(!foreground);
|
||||
setProjectLoadError("");
|
||||
@ -977,14 +982,25 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
return;
|
||||
}
|
||||
const knownProjects = projects.length > 0 ? projects : await projectsApi.list();
|
||||
const humanFilters = {
|
||||
pluginId: "annotation-qa",
|
||||
projectId: projectId || undefined,
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
};
|
||||
const poolsRequest = acceptanceWorkspace
|
||||
? humanLoopApi.listAcceptancePools(humanFilters, currentUser?.id || "", isManager)
|
||||
: Promise.all([
|
||||
humanLoopApi.listItems({ ...humanFilters, pool: "available" }),
|
||||
humanLoopApi.listItems({ ...humanFilters, pool: "mine" }),
|
||||
isManager ? humanLoopApi.listItems({ ...humanFilters, pool: "all" }) : Promise.resolve([]),
|
||||
]).then(([available, mine, all]) => ({ available, mine, all }));
|
||||
const [
|
||||
nextProjectMembers,
|
||||
nextWorkflows,
|
||||
nextTemplates,
|
||||
nextTasks,
|
||||
availableHumanItems,
|
||||
myHumanItems,
|
||||
allHumanItems,
|
||||
nextHumanPools,
|
||||
nextWorkload,
|
||||
nextRejects,
|
||||
nextPackages,
|
||||
@ -1008,31 +1024,9 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
nodeId: requestedNodeId || undefined,
|
||||
artifactId: requestedArtifactId || undefined,
|
||||
}),
|
||||
humanLoopApi.listItems({
|
||||
pluginId: "annotation-qa",
|
||||
projectId: projectId || undefined,
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
pool: "available",
|
||||
}),
|
||||
humanLoopApi.listItems({
|
||||
pluginId: "annotation-qa",
|
||||
projectId: projectId || undefined,
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
pool: "mine",
|
||||
}),
|
||||
isManager
|
||||
? humanLoopApi.listItems({
|
||||
pluginId: "annotation-qa",
|
||||
projectId: projectId || undefined,
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
pool: "all",
|
||||
})
|
||||
: Promise.resolve([] as HumanItem[]),
|
||||
reviewOnly ? Promise.resolve(null) : annotationOperationsApi.workloadSummary(projectId || undefined),
|
||||
reviewOnly
|
||||
poolsRequest,
|
||||
deferReviewReports ? Promise.resolve(null) : annotationOperationsApi.workloadSummary(projectId || undefined),
|
||||
deferReviewReports
|
||||
? Promise.resolve(null)
|
||||
: humanLoopApi.listRejects({
|
||||
projectId: projectId || undefined,
|
||||
@ -1045,7 +1039,7 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
projectId: projectId || undefined,
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
status: taskPoolView === "all" ? undefined : "pending_acceptance",
|
||||
status: projectPoolView === "all" ? undefined : "pending_acceptance",
|
||||
}),
|
||||
isManager && requestedRunId ? runsApi.get(requestedRunId) : Promise.resolve(null),
|
||||
]);
|
||||
@ -1061,11 +1055,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
),
|
||||
);
|
||||
setHumanPools({
|
||||
available: availableHumanItems.filter((i) => !submittedItemIdsRef.current.has(i.id)),
|
||||
mine: myHumanItems.map((i) =>
|
||||
available: nextHumanPools.available.filter((i) => !submittedItemIdsRef.current.has(i.id)),
|
||||
mine: nextHumanPools.mine.map((i) =>
|
||||
submittedItemIdsRef.current.has(i.id) ? { ...i, status: "ready", currentStageId: "quality_review" } : i,
|
||||
),
|
||||
all: allHumanItems,
|
||||
all: nextHumanPools.all,
|
||||
});
|
||||
if (nextWorkload) setWorkload(nextWorkload);
|
||||
if (nextRejects) setRejects(nextRejects);
|
||||
@ -1117,16 +1111,18 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
isManager,
|
||||
projectDataScope,
|
||||
reviewOnly,
|
||||
acceptanceWorkspace,
|
||||
deferReviewReports,
|
||||
workspaceMode,
|
||||
requestedArtifactId,
|
||||
requestedNodeId,
|
||||
requestedRunId,
|
||||
requestedWorkflowId,
|
||||
taskPoolView,
|
||||
projectPoolView,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!reviewOnly) return;
|
||||
if (!deferReviewReports) return;
|
||||
let disposed = false;
|
||||
setReviewAuxiliaryError("");
|
||||
setReviewAuxiliaryLoading(true);
|
||||
@ -1135,11 +1131,14 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
workflowId: requestedWorkflowId || undefined,
|
||||
runId: requestedRunId || undefined,
|
||||
};
|
||||
const reports = [
|
||||
humanLoopApi.listRejects(filters).then((value) => {
|
||||
if (!disposed) setRejects(value);
|
||||
}),
|
||||
];
|
||||
const reports = [];
|
||||
// Acceptance does not use rejection history to render a current task.
|
||||
if (!acceptanceWorkspace || tab === "rejects")
|
||||
reports.push(
|
||||
humanLoopApi.listRejects(filters).then((value) => {
|
||||
if (!disposed) setRejects(value);
|
||||
}),
|
||||
);
|
||||
if (tab === "workload")
|
||||
reports.push(
|
||||
annotationOperationsApi.workloadSummary(projectId || undefined).then((value) => {
|
||||
@ -1155,12 +1154,12 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
return () => {
|
||||
disposed = true;
|
||||
};
|
||||
}, [reviewOnly, projectDataScope, tab, projectLoadRetryVersion]);
|
||||
}, [deferReviewReports, acceptanceWorkspace, projectDataScope, tab, projectLoadRetryVersion]);
|
||||
|
||||
const applyReviewClaim = (item: HumanItem) => {
|
||||
// The claim response is authoritative. Do not start a queue reload that
|
||||
// would compete with detail/evidence requests for browser connections.
|
||||
if (taskPoolView !== "mine") skipClaimPoolReload.current = projectDataScope;
|
||||
if (!acceptanceWorkspace && taskPoolView !== "mine") skipClaimPoolReload.current = projectDataScope;
|
||||
++projectLoadRequestRef.current;
|
||||
setLoading(false);
|
||||
setRefreshingProject(false);
|
||||
@ -1768,27 +1767,29 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
// any pause latches the scope so recovery stays manual.
|
||||
const reviewAutoEntryReady = Boolean(
|
||||
reviewOnly &&
|
||||
reviewSessionEnabled &&
|
||||
// Legacy-protocol tasks keep manual-only review: an explicit entry must
|
||||
// never send a continuation start the task cannot support, and the
|
||||
// resulting session error would invalidate a usable legacy review.
|
||||
reviewReceiptSupported &&
|
||||
reviewSession.writable &&
|
||||
!viewportPaused &&
|
||||
!reviewWindowUndersized &&
|
||||
!reviewDecision.pending &&
|
||||
!reviewDraft.dirty &&
|
||||
!reviewContinuation.busy &&
|
||||
(workspaceMode === "acceptance"
|
||||
? expandedDeliveryPackageId && reviewSessionItem && expandedDeliveryPackageId === reviewSessionItem.id
|
||||
: detail?.humanItem && detail.humanItem.id === reviewSessionItem?.id),
|
||||
reviewSessionEnabled &&
|
||||
// Legacy-protocol tasks keep manual-only review: an explicit entry must
|
||||
// never send a continuation start the task cannot support, and the
|
||||
// resulting session error would invalidate a usable legacy review.
|
||||
reviewReceiptSupported &&
|
||||
reviewSession.writable &&
|
||||
!viewportPaused &&
|
||||
!reviewWindowUndersized &&
|
||||
!reviewDecision.pending &&
|
||||
!reviewDraft.dirty &&
|
||||
!reviewContinuation.busy &&
|
||||
(workspaceMode === "acceptance"
|
||||
? expandedDeliveryPackageId && reviewSessionItem && expandedDeliveryPackageId === reviewSessionItem.id
|
||||
: detail?.humanItem && detail.humanItem.id === reviewSessionItem?.id),
|
||||
);
|
||||
const reviewEntryItemId = reviewSessionEnabled ? reviewSessionItem?.id || "" : "";
|
||||
// Prune uses the item the user is actually navigating to, never the async
|
||||
// detail/session state of the previous task: while entering B, a stale A
|
||||
// context must neither consume nor drop B's fresh entry intent.
|
||||
const reviewSelectedItemId =
|
||||
workspaceMode === "acceptance" ? expandedDeliveryPackageId || requestedAcceptanceId : selectedTaskId || requestedTaskId;
|
||||
workspaceMode === "acceptance"
|
||||
? expandedDeliveryPackageId || requestedAcceptanceId
|
||||
: selectedTaskId || requestedTaskId;
|
||||
const reviewSelectedHumanItemId =
|
||||
workspaceMode === "acceptance"
|
||||
? reviewSelectedItemId
|
||||
@ -1902,10 +1903,11 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
() =>
|
||||
deliveryPackages.filter((item) => {
|
||||
if (taskPoolView === "all") return true;
|
||||
if (acceptanceWorkspace && item.status !== "pending_acceptance") return false;
|
||||
if (taskPoolView === "mine") return item.assignedUserId === currentUser?.id;
|
||||
return !item.assignedUserId;
|
||||
}),
|
||||
[currentUser?.id, deliveryPackages, taskPoolView],
|
||||
[currentUser?.id, deliveryPackages, taskPoolView, acceptanceWorkspace],
|
||||
);
|
||||
const visibleTasks = useMemo(() => {
|
||||
const taskIds = new Set(visiblePoolItems.map((item) => item.legacyTaskId).filter(Boolean));
|
||||
@ -4463,8 +4465,12 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
data-workspace-compact={focusedStageLayout || undefined}
|
||||
>
|
||||
<div className="flex justify-end text-xs">
|
||||
<a className="text-slate-500 hover:text-blue-600" target="_blank" rel="noopener noreferrer"
|
||||
href={`/diagnostics?${new URLSearchParams({ itemId: reviewSessionItem?.id || detail?.humanItem?.id || selectedHumanItem?.id || "", taskId: detail?.task?.id || selectedTaskId || "" })}`}>
|
||||
<a
|
||||
className="text-slate-500 hover:text-blue-600"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href={`/diagnostics?${new URLSearchParams({ itemId: reviewSessionItem?.id || detail?.humanItem?.id || selectedHumanItem?.id || "", taskId: detail?.task?.id || selectedTaskId || "" })}`}
|
||||
>
|
||||
当前任务连接诊断
|
||||
</a>
|
||||
</div>
|
||||
@ -4547,12 +4553,12 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{reviewOnly && refreshingProject && (
|
||||
{deferReviewReports && refreshingProject && (
|
||||
<p role="status" data-testid="review-background-refresh" className="text-xs text-slate-500">
|
||||
正在后台更新任务列表,当前任务可继续操作。
|
||||
</p>
|
||||
)}
|
||||
{reviewOnly && reviewAuxiliaryError && (
|
||||
{deferReviewReports && reviewAuxiliaryError && (
|
||||
<p role="alert" className="text-sm text-amber-700">
|
||||
{reviewAuxiliaryError}
|
||||
</p>
|
||||
@ -5969,9 +5975,17 @@ export default function AnnotationOperations({ workPage = false }: { workPage?:
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{reviewOnly && reviewAuxiliaryLoading && tab === "workload" && <p role="status">正在加载工作记录…</p>}
|
||||
{tab === "workload" ? <WorkforceStatisticsPanel items={workload.items} totals={workload.totals}
|
||||
from={workload.from} to={workload.to} projectId={projectId || undefined} surface="workload" /> : null}
|
||||
{deferReviewReports && reviewAuxiliaryLoading && tab === "workload" && <p role="status">正在加载工作记录…</p>}
|
||||
{tab === "workload" ? (
|
||||
<WorkforceStatisticsPanel
|
||||
items={workload.items}
|
||||
totals={workload.totals}
|
||||
from={workload.from}
|
||||
to={workload.to}
|
||||
projectId={projectId || undefined}
|
||||
surface="workload"
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{showResliceWarning ? (
|
||||
<div
|
||||
|
||||
@ -22,9 +22,43 @@ const queryString = (filters: Record<string, string | undefined>) => {
|
||||
return query ? `?${query}` : "";
|
||||
};
|
||||
|
||||
const listItems = async (filters: HumanItemFilters = {}) =>
|
||||
(await apiRequest<{ items: HumanItem[] }>(`/api/human-items${queryString(filters)}`)).items;
|
||||
|
||||
async function listAcceptancePool(filters: HumanItemFilters) {
|
||||
// Keep the legacy package acceptance stage alongside prepackage acceptance.
|
||||
// Both requests retain the server's actor, project and supplier checks.
|
||||
const pages = await Promise.all(
|
||||
["acceptance", "prepackage_acceptance"].map((stageId) => listItems({ ...filters, stageId })),
|
||||
);
|
||||
const items = new Map<string, HumanItem>();
|
||||
for (const item of pages.flat()) {
|
||||
if (!items.has(item.id) || item.version > items.get(item.id)!.version) items.set(item.id, item);
|
||||
}
|
||||
return [...items.values()].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
||||
}
|
||||
|
||||
export const humanLoopApi = {
|
||||
listItems: async (filters: HumanItemFilters = {}) =>
|
||||
(await apiRequest<{ items: HumanItem[] }>(`/api/human-items${queryString(filters)}`)).items,
|
||||
listItems,
|
||||
listAcceptancePools: async (
|
||||
filters: Omit<HumanItemFilters, "stageId" | "pool">,
|
||||
actorId: string,
|
||||
manager: boolean,
|
||||
) => {
|
||||
if (manager) {
|
||||
const all = await listAcceptancePool({ ...filters, pool: "all" });
|
||||
return {
|
||||
all,
|
||||
available: all.filter((item) => !item.assignedUserId && ["ready", "submitted", "rework"].includes(item.status)),
|
||||
mine: all.filter((item) => item.assignedUserId === actorId),
|
||||
reviewed: [],
|
||||
};
|
||||
}
|
||||
const [available, mine] = await Promise.all(
|
||||
["available", "mine"].map((pool) => listAcceptancePool({ ...filters, pool: pool as "available" | "mine" })),
|
||||
);
|
||||
return { available, mine, all: [], reviewed: [] };
|
||||
},
|
||||
getItem: (id: string) =>
|
||||
apiRequest<{
|
||||
item: HumanItem;
|
||||
|
||||
196
tests/browser/acceptance-pool-loading.mjs
Normal file
196
tests/browser/acceptance-pool-loading.mjs
Normal file
@ -0,0 +1,196 @@
|
||||
// Actual app/API wrapper with local synthetic responses only.
|
||||
import assert from "node:assert/strict";
|
||||
import { createServer } from "vite";
|
||||
import { chromium } from "playwright";
|
||||
|
||||
const server = await createServer({ server: { host: "127.0.0.1", port: 5198, strictPort: true } });
|
||||
await server.listen();
|
||||
const base = server.resolvedUrls.local[0];
|
||||
const browser = await chromium.launch({
|
||||
executablePath: process.env.BROWSER_PATH || "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
||||
headless: true,
|
||||
args: ["--no-proxy-server"],
|
||||
});
|
||||
const deferred = () => {
|
||||
let resolve;
|
||||
const promise = new Promise((r) => (resolve = r));
|
||||
return { promise, resolve };
|
||||
};
|
||||
|
||||
async function fixture(role, { holdProject = false, failLegacy = false } = {}) {
|
||||
const ctx = await browser.newContext({ viewport: { width: 1600, height: 1000 } });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(30000);
|
||||
const held = deferred(),
|
||||
reports = deferred();
|
||||
const calls = [],
|
||||
errors = [];
|
||||
const user = { id: "reviewer", role, status: "active", organizationId: "org", name: "Test reviewer" };
|
||||
const project = (id) => ({ id, name: id, status: "active", organizationId: "org" });
|
||||
const item = (projectId, stage) => ({
|
||||
id: `${projectId}-${stage}`,
|
||||
organizationId: "org",
|
||||
pluginId: "annotation-qa",
|
||||
projectId,
|
||||
workflowId: "workflow",
|
||||
runId: "run",
|
||||
version: 1,
|
||||
currentRevision: 1,
|
||||
createdAt: stage === "acceptance" ? "2026-09-28T00:00:00Z" : "2026-09-29T00:00:00Z",
|
||||
currentStageId: stage,
|
||||
status: stage === "acceptance" ? "claimed" : "ready",
|
||||
assignedUserId: stage === "acceptance" ? user.id : undefined,
|
||||
legacyTaskId: stage === "acceptance" ? `${projectId}-legacy` : undefined,
|
||||
processingProfile: "raw_human",
|
||||
display: { projectName: projectId, captureDirectories: [`${projectId}-${stage}`] },
|
||||
subject: { payload: { captureDirectory: `${projectId}-${stage}`, items: [] } },
|
||||
});
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await ctx.route("**/*", async (route) => {
|
||||
const req = route.request(),
|
||||
url = new URL(req.url()),
|
||||
path = url.pathname;
|
||||
if (!path.startsWith("/api/") && !path.startsWith("/worker-api/")) return route.continue();
|
||||
const json = (data) => route.fulfill({ json: data });
|
||||
calls.push({ path, query: Object.fromEntries(url.searchParams), method: req.method() });
|
||||
assert.equal(req.method(), "GET", "queue verification must not write");
|
||||
if (path === "/api/auth/me") return json({ user, organization: { id: "org", name: "Synthetic" } });
|
||||
if (path === "/api/plugins")
|
||||
return json({ items: [{ enabled: true, manifest: { id: "annotation-qa", name: "标注", version: "1" } }] });
|
||||
if (path.includes("ready") || path.includes("health"))
|
||||
return json({ ready: true, status: "ok", buildCommit: "test" });
|
||||
if (path === "/api/projects") return json({ items: [project("project-a"), project("project-b")] });
|
||||
if (path.endsWith("/members") && path.startsWith("/api/projects/"))
|
||||
return json({ items: [{ id: "member", projectId: path.split("/")[3], userId: user.id, roles: [role] }] });
|
||||
if (path.endsWith("/workflows"))
|
||||
return json({ items: [{ id: "workflow", name: "Workflow", nodes: [], edges: [] }] });
|
||||
if (path === "/api/human-rejects" || path.endsWith("/workload-summary")) {
|
||||
await reports.promise;
|
||||
return json({ items: [], eventCount: 0 });
|
||||
}
|
||||
if (path === "/api/plugins/annotation-qa/tasks") {
|
||||
const projectId = url.searchParams.get("projectId") || "project-a";
|
||||
return json({
|
||||
items: [
|
||||
{
|
||||
id: `${projectId}-legacy`,
|
||||
projectId,
|
||||
organizationId: "org",
|
||||
workflowId: "workflow",
|
||||
runId: "run",
|
||||
templateId: "template",
|
||||
templateVersion: 6,
|
||||
currentRevision: 1,
|
||||
status: "pending_acceptance",
|
||||
humanStageId: "acceptance",
|
||||
assignedUserId: user.id,
|
||||
clipStart: 0,
|
||||
clipEnd: 10,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
if (path === "/api/human-items") {
|
||||
const projectId = url.searchParams.get("projectId") || "project-a";
|
||||
const stage = url.searchParams.get("stageId"),
|
||||
pool = url.searchParams.get("pool");
|
||||
if (holdProject && projectId === "project-a") await held.promise;
|
||||
if (failLegacy && stage === "acceptance") return route.fulfill({ status: 403, json: { error: "legacy denied" } });
|
||||
const items = [item(projectId, "prepackage_acceptance"), item(projectId, "acceptance")]
|
||||
.filter((i) => !stage || i.currentStageId === stage)
|
||||
.filter((i) => pool === "all" || (pool === "mine" ? i.assignedUserId === user.id : !i.assignedUserId));
|
||||
return json({ items });
|
||||
}
|
||||
return json({ items: [], labelIds: [], sliceLabelIds: [] });
|
||||
});
|
||||
const close = async () => {
|
||||
held.resolve();
|
||||
reports.resolve();
|
||||
await ctx.close();
|
||||
};
|
||||
return { page, calls, errors, held, reports, close };
|
||||
}
|
||||
|
||||
try {
|
||||
for (const role of ["admin", "acceptance_reviewer"]) {
|
||||
const f = await fixture(role);
|
||||
try {
|
||||
await f.page.goto(base + "plugins/annotation-qa/workflows/all/acceptance?projectId=project-a", {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
const available = f.page.getByTestId("human-task-pool-available");
|
||||
const mine = f.page.getByTestId("human-task-pool-mine");
|
||||
await available.filter({ hasText: /1/ }).waitFor();
|
||||
await mine.filter({ hasText: /1/ }).waitFor();
|
||||
const poolCalls = () => f.calls.filter((r) => r.path === "/api/human-items");
|
||||
const initial = poolCalls().length;
|
||||
const expected = role === "admin" ? 2 : 4;
|
||||
assert.equal(new Set(poolCalls().map((r) => `${r.query.pool}:${r.query.stageId}`)).size, expected);
|
||||
assert.ok(initial <= expected * 2, "only the initial React development StrictMode replay may duplicate requests");
|
||||
assert.ok(poolCalls().every((r) => ["acceptance", "prepackage_acceptance"].includes(r.query.stageId)));
|
||||
assert.ok(poolCalls().every((r) => (role === "admin" ? r.query.pool === "all" : r.query.pool !== "all")));
|
||||
assert.equal(
|
||||
f.calls.filter((r) => r.path === "/api/human-rejects" || r.path.endsWith("/workload-summary")).length,
|
||||
0,
|
||||
);
|
||||
await mine.click();
|
||||
await f.page.locator('[data-task-id="project-a-legacy"]').waitFor();
|
||||
if (role === "admin") await f.page.getByTestId("human-task-pool-all").click();
|
||||
await available.click();
|
||||
await f.page
|
||||
.locator(".annotation-task-list")
|
||||
.getByRole("button", { name: /project-a-prepackage_acceptance/ })
|
||||
.waitFor();
|
||||
await f.page.waitForTimeout(200);
|
||||
assert.equal(poolCalls().length, initial, "switching pools must not reload the project");
|
||||
if (role === "admin") {
|
||||
const view = f.page.getByRole("combobox", { name: "当前工作台视图" });
|
||||
await view.selectOption("workload");
|
||||
await f.page.getByText("正在加载工作记录…", { exact: true }).waitFor();
|
||||
assert.equal(f.calls.filter((r) => r.path.endsWith("/workload-summary")).length, 1);
|
||||
await view.selectOption("queue");
|
||||
await available.filter({ hasText: /1/ }).waitFor();
|
||||
await view.selectOption("rejects");
|
||||
await f.page.waitForTimeout(100);
|
||||
assert.equal(f.calls.filter((r) => r.path === "/api/human-rejects").length, 1);
|
||||
await view.selectOption("queue");
|
||||
assert.equal(poolCalls().length, initial, "slow reports do not reload or block the task pool");
|
||||
}
|
||||
assert.deepEqual(f.errors, []);
|
||||
console.log("PASS", role, "scoped stages, legacy task, permissions, stable pool navigation, deferred reports");
|
||||
} finally {
|
||||
await f.close();
|
||||
}
|
||||
}
|
||||
const stale = await fixture("admin", { holdProject: true });
|
||||
try {
|
||||
await stale.page.goto(base + "plugins/annotation-qa/workflows/all/acceptance?projectId=project-a", {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await stale.page.getByRole("combobox", { name: "1. 项目", exact: true }).selectOption("project-b");
|
||||
await stale.page.getByTestId("human-task-pool-available").filter({ hasText: /1/ }).waitFor();
|
||||
stale.held.resolve();
|
||||
await stale.page.waitForTimeout(250);
|
||||
assert.ok(
|
||||
(await stale.page.locator(".annotation-task-list").innerText()).includes("project-b-prepackage_acceptance"),
|
||||
);
|
||||
assert.ok(!(await stale.page.locator(".annotation-task-list").innerText()).includes("project-a-"));
|
||||
console.log("PASS stale project responses cannot overwrite current acceptance pool");
|
||||
} finally {
|
||||
await stale.close();
|
||||
}
|
||||
const failed = await fixture("acceptance_reviewer", { failLegacy: true });
|
||||
try {
|
||||
await failed.page.goto(base + "plugins/annotation-qa/workflows/all/acceptance?projectId=project-a", {
|
||||
waitUntil: "domcontentloaded",
|
||||
});
|
||||
await failed.page.getByRole("alert").filter({ hasText: "任务加载失败" }).waitFor();
|
||||
assert.equal(await failed.page.getByRole("button", { name: "领取任务", exact: true }).count(), 0);
|
||||
console.log("PASS legacy stage failure is reported, not silently accepted as an empty pool");
|
||||
} finally {
|
||||
await failed.close();
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
await server.close();
|
||||
}
|
||||
@ -176,7 +176,8 @@ test("annotation operations uses the draggable video timeline and workflow deep
|
||||
assert.match(page, /captureDirectoriesFromHumanTask/);
|
||||
assert.doesNotMatch(page, /默认仅显示待处理任务/);
|
||||
assert.match(page, /runId: requestedRunId \|\| undefined/);
|
||||
assert.match(page, /status: taskPoolView === "all" \? undefined : "pending_acceptance"/);
|
||||
assert.match(page, /status: projectPoolView === "all" \? undefined : "pending_acceptance"/);
|
||||
assert.match(page, /acceptanceWorkspace && item.status !== "pending_acceptance"/);
|
||||
assert.match(page, /!isManager && current === "all" \? "available" : current/);
|
||||
assert.doesNotMatch(page, /current === "available" \? "all"/);
|
||||
assert.match(page, /visibleDeliveryPackages/);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user