Skip to content

test(web-shell): mock the provider module main.tsx actually imports in the boot test - #10526

Merged
yiliang114 merged 1 commit into
mainfrom
fix/main-boot-test-mock
Aug 30, 2026
Merged

test(web-shell): mock the provider module main.tsx actually imports in the boot test#10526
yiliang114 merged 1 commit into
mainfrom
fix/main-boot-test-mock

Conversation

@wenshao

@wenshao wenshao commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

What this PR does

main-boot.test.tsx mocks @qwen-code/webui/daemon-react-sdk, but main.tsx has imported DaemonWorkspaceProvider from @qwen-code/web-shell/daemon-react-sdk since the WebShell UI cutover (#9811), and the webui package no longer exports that path. Vitest resolves a vi.mock specifier even when nothing imports it, so the suite fails at collection with Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" package and both boot tests are red on main. This points the mock at the module the boot actually loads.

Why it's needed

Every PR's Test (ubuntu) job runs the web-shell unit suite; with this file failing at collection on main, the job cannot go green for anyone once the self-hosted pool gets through it.

Reviewer Test Plan

How to verify

cd packages/web-shell && npx vitest run client/main-boot.test.tsx — 2 failed on main (the missing-specifier error above), 2 passed with this change. Nothing else in the file changes; the mock's shape is unchanged.

Evidence (Before & After)

N/A (test-only; the vitest output above).

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

N/A

Risk & Scope

  • Main risk or tradeoff: none — a one-line mock path in a test.
  • Not validated / out of scope: nothing else.
  • Breaking changes / migration notes: none.

Linked Issues

Follow-up to #9811 and #10215 (the two commits whose combination left the mock pointing at a removed export).

中文说明

本 PR 的改动

main-boot.test.tsx mock 的是 @qwen-code/webui/daemon-react-sdk,但自 WebShell UI 切换(#9811)起 main.tsx 已从 @qwen-code/web-shell/daemon-react-sdk 导入 DaemonWorkspaceProvider,且 webui 包不再导出该路径。Vitest 即使没有模块导入也会解析 vi.mock 的说明符,因此该套件在收集阶段就报 Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" packagemain 上两个启动用例全红。本 PR 把 mock 指向启动时真正加载的模块。

为什么需要

每个 PR 的 Test (ubuntu) job 都跑 web-shell 单测;这个文件在 main 上收集即失败,一旦 self-hosted 池跑到它,任何 PR 的该 job 都无法变绿。

审查测试计划

如何验证

cd packages/web-shell && npx vitest run client/main-boot.test.tsx——main 上 2 失败(上述缺失说明符错误),本改动后 2 通过。文件中其它内容不变,mock 的形状不变。

证据(改动前后)

N/A(仅测试;见上述 vitest 输出)。

测试平台

OS Status
🍏 macOS ✅ 已测试
🪟 Windows ⚠️ 未测试
🐧 Linux ⚠️ 未测试

环境(可选)

N/A

风险与范围

  • 主要风险或取舍:无——测试里的一行 mock 路径。
  • 未验证 / 不在范围内:无。
  • 破坏性变更 / 迁移说明:无。

关联 Issue

#9811#10215 的后续(两者叠加后 mock 指向了已移除的导出)。

@qwen-code-ci-bot

qwen-code-ci-bot commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Deferred approval withheld — 1 PR CI workflow run(s) on 6c2430f did not finish green; see the updated table in the Stage 2 comment. Re-run @qwen-code /triage after fixes. finalize run

⚠️ 延迟审批已搁置 —— 6c2430f 有 1 个 PR CI workflow 未以绿色完成,详见 Stage 2 评论中已更新的表格。修复后可重新运行 @qwen-code /triage查看 finalize 运行

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Template looks good ✓

Problem: real, and verified. On main, client/main.tsx imports DaemonWorkspaceProvider from @qwen-code/web-shell/daemon-react-sdk, but this test still mocks @qwen-code/webui/daemon-react-sdk — a subpath the @qwen-code/webui package no longer exports. The failed Qwen Code CI runs on main (e.g. run 33270585556, Test (macos-latest, Node 22.x)) show exactly Error: Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" package during collection: 231 of 232 web-shell test files pass, 5222 of 5224 tests run, and the 2 boot tests in this file never get there.

Direction: clearly aligned — a test file that fails at collection on main keeps the web-shell suite red for every PR once its runner pool picks the job up. Re-pointing the mock at the module the boot actually loads is the right call; the alternative (dropping the mock) would change what the boot tests control.

Size: not applicable — test-only, +1/−1, no production lines.

Approach: the one-line re-point is the minimal fix. The mock's shape is unchanged, the new specifier resolves through the vitest alias to client/daemon-react-sdk.ts, which does export DaemonWorkspaceProvider, and I found no other lingering webui/daemon-react-sdk code references (only docs mention the old path, historically).

Risk: no elevated risk signals — test-only change, no high-risk paths matched.

Moving on to code review. 🔍

中文说明

感谢贡献!

模板完整 ✓

问题:真实存在,已验证。mainclient/main.tsx@qwen-code/web-shell/daemon-react-sdk 导入 DaemonWorkspaceProvider,而该测试仍 mock @qwen-code/webui/daemon-react-sdk——@qwen-code/webui 包已不再导出该子路径。main 上失败的 Qwen Code CI 运行(如 run 33270585556,Test (macos-latest, Node 22.x))在收集阶段恰好报 Error: Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" package:web-shell 232 个测试文件中 231 个通过,5224 个用例中 5222 个运行,本文件的 2 个启动用例未能运行。

方向:明确对齐——main 上收集即失败的测试文件会让每个 PR 的 web-shell 套件变红(一旦运行池排到该 job)。把 mock 指向启动时真实加载的模块是正确做法;备选方案(删掉 mock)会改变启动测试的控制面。

规模:不适用——仅测试,+1/−1,无生产代码行。

方案:一行改指向是最小修复。mock 形状不变,新说明符经 vitest alias 解析到 client/daemon-react-sdk.ts,该文件确实导出 DaemonWorkspaceProvider;除文档中的历史性提及外,未发现其他残留的 webui/daemon-react-sdk 代码引用。

风险:无升级风险信号——仅测试改动,未命中高风险路径。

进入代码审查 🔍

Qwen Code · qwen3.8-max

Reviewed at 6c2430f9cc6dabe1b928b618fb3ef91e08ea11ae · re-run with @qwen-code /triage

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

🖼️ web-shell visual preview

Rendered against a mock daemon (no real backend): the PR base vs this PR head 6c2430f. Only screenshots that changed are shown (flows below, if any, are head-only) — refreshes on every push.

Screenshots · before / after

No screenshot changes against the PR base.

Full-resolution recordings (.webm) are attached to the workflow run.

Qwen Code · web-shell visuals

@qwen-code-ci-bot

qwen-code-ci-bot commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Code review: clean. Before looking at the diff I would have done exactly this — re-point the vi.mock specifier at the module main.tsx actually imports, and keep the mock's shape (dropping the mock was the only real alternative, and it would change what the boot tests control). Two things worth recording from the verification pass: the new specifier resolves through the alias in vitest.config.ts to client/daemon-react-sdk.ts, which re-exports DaemonWorkspaceProvider, so the factory replaces a real module that exports what main.tsx imports; and the old @qwen-code/webui/daemon-react-sdk string survives nowhere else in code — only in design docs, as history. No blockers, no convention issues.

Testing evidence: this is an unattended CI run, so per the gate rules I did not build or execute any PR code — the evidence below is the PR's own CI, read through the API. The decisive signal is this PR's Test (ubuntu-latest, Node 22.x) job, which runs the web-shell suite including this file: without the fix that suite dies at collection (that is exactly what the failed runs on main show), so a green run here both exercises and pins the change. It is still in_progress as of this pass, with no red checks so far; the table updates in place once CI settles.

Final CI results for 6c2430f (auto-updated by the triage finalize job after CI completed):

Check Conclusion
Post Coverage Comment (ubuntu-latest, 22.x) ❌ failure
Test (ubuntu-latest, Node 22.x) 🚫 cancelled
web-shell E2E Smoke (ubuntu-latest, Node 22.x) 🚫 cancelled
Capture web-shell visuals (ubuntu-latest, Node 22.x) ✅ success
Classify PR ✅ success
Dependency CVE audit ✅ success
Desktop Shell (ubuntu-22.04) ✅ success
Desktop Shell (windows-2022) ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Secret scan (TruffleHog) ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

For reference, the before-state is documented from main itself: the web-shell suite in run 33270585556 (Test (macos-latest, Node 22.x); ubuntu was skipped in that run) ends with Error: Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" package, 231 of 232 files, 5222 of 5224 tests — the two missing tests are exactly the boot tests this file re-enables. That same run also carries one unrelated failure in src/acp-integration/acpAgent.test.ts (a deadline/timing test), which this PR does not claim to fix.

Not verified: runtime behavior beyond the suite — there is none to verify; this is a test-collection fix with zero production change.

中文说明

代码审查:干净。在看 diff 之前我的独立方案也正是如此——把 vi.mock 说明符指向 main.tsx 实际导入的模块,并保持 mock 形状(唯一真正的备选是删掉 mock,但那会改变启动测试的控制面)。验证过程中值得记录两点:新说明符经 vitest.config.ts 中的 alias 解析到 client/daemon-react-sdk.ts,该文件重新导出 DaemonWorkspaceProvider,因此工厂替换的是一个真实导出 main.tsx 所需符号的模块;旧的 @qwen-code/webui/daemon-react-sdk 字符串在代码中已无残留——仅在设计文档中作为历史提及。无阻塞项,无规范问题。

测试证据:这是无人值守的 CI 运行,按门禁规则未构建或执行任何 PR 代码——以下证据为本 PR 自身 CI 经 API 读取。决定性信号是本 PR 的 Test (ubuntu-latest, Node 22.x) job,它运行包含本文件的 web-shell 套件:没有这个修复,该套件在收集阶段即失败(main 上的失败运行正是如此),因此该 job 变绿即同时执行并钉住了此改动。本次 pass 时它仍在 in_progress,目前无红色 check;CI 结束后表格会原地更新(见英文部分的表格区域,由 finalize 工作流维护)。

供参考,修复前状态来自 main 本身:run 33270585556 的 web-shell 套件(Test (macos-latest, Node 22.x);该运行中 ubuntu 被跳过)以 Error: Missing "./daemon-react-sdk" specifier in "@qwen-code/webui" package 收尾,232 个文件中 231 个通过、5224 个用例中 5222 个运行——缺失的 2 个用例正是本文件恢复的启动测试。该运行另有一个与本 PR 无关的失败(src/acp-integration/acpAgent.test.ts 的 deadline/timing 用例),本 PR 并未声称修复它。

未验证:套件之外的运行时行为——无物可验;这是测试收集修复,零生产代码改动。

Qwen Code · qwen3.8-max

Reviewed at 6c2430f9cc6dabe1b928b618fb3ef91e08ea11ae · re-run with @qwen-code /triage

@qwen-code-ci-bot

Copy link
Copy Markdown
Collaborator

Confidence: 5/5 — verified problem, minimal fix, exactly what I would have done.

This is the kind of PR that is easy to take for granted: one line, test-only, no drama. But it unblocks something concrete — the web-shell suite cannot go green on main while this file fails at collection, and I confirmed that failure in main's own CI logs (run 33270585556, exact error quoted above) rather than taking the description on faith. The fix points the mock at the module the boot actually loads, the specifier resolves to a real export, and nothing else in the tree references the old path. Nothing to cut, nothing missing, nothing drive-by. Six months from now this reads as exactly the fix it is.

One CI workflow run is still in flight on the reviewed commit, so approval is deferred until CI lands green on 6c2430f9cc6dabe1b928b618fb3ef91e08ea11ae.

中文说明

Confidence: 5/5 —— 问题已证实,修复极小,与我的独立方案完全一致。

这类 PR 容易被轻看:一行、仅测试、毫无戏剧性。但它解锁的东西很具体:只要这个文件在收集阶段失败,web-shell 套件在 main 上就无法变绿——该失败已在 main 自己的 CI 日志中确认(run 33270585556,上文引用了精确报错),而非凭 PR 描述采信。修复把 mock 指向启动时真实加载的模块,说明符可解析到真实导出,代码树中再无对旧路径的引用。无可删减、无遗漏、无顺手改动。六个月后再看,它就是一个恰如其分的修复。

被审提交上仍有一个 CI 工作流运行在进行中,因此批准推迟到 CI 在 6c2430f9cc6dabe1b928b618fb3ef91e08ea11ae 上变绿之后。

Qwen Code · qwen3.8-max

Reviewed at 6c2430f9cc6dabe1b928b618fb3ef91e08ea11ae · re-run with @qwen-code /triage

@CanReader CanReader left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed the diagnosis — the old mock really was pointing at a module nothing imports.

What I checked at this commit:

  • client/main.tsx:4 imports DaemonWorkspaceProvider from @qwen-code/web-shell/daemon-react-sdk.
  • packages/web-shell/package.json exports ./daemon-react-sdk.
  • @qwen-code/webui — the path the test was mocking — has no daemon-react-sdk export at all.

So vi.mock('@qwen-code/webui/daemon-react-sdk', ...) was registering a factory against a specifier that never resolves in this test, and main.tsx was pulling in the real provider. The one-character-per-word fix is correct and the mock now intercepts what the module under test actually loads.

The thing worth flagging is the failure mode rather than this diff: a vi.mock whose specifier matches nothing is silently a no-op, so this class of drift produces a test that still passes while quietly exercising unmocked code. If the provider ever grows a side effect at import time, that would surface as a confusing failure far from the cause. Not something this PR needs to solve, but if the same pattern exists in sibling boot tests it is worth a sweep.

@qwen-code-ci-bot qwen-code-ci-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Downgraded from Approve to Comment: CI still running. Partially reviewed — gaps disclosed.

Not reviewed: reverse audit — stopped before round 1 by the review time budget.

Test Plan (not a blocker): 2 passed — this review observed 5102, 481 passed.

中文说明

⚠️ 已从批准降级为评论:CI still running。 仅完成部分审查,审查缺口已披露。

未审查:反向审计——评审时间预算不足,未能开始第 1 轮。

Test Plan(非阻断):2 passed — this review observed 5102, 481 passed

— qwen3.8-max via Qwen Code /review (v0.22.3)

@yiliang114
yiliang114 enabled auto-merge August 30, 2026 05:55

@chiga0 chiga0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings.

What I checked:

  • Diff (1 line): vi.mock('@qwen-code/webui/daemon-react-sdk', …)vi.mock('@qwen-code/web-shell/daemon-react-sdk', …)
  • Cross-file: packages/web-shell/client/main.tsx imports DaemonWorkspaceProvider from @qwen-code/web-shell/daemon-react-sdk (post-#9811 cutover) — the old mock path was targeting a specifier that package @qwen-code/webui no longer exports; the new path matches the real import.
  • packages/web-shell/package.json exports ./daemon-react-sdk — the mock target is resolvable.
  • CI: Integration Tests ✓, Desktop Shell ubuntu+windows ✓, Capture web-shell visuals ✓. Test (ubuntu-latest, Node 22.x) was CANCELLED (runner issue, not a test failure); Post Coverage Comment failed downstream of the cancellation. These are pre-existing infra issues unrelated to this change.
  • Existing reviews: CanReader independently confirmed the diagnosis; yiliang114 approved.

Reviewed with AI assistance.

@yiliang114
yiliang114 added this pull request to the merge queue Aug 30, 2026
Merged via the queue into main with commit 807eba2 Aug 30, 2026
99 of 105 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants