
> shuimu-workbench@1.0.0 test
> tsx --test "src/**/!(*InteractiveCard*|*chatWindowArtifact*|*deliverableSync*).test.ts" && vitest run src/components/chat/InteractiveCard.test.ts src/components/chat/chatWindowArtifact.test.ts src/components/chat/deliverableSync.test.ts

✔ AuthClient: 基础登录与 .env 超级管理员鉴权 (1.995041ms)
✔ AuthClient: 自主注册受控流程（仅填用户名密码姓名，职位强制绑定访客待指派） (0.467176ms)
✔ AuthClient: 开启注册需审批时，注册账号处于待审状态并禁止登录 (0.528284ms)
✔ AuthClient: 管理员创建账号必须在首次登录修改密码 (0.323461ms)
✔ mapUserAccount: snake_case Go contract → camelCase (1.033499ms)
✔ mapUserAccount: prefers snake_case when both present (0.197924ms)
✔ mapLoginResult + mapMeResult map nested user and top-level must_change_password (0.902823ms)
✔ mapUserAccountList maps admin users list (0.223613ms)
✔ AuthClient.login + fetchMe map real snake_case wire payloads (26.144283ms)
✔ shouldAutoRetryChat: disabled until idempotency (0.912833ms)
✔ shouldAutoRetryTask: transient only, max 2 (0.194784ms)
✔ shouldAutoRetryTask: document busy never retries (0.110757ms)
✔ shouldAutoRetry alias delegates to task path (0.130287ms)
✔ autoRetryDelayMs: 1s then 2s (0.135606ms)
✔ fallbackErrorClass: network → transient, workspace → resumable (0.117457ms)
✔ parseSSEChunk: parses event and data lines (1.061658ms)
✔ parseSSEChunk: keeps incomplete frame in rest (0.276232ms)
✔ parseSSEChunk: flush parses final frame without trailing delimiter (0.226903ms)
✔ parseSSEChunk: ignores heartbeat comments and keeps last id (0.175014ms)
▶ projectSettingsError
  ✔ keeps status, code, message and issues on PLAN_FROZEN (1.468706ms)
  ✔ maps revision and concurrent conflicts to distinct recovery (0.147115ms)
  ✔ joins validation issues but still keeps typed codes (0.136046ms)
  ✔ prefers envelope code over legacy error field (0.093017ms)
  ✔ unwraps nested business JSON inside VERSION_CONFLICT envelope (0.174915ms)
  ✔ maps bare VERSION_CONFLICT envelope to retry_after_switch (0.097887ms)
  ✔ retains the local draft when a late tab hits PLAN_FROZEN (0.085587ms)
