fix(web-shell): polyfill Range layout APIs in tests - #6677
Conversation
|
Thanks for the PR! Template looks good ✓ Problem: Observed bug — Ubuntu PR CI fails with Direction: Aligned. Polyfilling jsdom gaps in the shared test setup is exactly the pattern Size: Not applicable — no core infrastructure paths touched. All changes are test files or test setup ( Approach: Scope is tight. Two focused files for the polyfill + test, plus a timing stabilization in the DaemonSessionProvider test discovered during CI validation. The Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:已观测到的 bug — Ubuntu PR CI 在 jsdom animation-frame 测量后抛出 方向:对齐。在共享测试 setup 中补充 jsdom 缺失的 polyfill 正是 规模:不适用 — 未触及核心基础设施路径。所有改动均为测试文件或测试 setup。36 行生产代码(setup.ts polyfill)、23 行测试代码、13/10 行测试修复。 方案:范围精简。两个文件专注做 polyfill + 测试,加上 CI 验证中发现的 DaemonSessionProvider 计时稳定化修复。使用 进入代码审查 🔍 — Qwen Code · qwen3.7-max |
Code ReviewClean. The PR extends the existing The DaemonSessionProvider timing fix uses No issues found. TestingThis is test infrastructure — no user-visible behavior change. Ran the key test suites locally on the PR branch: setup.test.ts (new test)useComposerCore.dom.test.tsx (the test that triggered the CI failure)DaemonSessionProvider.test.tsx (timing stabilization)Full web-shell suiteTypecheck & LintAll green — no 中文说明代码审查干净。PR 延续了 DaemonSessionProvider 计时修复使用 测试测试基础设施修复——无用户可见行为变化。本地在 PR 分支上运行了关键测试套件,全部通过:setup.test.ts 1 个测试、useComposerCore.dom.test.tsx 4 个测试、DaemonSessionProvider.test.tsx 146 个测试、web-shell 全量 83 文件 1340 个测试。Typecheck 和 lint 均干净。未出现 — Qwen Code · qwen3.7-max |
|
This is a tight, well-scoped test infrastructure fix. The problem is real and well-documented (CI failures in #6578, #6662), the solution follows the exact pattern already established in 中文说明这是一个范围明确、精简的测试基础设施修复。问题是真实且有据可查的(#6578、#6662 中的 CI 失败),方案完全遵循 — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
|
No new Suggestion-level findings this round — all prior suggestions have been addressed or superseded. — qwen3.7-max via Qwen Code /review |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No issues found. Downgraded from Approve to Comment: CI still running.
— qwen3.7-max via Qwen Code /review
|
@qwen-code /triage |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
What this PR does
Adds a web-shell test setup polyfill for the jsdom
Rangelayout methods that CodeMirror calls during asynchronous editor measurement, and adds a focused setup test that locks this environment contract.Why it's needed
The Ubuntu PR CI can finish all web-shell assertions successfully and still fail because Vitest catches an unhandled
TypeError: textRange(...).getClientRects is not a functionfrom CodeMirror afteruseComposerCore.dom.test.tsxschedules a jsdom animation-frame measurement. jsdom does not provide theseRangelayout methods, so the shared test setup should provide stable empty geometry for editor tests.Reviewer Test Plan
How to verify
Confirm that jsdom
document.createRange()exposesgetClientRectsandgetBoundingClientRect, then run the web-shell DOM composer test and full web-shell CI test command. The expected result is that all tests pass without the CodeMirrorgetClientRectsunhandled error.Evidence (Before & After)
Before:
npm -w packages/web-shell run test -- test/setup.test.tsfailed withexpected 'undefined' to be 'function'forrange.getClientRects.After:
npm -w packages/web-shell run test -- test/setup.test.tspassed 1 test;npm -w packages/web-shell run test -- hooks/useComposerCore.dom.test.tsxpassed 4 tests;npm -w packages/web-shell run test:cipassed 83 files and 1340 tests;npm -w packages/web-shell run typecheckpassed;npm -w packages/web-shell run lintpassed;./node_modules/.bin/prettier --check packages/web-shell/client/test/setup.ts packages/web-shell/client/test/setup.test.tspassed.Tested on
Environment (optional)
Node v22.22.0, package workspace installed with
npm ciin an isolated git worktree.Risk & Scope
Linked Issues
Related to #6578 and the failing PR CI observed on #6662.
中文说明
What this PR does
为 web-shell 的测试环境补上 jsdom
Rangelayout 方法 polyfill,覆盖 CodeMirror 在异步编辑器测量里会调用的getClientRects和getBoundingClientRect,并新增一个聚焦的 setup 测试锁住这个测试环境契约。Why it's needed
Ubuntu PR CI 里 web-shell 的断言本身可以全部通过,但 Vitest 随后会捕获 CodeMirror 在
useComposerCore.dom.test.tsx相关异步 animation-frame 测量中抛出的TypeError: textRange(...).getClientRects is not a function。jsdom 本身不提供这些Rangelayout 方法,所以应该在共享测试 setup 里提供稳定的空布局几何,避免编辑器测试出现 unhandled error。Reviewer Test Plan
How to verify
确认 jsdom 的
document.createRange()暴露getClientRects和getBoundingClientRect,然后运行 web-shell 的 DOM composer 测试和 full web-shell CI 测试命令。预期结果是所有测试通过,并且不再出现 CodeMirrorgetClientRectsunhandled error。Evidence (Before & After)
Before:
npm -w packages/web-shell run test -- test/setup.test.ts在range.getClientRects上失败,错误为expected 'undefined' to be 'function'。After:
npm -w packages/web-shell run test -- test/setup.test.ts通过 1 个测试;npm -w packages/web-shell run test -- hooks/useComposerCore.dom.test.tsx通过 4 个测试;npm -w packages/web-shell run test:ci通过 83 个文件和 1340 个测试;npm -w packages/web-shell run typecheck通过;npm -w packages/web-shell run lint通过;./node_modules/.bin/prettier --check packages/web-shell/client/test/setup.ts packages/web-shell/client/test/setup.test.ts通过。Tested on
Environment (optional)
Node v22.22.0,在独立 git worktree 中通过
npm ci安装 workspace 依赖。Risk & Scope
Linked Issues
关联 #6578 以及 #6662 上观察到的 PR CI 失败。
CI Follow-up
After the first push, Ubuntu full CI no longer reproduced the CodeMirror getClientRects unhandled error, and packages/web-shell passed 83 files / 1340 tests in the GitHub Actions log. The same full CI run then exposed an unrelated timing-sensitive packages/webui heartbeat prompt cleanup test. This PR now also stabilizes that test by releasing the simulated terminal heartbeat failure only after submitPrompt has started.
CI follow-up 中文说明
第一次 push 后,Ubuntu full CI 已经没有再复现 CodeMirror getClientRects unhandled error,GitHub Actions 日志里 packages/web-shell 通过了 83 个文件 / 1340 个测试。随后同一次 full CI 暴露了一个无关的 packages/webui heartbeat prompt cleanup 计时型测试问题。这个 PR 现在也把该测试稳定化:只有在 submitPrompt 已经启动后,才释放模拟的 terminal heartbeat 失败。