⚡️ 降低测试固定等待与渲染开销 - #1737
Conversation
|
Follow-up rework completed and pushed at Corrections:
Independent scoped audits found these as concrete test-observation regressions; no production-runtime defect was identified. The final diff remains test/documentation-only. Local evidence at the published head:
GitHub Actions for the new head were pending when this comment was posted; the last remote read showed the PR open and mergeable. Local runs retain existing happy-dom extension-URL warnings, with no test failures. |
|
基于当前 PR head
另外有两项文档问题需要同步处理:
我在当前 |
|
已按这条审查意见完成修正并推送到
验证结果:相关 3 个文件 38/38 通过;全量 368 个文件、4,711 个测试通过; |
|
已将 UI 性能修正推送到此 PR,当前 HEAD 为 本次 follow-up 涉及 精确工作树上的验证证据:
GitHub Actions run 34584238117 已完成:Lint、E2E 四个分片、测试 shard 2/2 和 License Compliance 成功;测试 shard 1/2 失败, |
Checklist / 检查清单
Code reviewed by humanremains unchecked because no human review was performed in this task.Description / 描述
背景
CI timing reports identified avoidable wall-clock cost in Network Rules UI tests and several Promise/timer-driven
tests. The original failures were sensitive to the UI project's 850 ms per-test budget and to worker contention;
the goal is to make tests observe their real completion signals without weakening the behavior they protect.
本次改动
ActionColors,BulkActions,Feedback,RowRenderCost,UxRefinements, the NetworkRules page, and the Tools summary section. Page tests use controlledactmicrotasksettling, direct selectors where identity is already known, focused
RuleSheetrendering for drawer-only behavior,and cheaper dnd-kit rectangle measurement. Existing request, confirmation, pagination, feedback, and row-render
assertions remain. Page-level create/edit bridge tests now assert exact mutation payloads, retry tests assert the
applied UI state, and bulk actions assert the toolbar's accessible name.
dom_cdp,tool_loop_orchestrator,MessageToolbar, andModelFormDialog. Fixedproduction stability/retry delays are advanced with fake timers; Promise-driven React updates use a single
completion step followed by direct assertions.
src/pages/batchupdate/hooks.test.tsby advancing the production success-hold and row-exit timers inthe two tests that intentionally observe those transitions.
AGENTS.mdanddocs/references/develop-testing.mdto make the test-writing rule durable: choose thewait primitive from the contract, use fake timers for production timer behavior, and do not raise timeouts,
add arbitrary sleeps, or weaken assertions to hide contention. The detailed async mechanics remain owned by
docs/references/develop-testing.md.No production runtime code or user-visible behavior changed. The final diff contains 12 test files and 2 agent/
testing-document files.
实现考虑
The changes preserve the original test boundaries and observable assertions.
findBy*remains appropriate when anelement's appearance is the asynchronous boundary; direct assertions are used only after the test-owned Promise or
completion signal has settled. Fake timers advance the configured production durations rather than shortening them.
The 20-row render-cost boundary and its exact read-count assertions remain intact.
已知限制
Test wall-clock timings still vary with worker contention and local hardware. Full local execution emits existing
happy-dom
chrome-extension://iframe and Node local-storage warnings, but all tests pass. GitHub checks for thelatest head may still be running after this metadata update.
建议审查重点
gates, drag ordering, pagination, and row-render counts.
that a timer callback ran.
docs/references/develop-testing.md.验证
Final local head:
c2c11fc23c88a0a97130a121799cb2ddc76d7825; PR base:dd280349617c8cd5b29710a2c016ce8194dc4280.pnpm exec vitest run --project ui --no-coverage --reporter=default --silent=passed-only src/pages/options/routes/Tools/NetworkRules/index.test.tsx src/pages/options/routes/Tools/NetworkRules/BulkActions.test.tsx src/pages/options/routes/Tools/sections/NetworkRulesSection.test.tsx— 3 files / 38 tests passed.pnpm exec vitest run --no-coverage --reporter=default --silent=passed-only— 368 files / 4,711 tests passed in 27.10 s.pnpm run lint— passed: Prettier, TypeScript, i18n, issue-template validation, and ESLint.git diff --check, the new Markdown link target/anchor, and the targeted policy-consistencyscan passed.
Screenshots / 截图
N/A — test and agent-document changes only; no visual behavior changed.