✔ projectSettingsError (3.200045ms)
✔ Project workflow types validation (1.156985ms)
✔ createTaskRun exposes DOC_BUSY detail without a retryable run (24.052076ms)
✔ parseSSEChunk tracks id seq for after_seq reconnect (0.385119ms)
✔ subscribeTaskRunEvents reconnects on EOF with advancing after_seq (4.695911ms)
✔ readTaskRunSSEOnce marks non-terminal EOF for reconnect (0.588273ms)
✔ buildTaskRequest: maps five project fields + task_key + user identity (1.133977ms)
✔ buildTaskRequest: omits optional fields when absent (0.215383ms)
✔ buildTaskRequest: includes materials when provided and non-empty (1.074518ms)
✔ buildResumeRequest: adds work_dir on top of task request (0.225603ms)
✔ buildTaskRequest: canonicalizes legacy doc-p doc_id (0.325181ms)
✔ buildTaskRequest: UI-05 pinned intake keeps task_key + doc_proj6109_intake (0.237933ms)
✔ buildResumeRequest: forwards add_steps when provided (0.197414ms)
✔ CategoryDock: 渲染顶部 🔔 未读提醒项及角标数字 (12.675113ms)
✔ CategoryDock: isAllReadCompleted 为 true 时渲染完成态提示 (3.480557ms)
✔ CategoryDock: 0 未读时不渲染红色未读角标 (6.254924ms)
✔ CategoryDock: 分类项包含依次跳转与遍历提示信息 (2.735299ms)
✔ InputArea keeps draft when send preflight fails (1.230894ms)
✔ InputArea clears draft only after accepted send (0.573333ms)
✔ InputArea shows thinking block message (0.159615ms)
✔ InputArea keeps draft when attachment registration fails (0.247173ms)
✔ isTemplateOnly 交付物应正确识别为初始模板展示态 (0.754627ms)
✔ 左侧栏鼠标严密绝对跟随与夹紧测试 (Left Rail Exact Pointer Following & Clamping) (0.714469ms)
✔ 右侧栏鼠标严密绝对跟随与反向位移测试 (Right Rail Exact Pointer Following & Inverted Delta) (0.165045ms)
✔ detects legacy mock and neuropulse/ten-projects ids (1.01564ms)
✔ detects colliding demo project ids (0.206664ms)
✔ 每人独立私聊：同一项目不同用户拥有不同 sessionId (0.709639ms)
✔ 左侧会话列表按当前用户过滤，不可见他人私聊 (0.291942ms)
✔ 消息严格归属各自私聊 session，无跨用户混聊 (0.67632ms)
✔ 切换用户时 resolve 到该用户同项目私聊会话 (0.265232ms)
✔ resolve 优先有消息的私聊，跳过空壳 sess-p{N}-u{id} (0.33197ms)
✔ ensurePrivateSessionsForUser 为缺失用户补齐空私聊 (0.281082ms)
✔ 多项目会话消息隔离测试仍成立（endo vs ultrasound） (0.196574ms)
✔ parseAnchorHash: 正确解析标准深链 hash (1.761548ms)
✔ formatAnchorHash: 正确构造深链格式 (0.185855ms)
✔ navigateToAnchor: 快路径直接命中 DOM 节点 (0.426987ms)
✔ navigateToAnchor: 慢路径拉取分片后命中 (81.596677ms)
✔ resolveTurnAnchorId: 方案 A 轮次归一化测试 (0.579223ms)
✔ 全链路场景 1: 用户自主受控注册（仅填用户名/密码/姓名，职位严格绑定访客待指派） (1.572433ms)
✔ 全链路场景 2: 系统准入策略（关闭自主注册与开启强制审批流转） (0.957642ms)
✔ 全链路场景 3: 管理员开通账号首次强制改密闭环 (0.3251ms)
✔ 全链路场景 4: 环境标识随登录会话返回（dev/test/main） (0.295291ms)
✔ cleanHeadingContent: 手工多级序号前缀清洗与专业词汇保护 (0.962552ms)
✔ 标题多层级自动编号：单 H1 文档总标题自适应模式 (1 -> 1.1 -> 1.1.1) (0.305551ms)
✔ 标题多层级自动编号：多 H1 标准大章模式 (0.141016ms)
✔ 跨章节图、表、公式多级按章重编号测试 (表 1-1, 表 2-1, 图 3-1, 式 (4-1)) (0.120746ms)
✔ 有序列表与无序列表编号与渲染功能测试 (1.520405ms)
✔ 动态块操作闭环重编号验证 (Insert, Move, Delete) (0.186174ms)
✔ findMatchingBlockForReview: 能够精准按审查关键词（电气安全/EMC/竞品）定位段落块 (1.295541ms)
✔ findMatchingBlockForReview: 能够按外部指定 hint 线索精确命中目标块 (0.233673ms)
✔ createRejectConfirmationCard: 生成合规危险级驳回门禁卡片 (0.601753ms)
✔ isAffirmativeResponse: 准确识别双轨交互中的肯定意图输入 (0.221293ms)
✔ findLastActiveCard: 正确在会话历史中提取最新的待决策卡片 (0.216604ms)
✔ decrementActiveCardsTtl: 多轮对话超时递减与自动失效归档 (0.173525ms)
✔ applyConfirmRejectToDoc & applyUndoRejectToDoc: 驳回挂载批注与60s窗口期撤销完整闭环 (0.296501ms)
✔ resolveCardInMessages & cancelCardInMessages: 消息流中卡片终态沉淀 (0.187264ms)
✔ classifyRejectUtterance: 询问原因 → QUERY_REJECT_REASON (0.930912ms)
✔ classifyRejectUtterance: 明确执行 → EXECUTE_REJECT (0.166615ms)
✔ classifyRejectUtterance: 模糊 → OTHER (0.180014ms)
✔ resolveDocGovCard: 编制人查询 → 信息卡且无 confirm_reject (0.746558ms)
✔ resolveDocGovCard: 审核人执行 + reviewing → 确认卡 (1.254603ms)
✔ resolveDocGovCard: 编制人误说执行驳回 → 无权纯文本 (0.166465ms)
✔ resolveDocGovCard: 批准人 + approving → 终审确认卡 (0.168425ms)
✔ resolveDocGovCard: 编制人 OTHER → 引导查询无危险按钮 (0.107177ms)
✔ canConfirmReject: 仅审核/批准 (0.130966ms)
✔ deriveFallbackCategory identifies categories correctly (0.977831ms)
✔ enrichMessagesWithCategories backfills categories without overwriting existing ones (0.285522ms)
✔ Markdown ➔ Block AST 解析测试 (标题自适应编号与图表公式全链路) (2.498745ms)
✔ 动态重编号引擎测试 (多 H1 规范章节重排验证) (2.100378ms)
✔ Block AST ➔ Markdown 双向无损往返还原测试 (0.554304ms)
✔ 三层交付物多用户隐私绝对隔离测试 (Multi-user Strict Privacy Isolation) (1.082668ms)
✔ 一键共享至项目参考库流转测试 (Promote to Shared Reference Test) (0.271372ms)
✔ 撤回共享恢复私有草稿测试 (Revoke Shared Reference Test) (0.564424ms)
✔ 受控工作流纯净性红线检验 (Workflow Purity Security Red Line) (0.32681ms)
✔ isSameMessage: clientTurnId match (1.109737ms)
✔ isSameMessage: serverId match without turn (0.167865ms)
✔ filterPendingLiveMessages: real temp vs server id (0.139175ms)
✔ mergeLiveOverHistory preserves server id from live (0.129527ms)
✔ applyPhaseEvent: appends first phase as running node (1.064778ms)
✔ applyPhaseEvent: completes predecessors when a new phase arrives (0.208124ms)
✔ applyPhaseEvent: same phase refreshes label in place (no duplicate node) (0.216274ms)
✔ applyPhaseEvent: unknown phase falls back to hourglass meta (0.114496ms)
✔ applyPhaseEvent: prefers backend message over short label (0.099547ms)
✔ applyPhaseEvent: step_completed closes running entry without appending (1.024819ms)
✔ applyPhaseEvent: stage_completed closes entries (0.124956ms)
✔ applyPhaseEvent: task_failed appends warning node (0.113747ms)
✔ applyPhaseEvent: decorates label with step index / total steps (0.155515ms)
✔ applyPhaseEvent: repeated step_executing with step_index gets separate nodes (0.237263ms)
✔ applyPhaseEvent: ignores event without phase payload (0.122346ms)
✔ applyPhaseEvent: step_failed marks running entry as failed (keeps step label) (0.130266ms)
✔ applyPhaseEvent: step_failed appends failed node when no running entry exists (0.125276ms)
✔ applyPhaseEvent: retry of a failed step resets it to running (0.097697ms)
✔ PLAN_CONFIRM 卡片来自 PlanView 且不触达 AST (1.01759ms)
✔ 409 冲突把卡片标为 outdated 并换上最新 revision (0.243463ms)
✔ GET reconcile 用权威 PlanView 覆盖本地 executing，不假装成功 (0.207094ms)
✔ 过期计划映射 expired (0.151796ms)
✔ 非计划卡不被误判 (0.085737ms)
✔ 集成验证：项目切换时交付物严格隔离，新建项目即刻包含 7 份模板副本 (4.991482ms)
✔ 集成验证：三层隐私与项目物理隔离双重约束 (1.410598ms)
✔ 用例 1: DEFAULT_ROLES 包含 5 种默认角色且具备预期权限 (1.231943ms)
✔ 用例 2: 系统管理员 (ADMIN) 与具备 perm:manage 用户的通配豁免特权 (0.245832ms)
✔ 用例 3: 常规工作流基线可见性 (workflow:view_all) 判定 (0.271472ms)
✔ 用例 4: 单文档覆盖 - designated_only (仅编制/审核/批准人可见，其他用户被精确拦截) (1.962741ms)
✔ 用例 5: 单文档覆盖 - role_whitelist (仅白名单内角色可见，其他角色被精确拦截) (0.274252ms)
✔ 用例 6: 单文档覆盖 - public (放宽可见性，无 workflow:view_all 权限的访客也能查阅) (0.126076ms)
✔ 用例 7: 私密文档隔离强红线 (category === private 无论任何管理员或单文档覆盖，非创建者绝对不可见) (0.138626ms)
✔ 用例 8: 核心业务动作权限拦截判定 (canPerformDocAction & hasPermission) (0.173525ms)
✔ 用例 9: filterVisibleDeliverablesWithRBAC 能够批处理过滤大盘交付物 (0.885453ms)
✔ 集成场景 1: 动态新增合规审计员角色，并配置其仅能查阅特定单文档覆盖 (0.969342ms)
✔ 集成场景 2: 服务端 capabilities 变更后权限即刻生效 (0.180845ms)
✔ 集成场景 3: 单文档覆盖 designated_only 严格收紧与撤回恢复全流程 (0.216884ms)
✔ renderInlineMarkdown: renders bold, italic, strikethrough (1.00806ms)
✔ renderInlineMarkdown: escapes raw HTML tags to prevent XSS (0.437667ms)
✔ renderInlineMarkdown: blocks javascript: link hrefs (0.145766ms)
✔ renderInlineMarkdown: renders inline code and preserved line breaks (0.227353ms)
✔ renderInlineMarkdown: renders headings lists and tables for chat replies (0.34343ms)
✔ sanitizeMermaidCode: auto wraps unquoted labels containing brackets or comparison operators (0.283632ms)
(node:4027631) ExperimentalWarning: localStorage is not available because --localstorage-file was not provided.
(Use `node --trace-warnings ...` to show where the warning was created)
✔ DOCX 渲染器行内文本与公式解析测试 (parseInlineContent) (5.096649ms)
✔ DOCX 渲染器 LaTeX 原生 OMML 转换引擎测试 (latexToOmml) (2.504616ms)
✔ DOCX 渲染器 Mermaid 语法净化与容错测试 (sanitizeMermaidCode) (0.288952ms)
✔ DOCX 渲染器 SVG 净化防 Canvas 污染测试 (cleanSvgForCanvas) (0.34609ms)
✔ DOCX 渲染器全量编译测试 (buildDocxModel & exportDocumentToDocx) (60.494434ms)
✔ XLSX 渲染器多表提取与工作簿编译测试 (buildXlsxWorkbook & exportDocumentToXlsx) (6.085679ms)
▶ Reply Document IR & Export Engine
  ✔ deriveReplyTitle and sanitizeFilename derive title and safe file name (1.00806ms)
  ✔ deriveReplyTitle handles text without heading (0.263112ms)
  ✔ parseReplyMarkdown parses headers, lists, code, and tables (1.897594ms)
  ✔ renderClipboardHtml renders self-contained styling for office tools (0.514334ms)
  ✔ renderClipboardHtml converts LaTeX formulas to native MathML for Word/Office (3.559075ms)
  ✔ renderPlainText strips formatting cleanly (0.436737ms)
  ✔ serializeMarkdown round-trips to valid markdown (0.34021ms)
  ✔ stripUnsafeHtml strips script tags and dangerous event handlers (0.474656ms)
