test(plugin-kanban): 在模块作用域预载 KanbanImpl,把 lazy chunk 移出 findBy 预算 (#3465) - #3474
Merged
Merged
Conversation
…3465) KanbanRenderer.uncolumned.test.tsx 的两条断言都落在 React.lazy 边界之后, 而文件顶部只 import './index' —— 它仅登记 lazy 工厂,并不执行动态 import, 所以首次 import('./KanbanImpl') 被计入 RTL findBy 的 1000ms 有界窗口。 按 AGENTS.md §测试纪律,在模块作用域直接 import './KanbanImpl'(specifier 与 index.tsx:124 完全一致,ESM 按解析后的 specifier 缓存),成本进入 import 阶段, 不受任何 test/hook 超时约束。沿用 PR #3464 两个姊妹文件的写法。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GTRjn8xBqp75dk7kFupVRt
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3465
问题
packages/plugin-kanban/src/KanbanRenderer.uncolumned.test.tsx的两条断言(
findByText('Orphaned card')与findByText('Matches'))都落在React.lazy边界之后,而文件顶部只
import { KanbanRenderer } from './index'。关键点:import './index' 并不会预热 KanbanImpl。已核对
./index的静态图:index.tsx:15只静态 import./ObjectKanbanObjectKanban.tsx:24又反向 import 回./index,另加./typesKanbanImplKanbanImpl唯一的可达路径是index.tsx:124的React.lazy(() => import('./KanbanImpl'))—— 它只是登记了工厂,不执行导入。于是首次
import('./KanbanImpl')发生在 Suspense resolve 期间,即被计入 RTLfindBy的 1000ms 有界窗口。AGENTS.md §测试纪律 记录过满并行下一次首包import()实测可达 976ms(占该预算 97.6%),这就是 latent flake 的根因。heavyDomTests成员身份帮不上忙:vitest.setup.dom.tsx只预载components / fields / plugin-dashboard / plugin-grid,没有 plugin-kanban;
何况即便有,
./index也不会 warm 到KanbanImpl。改动
按 §测试纪律,在模块作用域直接
import './KanbanImpl';并附一行注释说明原因,写法沿用 PR #3464 的两个姊妹文件(
ObjectKanban.overlayTitleI18n.test.tsx、ObjectKanban.overlayTitleNoProviderFallback.test.tsx)。成本进入 import 阶段,不受任何 test/hook 超时约束。
specifier 与
index.tsx:124完全一致(两个文件同在packages/plugin-kanban/src/,./KanbanImpl解析到同一个绝对模块 id)—— ESM 按解析后的 specifier 缓存,这样组件自己的 lazy 工厂才会立刻 resolve。
没有用
beforeAll:它受更窄的hookTimeout(10s)约束,且已被object-ui/no-dynamic-import-in-test-hook机械禁止。单文件 +13 行(1 个 import + 注释),纯测试改动,无 changeset。
验证 —— 计时是 null result,如实报告
派发单预期「after 首个测试更快」。实测并非如此,这里如实记录:本改动移除的是
一场竞态,不是一条失败断言,而空闲容器复现不出 CI 满并行的饱和管线条件。
首个测试耗时(
--reporter=verbose,repo root,--maxWorkers=2):差异在噪声范围内,
import/tests阶段拆分同样看不出成本迁移(before import 656-724ms、tests 385-395ms;after import 625-669ms、tests 379-386ms)。
清掉
node_modules/.vite冷跑也没拉开差距。原因是:空闲容器上这次
import()只要几十 ms,而首个测试的 ~355ms 主要是React + happy-dom 真实渲染看板(dnd-kit 初始化、列与卡片),预载并不消除这部分。
976ms 那个数字来自全仓 ~300 个 DOM 文件并行时饱和的 transform 管线,8 个文件、
--maxWorkers=2的包级套件复现不出来。所以本 PR 的依据是结构性的(上面的静态图追踪证明 lazy 边界确实横在断言之前),
而不是本地计时差。可观察到的旁证是 before 跑的文件内落差:首个测试 ~370ms、
第二个 ~25ms —— 首次加载的成本确实压在第一条
findBy上。其余检查(均在
flock /tmp/os-heavy-verify.lock下,--max-old-space-size=4096):pnpm exec vitest run packages/plugin-kanban/before/after 均 8 files / 39 tests passedpnpm exec eslint该文件:0 error 0 warning;--print-config确认object-ui/no-dynamic-import-in-test-hook在该路径上确实生效pnpm --filter @object-ui/plugin-kanban type-check:exit 0(先
pnpm --filter '@object-ui/plugin-kanban^...' build—— 新 worktree 未建依赖时的 TS2307 是 stale-artefact 陷阱,与本改动无关)
pnpm check:control-bytes:OK(3673 个文件);另做越界自扫grep -naP无匹配,file报 UTF-8 text未改动其他 kanban 测试文件:
registration.test.tsx的断言在边界之前(它 mock 掉./ObjectKanban并同步getByTestId),cardPredicateScope.test.tsx已有对./KanbanImpl的静态 import。Generated by Claude Code