Skip to content

test(plugin-kanban): 在模块作用域预载 KanbanImpl,把 lazy chunk 移出 findBy 预算 (#3465) - #3474

Merged
yinlianghui merged 1 commit into
mainfrom
claude/issue-3465-kanban-test-preload
Aug 6, 2026
Merged

test(plugin-kanban): 在模块作用域预载 KanbanImpl,把 lazy chunk 移出 findBy 预算 (#3465)#3474
yinlianghui merged 1 commit into
mainfrom
claude/issue-3465-kanban-test-preload

Conversation

@yinlianghui

Copy link
Copy Markdown
Collaborator

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 ./ObjectKanban
  • ObjectKanban.tsx:24 又反向 import 回 ./index,另加 ./types
  • 全图没有任何一条静态边到达 KanbanImpl

KanbanImpl 唯一的可达路径是 index.tsx:124
React.lazy(() => import('./KanbanImpl')) —— 它只是登记了工厂,不执行导入。
于是首次 import('./KanbanImpl') 发生在 Suspense resolve 期间,即被计入 RTL
findBy1000ms 有界窗口。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):

条件 before after
单文件(warm,3 次) 356 / 359 / 372ms 355 / 355 / 356ms
plugin-kanban 全量套件 386ms 384ms

差异在噪声范围内,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):

  • 目标文件 before 与 after 均绿(各 3 次,2 passed)
  • pnpm exec vitest run packages/plugin-kanban/ before/after 均 8 files / 39 tests passed
  • pnpm 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

…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
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Aug 6, 2026 9:10am

Request Review

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Main entry (gzip) 28.1 KB 350 KB
Entry file index-D_L7OkcS.js
Status PASS

📦 Bundle Size Report

Package Size Gzipped
app-shell (index.js) 8.47KB 3.09KB
app-shell (runtime-config.js) 7.42KB 2.32KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 7.57KB 2.97KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 1.17KB 0.53KB
auth (AuthProvider.js) 22.10KB 4.37KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.13KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.64KB 2.21KB
auth (SocialSignInButtons.js) 9.60KB 3.89KB
auth (UserMenu.js) 3.40KB 1.22KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 35.76KB 9.11KB
auth (createAuthenticatedFetch.js) 4.37KB 1.69KB
auth (index.js) 2.35KB 1.07KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 4.91KB 0.87KB
auth (useIsWorkspaceAdmin.js) 1.61KB 0.85KB
collaboration (CommentThread.js) 21.35KB 5.70KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.49KB 2.64KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.65KB 0.73KB
collaboration (useCollaborationTranslation.js) 5.30KB 2.24KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 479.63KB 105.43KB
core (index.js) 2.47KB 0.91KB
create-plugin (index.js) 9.28KB 2.98KB
data-objectstack (index.js) 136.30KB 34.76KB
fields (index.js) 229.92KB 56.48KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (currency.js) 1.22KB 0.64KB
i18n (i18n.js) 4.32KB 1.77KB
i18n (index.js) 2.65KB 1.06KB
i18n (pickLocalized.js) 1.70KB 0.83KB
i18n (provider.js) 9.48KB 3.27KB
i18n (useObjectLabel.js) 26.14KB 6.07KB
i18n (useSafeTranslation.js) 3.26KB 1.44KB
layout (index.js) 38.53KB 10.71KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.74KB
mobile (index.js) 1.50KB 0.62KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 2.53KB 0.85KB
mobile (useResponsive.js) 0.71KB 0.42KB
mobile (useResponsiveConfig.js) 1.36KB 0.63KB
mobile (useSpecGesture.js) 4.05KB 1.53KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 8.75KB 3.06KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 3.67KB 1.12KB
permissions (evaluator.js) 4.41KB 1.44KB
permissions (index.js) 0.91KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.52KB
permissions (usePermissions.js) 1.55KB 0.71KB
plugin-ai (index.js) 15.71KB 3.79KB
plugin-calendar (index.js) 44.98KB 12.37KB
plugin-charts (index.js) 61.04KB 17.31KB
plugin-chatbot (index.js) 180.09KB 42.72KB
plugin-dashboard (index.js) 112.03KB 28.88KB
plugin-designer (index.js) 210.51KB 42.51KB
plugin-detail (index.js) 232.53KB 57.37KB
plugin-editor (index.js) 2.46KB 1.10KB
plugin-form (index.js) 111.54KB 26.97KB
plugin-gantt (index.js) 162.55KB 39.57KB
plugin-grid (index.js) 185.25KB 49.08KB
plugin-kanban (index.js) 48.03KB 13.22KB
plugin-list (index.js) 105.19KB 25.39KB
plugin-map (index.js) 16.81KB 5.24KB
plugin-markdown (index.js) 13.72KB 4.69KB
plugin-report (index.js) 40.58KB 10.58KB
plugin-timeline (index.js) 25.76KB 7.33KB
plugin-tree (index.js) 8.50KB 2.88KB
plugin-view (index.js) 84.03KB 20.55KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.71KB 3.53KB
providers (index.js) 0.44KB 0.22KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.67KB 2.37KB
react (LazyPluginLoader.js) 3.77KB 1.33KB
react (SchemaRenderer.js) 19.28KB 6.38KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 1.02KB 0.55KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 4.09KB 1.74KB
sdui-parser (index.js) 4.47KB 2.03KB
sdui-parser (parse.js) 10.04KB 2.82KB
sdui-parser (types.js) 0.29KB 0.24KB
sdui-parser (validate.js) 4.69KB 1.48KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 0.99KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 0.20KB 0.18KB
types (crud.js) 0.20KB 0.18KB
types (data-display.js) 0.20KB 0.18KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.87KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-retry.js) 4.32KB 2.02KB
types (index.js) 2.46KB 1.21KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 0.20KB 0.18KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 0.20KB 0.18KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (spec-report.js) 5.05KB 1.93KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 0.20KB 0.18KB
types (ui-action.js) 3.40KB 1.71KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@yinlianghui
yinlianghui marked this pull request as ready for review August 6, 2026 13:51
@yinlianghui
yinlianghui added this pull request to the merge queue Aug 6, 2026
Merged via the queue into main with commit 09edc61 Aug 6, 2026
18 checks passed
@yinlianghui
yinlianghui deleted the claude/issue-3465-kanban-test-preload branch August 6, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[finding] KanbanRenderer.uncolumned.test.tsx 的两条断言落在 React.lazy 边界之后,未按 §测试纪律 在模块作用域预载 ./KanbanImpl

2 participants