✔ Reply Document IR & Export Engine (10.511258ms)
✔ createProjectTemplateDeliverables: 必须精确生成 7 份全生命周期受控文档副本 (4.683551ms)
✔ resolveRequirementsTaskKey prefers intake for 初始需求表 (1.325751ms)
✔ resolveRequirementsTaskKey selects user_requirements for explicit URS (0.166045ms)
✔ UI-02 first-round prompt with 首轮+用户需求+摸底 must be intake not user_requirements (0.700139ms)
✔ 首轮 / 需求摸底 / 摸底 beat bare 用户需求 (0.130106ms)
✔ bare 用户需求 without V0.1 markers stays user_requirements (0.120147ms)
✔ matchTemplateDeliverable uses intake key when pool only has URS template (0.163975ms)
✔ resolveTaskTemplateForMessage keeps intake key with URS-only pool (0.162786ms)
✔ matchTemplateDeliverable prefers intake when both templates exist (0.752757ms)
✔ read-only request does not start a document task: 总结一下用户初始需求表 (0.275072ms)
✔ read-only request does not start a document task: 查看用户初始需求表 (0.167355ms)
✔ read-only request does not start a document task: 用户初始需求表现在谁在编辑 (0.713008ms)
✔ read-only request does not start a document task: 分析一下用户需求表里的风险 (0.082938ms)
✔ read-only request does not start a document task: 用户初始需求表 (0.569833ms)
✔ explicit write action still starts intake (0.123747ms)
✔ explicit update action still starts URS (0.173725ms)
✔ UI-05 prompt without active doc still keyword-routes to feasibility_reg (0.281542ms)
✔ UI-05 prompt + registered intake pins intake and doc_proj6109_intake (0.281211ms)
✔ read-only current-doc request does not start a task (0.110036ms)
✔ template-only active slot is not pinned; keywords still apply (0.101387ms)
✔ explicit named deliverable can switch away from active intake (0.254003ms)
✔ domain 注册法规 without current-doc deixis still routes feasibility_reg (0.084247ms)
✔ mismatched title vs docId suffix prefers docId taskKey (0.088707ms)
✔ deixis 当前文档 pins registered intake (0.092458ms)
✔ deixis 本文件 pins registered intake (0.045979ms)
✔ deixis 这份文档 pins registered intake (0.044009ms)
✔ deixis 本文档 pins registered intake (0.040988ms)
✔ deixis 本受控文档 pins registered intake (0.042559ms)
✔ no active doc does not invent a pin (0.087408ms)
✔ UI-11 named 系统设计输入 beats negated 需求 background (0.071368ms)
✔ mixed generate-design + do-not-cover-requirements stays prelim_design (0.055729ms)
✔ current-doc pin still wins when no other deliverable is named (0.069938ms)
▶ document revision overlay modes
  ✔ pure hides all decorations (1.00319ms)
  ✔ manual only marks human hunks (0.164295ms)
  ✔ all marks human and agent differently (0.127556ms)
  ✔ same human hunk stays amber in manual and all (no pairwise style guarantee) (0.288191ms)
  ✔ exposes needs-content error code for empty orphan docs (0.119987ms)
  ✔ matches overlay hunks by section or text when ids differ (0.379089ms)
  ✔ aligns client block ids from head_block_map by order (0.368419ms)
✔ document revision overlay modes (3.672621ms)
▶ toolbar refresh + report entry reachability
  ✔ pickLatestChangeReportId prefers highest version with report (0.473166ms)
  ✔ first squad run alone still exposes a reachable report id (0.397829ms)
  ✔ second squad run keeps both history report entries and latest shortcut (0.926382ms)
  ✔ revisionRefreshKey is an independent refresh signal from docId (0.134596ms)
✔ toolbar refresh + report entry reachability (2.423028ms)
▶ change report view model
  ✔ surfaces risk items, project impact, doc impacts with advice, and open questions (0.737078ms)
  ✔ preferReportId prioritizes pending over committed latest (0.595622ms)
✔ change report view model (1.471876ms)
▶ revisionToolbarMount
  ✔ exposes clear non-error template preview hint copy (0.970381ms)
  ✔ template doc-p + isTemplateOnly=true does not mount (0.218523ms)
  ✔ legacy doc-001 does not mount (0.222983ms)
  ✔ unregistered doc-upload orphan does not mount (must register first) (0.203474ms)
  ✔ server-registered upload (doc-free) and freeform mount (0.194614ms)
  ✔ canonical doc_proj and generated non-template doc-p mount (0.171255ms)
✔ revisionToolbarMount (3.38832ms)
✔ window fetch race: stale response ignored by generation (0.965092ms)
✔ mapRecordToMessage: 正确映射服务端消息记录为前端 ChatMessage (1.3631ms)
✔ refresh window: 空 messages 日桶不算有效窗口 (0.175505ms)
✔ mapRawBucket: 正确映射服务端按日分片桶 (0.143685ms)
✔ Category navigation: chip 选中后准确匹配目标分类最新轮次并触发归一化定位 (0.171244ms)
✔ turn runtime: session A stream survives session B switch (0.604902ms)
✔ syncAdminUserDirectories calls local reload then parent onRefreshUsers (1.509885ms)
✔ syncAdminUserDirectories fails closed when onRefreshUsers is a dead/missing prop (0.635911ms)
✔ syncAdminUserDirectories surfaces parent refresh errors (no silent swallow) (0.280641ms)
✔ afterProjectMemberPersisted syncs members then refreshes workflow docs (1.755678ms)
✔ afterProjectMemberPersisted does not refresh when member sync fails (0.532184ms)
▶ blockEditorDialogPolicy
  ✔ pins an accessible dialog label and exact save name (0.841485ms)
  ✔ rejects page-wide fuzzy /保存/ that would hit private-library buttons (0.307371ms)
✔ blockEditorDialogPolicy (2.171536ms)
▶ resolveSaveTargetBlock
  ✔ keeps the editor and does not fake success when the block id is gone (0.723128ms)
  ✔ never retargets another block that happens to share the same content (0.718658ms)
✔ resolveSaveTargetBlock (2.541904ms)
▶ editor session document binding
  ✔ fail-closes when activeDocId drifts away from the opened editor doc (0.209393ms)
  ✔ accepts a save only when the editor is still bound to the active doc (0.140885ms)
  ✔ blocks switching documents while the editor is open (0.160485ms)
✔ editor session document binding (0.833666ms)
▶ interpretBlockSaveError
  ✔ 409 keeps the draft in the editor (0.232513ms)
  ✔ other PATCH failures also keep the editor (0.236993ms)
✔ interpretBlockSaveError (0.694559ms)
▶ blockedGovernanceCopy
  ✔ recognizes blocked run status and fixed hint, not generation success (0.68284ms)
✔ blockedGovernanceCopy (1.501155ms)
▶ commentPolicy
  ✔ lets author/reviewer/approver annotate and keeps their comment role (0.754708ms)
  ✔ keeps viewer read-only: no add entry and no reviewer/approver cast (0.143735ms)
✔ commentPolicy (1.845556ms)
▶ controlledContentInvalidation
  ✔ hydrate success then late list_sync keeps cache/ready and does not bump resume (1.501406ms)
  ✔ post_task invalidation drops active cache and requires a new hydrate epoch (0.234723ms)
  ✔ editor open / save epoch keeps draft and rejects a stale GET after PATCH (0.380079ms)
  ✔ never drops the active doc without signaling rehydrate (0.131047ms)
  ✔ candidate helper keeps template / doc-001 / freeform / upload out of wipe lists (0.416848ms)
  ✔ dropRecordKeys is a no-op when ids are absent (0.111197ms)
✔ controlledContentInvalidation (3.930263ms)
▶ controlledDocHydrate
  ✔ shouldLoadControlledContent when non-template workflow doc (0.975202ms)
  ✔ shouldLoadControlledContent rejects local legacy/mock ids like doc-001 (0.209814ms)
  ✔ shouldLoadControlledContent keeps canonical, freeform-off, and template preview rules (0.157935ms)
  ✔ hydrateControlledDocumentContent never requests content/revision for doc-001 (0.33429ms)
  ✔ hydrateControlledDocumentContent never requests for template preview or registered freeform (0.138206ms)
  ✔ shouldLoadControlledContent stays inside toolbar server-backed eligibility (0.181635ms)
  ✔ resolveCanonicalDocId maps doc-p56-intake to doc_proj56_intake (0.271331ms)
  ✔ canonicalDocIdForTask maps doc-p56-research to doc_proj56_research (0.155545ms)
  ✔ hydrate treats projection missing as ledger content, not 404 (1.439947ms)
  ✔ attaches hydrate ETag as PATCH baseline and ignores a later GET (1.035789ms)
  ✔ rejects hydrate when revision-state network or 5xx fails (0.621892ms)
  ✔ aligns markdownToBlockAST random ids onto revision-state head_block_map (1.815297ms)
  ✔ leaves Math.random ids when head_block_map is omitted (why gate + fail-closed remain) (0.409868ms)
  ✔ rejects controlled hydrate on NOT_FOUND or NEEDS_CONTENT (0.262602ms)
  ✔ fingerprint stays stable when only object identity changes (0.411477ms)
  ✔ dedupes in-flight hydrate for the same doc fingerprint (0.271882ms)
  ✔ aligned late hydrate still cannot overwrite a PATCH-success baseline (0.436167ms)
✔ controlledDocHydrate (11.673493ms)
✔ createClientTurnId uses randomUUID when available (0.801476ms)
✔ createClientTurnId falls back to getRandomValues UUID v4 (0.422888ms)
✔ createClientTurnId throws when no secure random API exists (0.377459ms)
✔ selectNonCreatorInitialMembers skips creator only (1.384889ms)
✔ buildManagedMemberUpsertPayload sends document_duty on add/update/restore (0.209053ms)
✔ buildInitialMemberUpsertPayload maps reviewer UI role to member API role (0.129297ms)
✔ persistInitialProjectMembers awaits each add and stops on failure (0.467736ms)
✔ ensureCreatedProjectWithMembers skips recreate on bootstrap id and retries members (1.66308ms)
✔ beginCreateProjectSubmit rejects concurrent second entry until end (31.01785ms)
✔ resolveCreateProjectSubmitPhase uses bootstrap to choose syncing label (0.521255ms)
✔ createProjectSubmitButtonLabel and close block while submitting (0.176264ms)
▶ resolveCurrentDocRole
  ✔ resolves A as author by authoritative user id (0.730168ms)
  ✔ does not promote reviewer B or stranger to author (0.156975ms)
  ✔ resolves real USER_B id as reviewer and never name-promotes placeholder 2 (0.144165ms)
  ✔ fail-closes unknown identity to viewer even if projectPermission says author (0.138776ms)
  ✔ matches name only for legacy local docs without duty ids (0.111857ms)
  ✔ does not name-promote when server controlled duties are zero ids (0.128906ms)
✔ resolveCurrentDocRole (2.618612ms)
▶ currentProjectRestore
  ✔ rejects empty project names (0.765087ms)
  ✔ rejects page-wide project name when banner and sidebar both match (0.232303ms)
  ✔ scopes the visible entry to complementary exact title (0.829836ms)
  ✔ scopes the current project assertion to banner exact text (0.236433ms)
✔ currentProjectRestore (3.03326ms)
▶ deliverableLeaseSync
  ✔ returns the same array reference when leases are unchanged (0.698939ms)
  ✔ returns a new array only when a lease actually changes (0.205023ms)
✔ deliverableLeaseSync (1.972472ms)
▶ docGovActionVisibility
  ✔ hides all approval actions on unmanaged docs (0.642991ms)
  ✔ gates full docs by currentRole and denies creator who is not author (0.149815ms)
✔ docGovActionVisibility (1.653911ms)
▶ documentBlockDomAttrs
  ✔ marks a real DocumentBlock in pure mode without overlay kind (0.635621ms)
  ✔ keeps the same stable attrs when overlay is later attached separately (0.160695ms)
✔ documentBlockDomAttrs (1.696249ms)
▶ durableBodySnippet
  ✔ rejects empty persisted snippets (0.834965ms)
  ✔ lets a later successful revision replace the old snippet (0.184845ms)
  ✔ does not promote a conflict-failed draft to the expected body (0.094617ms)
✔ durableBodySnippet (2.088838ms)
▶ dutyCellAssertion
  ✔ parses author, reviewer, and viewer from select value or badge role (1.050019ms)
  ✔ must not infer author from a row whose option labels include 编制负责人 (0.606802ms)
  ✔ accepts only a disabled non-assignable reviewer select (0.178935ms)
  ✔ rejects an enabled reviewer select when the reviewer cannot assign leads (0.141976ms)
  ✔ rejects canAssignLead=true even if the reviewer select is disabled (0.104107ms)
  ✔ rejects viewer, author, approver, and unknown values for USER_B (0.240222ms)
✔ dutyCellAssertion (3.789288ms)
▶ decideHydrationApply
  ✔ applies only when gen, doc, save epoch match and editor is closed (1.114307ms)
  ✔ rejects a response for another document (0.129927ms)
  ✔ rejects a superseded generation (0.074477ms)
✔ decideHydrationApply (2.174136ms)
▶ createEditorHydrationGate
  ✔ does not start a new hydrate while the editor is open (UI-06 fill-window GET) (0.33025ms)
  ✔ deferred hydrate that resolves after the editor opens does not replace the session (0.154475ms)
  ✔ covers hydrate resolving between fill and save (0.831215ms)
  ✔ asks for a hydrate resume after editor_open blocked the first apply (0.183755ms)
  ✔ asks for a hydrate resume when beginHydration is skipped while editing (0.098577ms)
  ✔ requestHydrationResume is consumed once after a protected edit session (0.101547ms)
  ✔ late hydrate after a successful PATCH does not roll back the new baseline (0.221663ms)
✔ createEditorHydrationGate (2.317701ms)
✔ mergeSessionUser prefers session identity over stale catalog entry (1.33126ms)
▶ playwrightPhaseArtifacts
  ✔ defaults unknown or empty UI_PHASE to main (0.961422ms)
  ✔ keeps post-restart distinct from main so the second run cannot overwrite traces (0.237433ms)
  ✔ keeps main results at the historical filename and isolates post-restart recordPass (0.231943ms)
  ✔ shares phase-state and secrets across phases (0.157155ms)
✔ playwrightPhaseArtifacts (2.775488ms)
✔ resolvePostTaskActiveDocId prefers server doc_proj for taskKey (5.135667ms)
✔ resolvePostTaskActiveDocId honors preferred server doc id (0.248052ms)
✔ shouldSwitchTemplateSlotToServer when active is local template slot (0.220503ms)
✔ pollUntilPostTaskServerDoc retries until same taskKey server doc appears (0.492325ms)
✔ pollUntilPostTaskServerDoc returns null after maxAttempts without relying on setState (0.259652ms)
✔ mapServerProjectToProjectInfo maps creator and preserves local members (0.862764ms)
✔ mergeProjectLists drops local-only demo seed projects by default (0.307481ms)
✔ mergeProjectLists can retain local-only demo when explicitly opted in (0.257142ms)
✔ documentDutyFromMemberRole maps UI reviewer and creator (0.961031ms)
✔ exclusiveMemberRoleChange keeps a single reviewer (0.253383ms)
✔ memberRoleFromDocumentDuty does not invent reviewer from access role (0.304451ms)
✔ toApiProjectRole maps doc roles to member and creator to owner (0.710619ms)
✔ fromApiProjectRole maps owner to creator for project creator (0.134726ms)
✔ mapApiMemberToProjectMember builds UI record (0.138356ms)
▶ projectSettingsDuties
  ✔ toggles full to none by atomically clearing duties (1.431477ms)
  ✔ blocks partial saves and locates required/governance issue codes (0.424337ms)
  ✔ allows an all-none configurable draft without three members (1.276902ms)
  ✔ requires three members once any document is managed (0.169765ms)
✔ projectSettingsDuties (4.785338ms)
▶ projectSettingsMode
  ✔ enters frozen when can_edit_plan is false or the project is active (0.908493ms)
  ✔ stays planning only for an editable draft (0.192724ms)
  ✔ lists enabled duties for the frozen snapshot and skips disabled tasks (0.810526ms)
  ✔ keeps the local draft after PLAN_FROZEN refresh and switches to frozen (0.154905ms)
✔ projectSettingsMode (3.222635ms)
▶ revisionEtag
  ✔ uses stale hydrate ETag for PATCH and never the latest GET (0.893634ms)
  ✔ does not invent 0:0 when controlled hydrate misses etag or errors (0.173455ms)
  ✔ refuses controlled save without a hydrate ETag (0.544853ms)
  ✔ allows freeform bootstrap 0:0 only (0.292201ms)
✔ revisionEtag (3.124147ms)
▶ saveControlledBlockEdit
  ✔ successful save calls PATCH once with bound docId, hydrate ETag, body and client_block_map (2.093777ms)
  ✔ does not PATCH when editorDocId and activeDocId diverge (0.175035ms)
  ✔ does not PATCH on stale block id and keeps the draft (0.148595ms)
  ✔ 409 does not close the editor or drop the draft (0.512815ms)
  ✔ network errors do not close the editor or drop the draft (0.178185ms)
✔ saveControlledBlockEdit (4.080149ms)
✔ parseProjectIdFromSessionId decodes sess-p{id}-u{user} (0.621912ms)
✔ resolveSessionProjectId prefers explicit id then session id encoding (0.149855ms)
✔ mapServerSessionToProjectSession fills project metadata (0.581942ms)
✔ mergeSessionLists keeps local stage while applying server counts (0.191564ms)
▶ squadCompletionObservation
  ✔ accepts a directly completed adjacent assistant without requiring inflight (0.738108ms)
  ✔ accepts a turn that passed through inflight then completed (0.121706ms)
  ✔ rejects error terminals, missing correspondence, and visible errors (0.149446ms)
  ✔ keeps waiting while still inflight and does not treat inflight as success (0.097687ms)
✔ squadCompletionObservation (2.076648ms)
✔ resolveReconnectRunId prefers explicit opts and ignores attempt without opts (0.734238ms)
✔ shouldSubscribeExistingRun only for in-flight statuses (0.158095ms)
✔ isRemoteTaskTerminal covers confirmation and quality_failed (0.140145ms)
✔ nextAttemptOpts carries retained runId for reconnect without new POST (0.121557ms)
▶ uploadFreeformRegister
  ✔ buildUploadClientKey prefers explicit hint then doc-upload stamp (0.472296ms)
  ✔ registerUploadAttachments hard-fails without creating orphan on API error (12.923646ms)
  ✔ registerUploadAttachments rejects local doc-upload id from server (0.307631ms)
  ✔ registerUploadAttachments returns server doc-free ids and freeform facts (0.425217ms)
  ✔ deliverableFromFreeformUpload maps server id and upload facts (0.138386ms)
✔ uploadFreeformRegister (15.166989ms)
▶ workflowCategoryNavigation
  ✔ private menu cannot see doc_proj* so it must switch to workflow before exact select (1.137846ms)
  ✔ fail-closes when the workflow menu is showing but the exact doc is missing (0.206404ms)
  ✔ label and taskKey opens always require the workflow category (0.094747ms)
✔ workflowCategoryNavigation (2.37942ms)
▶ 用户上传文档多格式在线预览体系与渲染分流测试
  ✔ 1. 上传附件时正确注入 sourceType: "uploaded_file" 与完整 fileMeta 元数据 (0.66963ms)
  ✔ 2. 扩展名分类规则准确分发至对应的高保真渲染器类型 (0.298471ms)
  ✔ 3. 受控工作流交付物严格隔离：绝不命中 FilePreviewPanel，保持 BlockRenderer 纯净 (0.147986ms)
  ✔ 4. 上传文档支持受控流转：从个人私密一键共享至项目参考库后，在线预览依然可用且权限标态正确 (0.153345ms)
✔ 用户上传文档多格式在线预览体系与渲染分流测试 (2.101867ms)
▶ 项目立项、成员职责分配与退出留痕治理测试套件
  ✔ 1. 默认项目库包含完整元数据与法定三权成员 (active 状态) (0.458517ms)
  ✔ 2. 跨用户会话可见性严格隔离：未加入成员完全不可见 (0.200454ms)
  ✔ 3. 创建者添加新成员并分配职责后，新成员即刻可见该项目会话 (0.118626ms)
  ✔ 4. 中途加入后期退出 (exited)：保留项目会话但标记已退出只读留痕 (0.125476ms)
  ✔ 5. 超级管理员 (ADMIN) 享有全量通配可见与管理兜底特权 (0.086488ms)
✔ 项目立项、成员职责分配与退出留痕治理测试套件 (1.850955ms)
▶ 新建项目工程文档模板质量与纯净性保障套件（对标官方参考系统）
  ✔ 1. 必须精确生成 7 份官方全流程受控工作流模板且标记纯净 (0.66659ms)
  ✔ 2. 杜绝旧项目 CUSA-NeuroPulse 串号泄露，动态注入新项目信息 (0.545744ms)
  ✔ 3. 严格对标参考系统模板规范要素，绝非 3 行残缺摘要 (0.408417ms)
  ✔ 4. 缓存丢失场景下即时自愈重建 AST 能力验证 (0.241083ms)
✔ 新建项目工程文档模板质量与纯净性保障套件（对标官方参考系统） (5.099429ms)
▶ 用户上传文档私密归档与共享流转测试
  ✔ 10 个评审项目均包含已共享的 URS 交付物与 AST，支持跨角色合规查阅且会话均以 assistant 闭环 (1.155265ms)
  ✔ 用户上传附件自动生成私密交付物并在 AST 中建立隔离，支持流转至项目参考库 (1.181035ms)
  ✔ 单轮对话支持一次上传多个文档(上限5个)，批量生成私密交付物并遵循数量约束 (0.406688ms)
✔ 用户上传文档私密归档与共享流转测试 (3.384109ms)
▶ 工作流切换与消息展示时序测试套件
  ✔ 1. 当存在历史 seed 消息且追加新实时消息时，新消息必须严格沉淀在末尾 (0.65175ms)
  ✔ 2. 切回项目时相同正文不应因 temp/server id 差异重复展示 (0.141016ms)
✔ 工作流切换与消息展示时序测试套件 (1.414058ms)
✔ DeliverableItem 必须包含 projectId 与 isTemplateOnly 属性 (0.652751ms)
ℹ tests 376
ℹ suites 34
ℹ pass 376
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 838.607739

 RUN  v5.0.0 /home/weichen/projects/Agent-System/web

(node:4028144) ExperimentalWarning: localStorage is not available because --localstorage-file was not provided.
(Use `node --trace-warnings ...` to show where the warning was created)

 Test Files  3 passed (3)
      Tests  32 passed (32)
   Start at  05:15:46
   Duration  509ms (import 50%, transform 44%, tests 5%, worker 1%)

npm_exit=0
