Skip to content

test(plugin-gantt): fold seven ObjectGantt fetch and row pins onto one shared harness - #30725

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-3t7ug5
Nov 6, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-3t7ug5

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Sales · project thread
Part of #29469

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:甘特图组件 7 个按 issue 单独成文件的测试,合并进一个共享测试文件 ObjectGantt.harness.test.tsx,每个原文件变成文件里一个顶层 describe;断言一字未改。
  • 为什么改:这 7 个文件用同一套 mock,却各自重新加载整张模块图,时间几乎全花在加载上。合并后只加载一次:本地同机实测这 7 个 pin 从 20.8 s CPU 降到 8.3 s(-60%),整个 ObjectGantt 测试族 -10%。
  • 风险与回滚:只动测试文件,不发布任何东西;风险是块与块之间串状态,已全包跑绿排除。回滚 = revert 本 PR。
  • 先看:ObjectGantt.harness.test.tsx 开头 70 行(共享 mock 与 standIns 槽位);再看任一块的 beforeEach。
  • 两分钟验证:在 ui/ 下跑 pnpm exec vitest run packages/plugin-gantt/src/ObjectGantt.harness.test.tsx,应见 1 个文件、35 个测试全过。
  • 需要你做的:无,席位落地。

What changes

Slice 1 of the ObjectGantt* family in the shared-setup rollout that ruling 6583487846 on #29469 orders, in the shape of the #25911 pilot (PR #26309). Seven ObjectGantt pins render the real ObjectGantt over the same three mocks: sonner's toast, a ./GanttView stand-in, and @object-ui/plugin-detail with RecordDetailDrawer and deriveRecordPageHref stubbed out. Only the GanttView stand-in differed between them, in which task attributes it writes to the DOM. They now live in one new file, ui/packages/plugin-gantt/src/ObjectGantt.harness.test.tsx:

  • Each former file is a top-level describe named after it (ObjectGantt.fetchGate-7225 and so on), with its docblock above it.
  • The ./GanttView mock reads a vi.hoisted slot (standIns.ganttView), and each block installs its own stand-in, verbatim, in a beforeEach.
  • Everything that was module-level in a former file (fixtures, adapters, call logs, helpers, hooks) moved inside its block unchanged, re-indented by two spaces. A sorted line diff of each former file against its block shows only the license header, the imports, the three vi.mock calls and the wrapper lines.
  • The sonner and plugin-detail mocks were byte-identical in all seven files and are declared once.
  • ./index is imported once (one block renders through SchemaRenderer), so object-gantt is registered for the whole file. No block asserts that key absent.

The test-only diff: no src file, no changeset (skip-changeset: @object-ui/plugin-gantt ships dist, README.md, CHANGELOG.md and LICENSE only). Besides the move, comments that named a folded file now name its block: five inside the harness, one in ObjectGantt.expandFls-7230.test.tsx and one in __tests__/recordSourceInputs-10394.test.tsx.

Why

Every dom-project test file pays a fixed cost (environment, setup and the module graph) before its first test runs, and for these seven that fixed cost was about 95 % of their CPU (19.9 of 20.9 s, run 1). One harness file pays it once. #29469 rolls the #25911 pilot out component by component; this is the first ObjectGantt slice.

Tests

Former file → describe (no title or assertion dropped)

Mechanical count: a TypeScript AST walk of each former file at 4bf9a2d7e (it/test titles and expect( calls) against the describe of the same name in the harness at this PR's head.

former file it before it after expect( before expect( after titles identical
ObjectGantt.fetchGate-7225.test.tsx 5 5 15 15 yes
ObjectGantt.rowCeiling-7210.test.tsx 4 4 15 15 yes
ObjectGantt.hostDataProp-7210.test.tsx 2 2 9 9 yes
ObjectGantt.emptyHostData-7333.test.tsx 5 5 16 16 yes
ObjectGantt.inlineQueryKeys-8769.test.tsx 8 8 23 23 yes
ObjectGantt.searchTerm-10250.test.tsx 7 7 16 16 yes
ObjectGantt.ruleArrayFilter-10767.test.tsx 4 4 12 12 yes
total 35 35 106 106 yes

The run agrees: the seven files reported 35 passed tests, and the harness reports the same 35.

CPU before and after (local A/B, one machine)

CI after: NOT MEASURED. The per-file timings reporter (#29517) uploads its reports on main's full-battery push and schedule runs only, never on a pull request, and ui/scripts/test-shard-timings.json was last regenerated on 2026-10-19. The first CI after-reading is the first full-battery run on main after this merges. The CI before-reading from that dataset is 35.6 s of module time for the seven files.

Local A/B on one 4-vCPU container, same command both legs, run twice each, from ui/: pnpm exec vitest run <every ObjectGantt*.test.ts(x) in plugin-gantt> --maxWorkers=2, with a throwaway reporter reading each module's diagnostic(). Fixed = environment + prepare + setup + import. The "before" leg is 4bf9a2d7e's seven files restored into this branch's tree and the harness removed, so both legs run the same 49 other files. Shared-box seconds.

files tests passed fixed CPU test CPU total CPU wall
ObjectGantt family, before (run 1 / run 2) 56 327 164.0 / 165.3 s 11.0 / 11.1 s 174.9 / 176.4 s 92.6 / 94.1 s
ObjectGantt family, after (run 1 / run 2) 50 327 146.7 / 145.1 s 11.1 / 10.6 s 157.8 / 155.7 s 84.1 / 83.2 s
the seven pins alone, before → after (run 1) 7 → 1 35 → 35 19.9 → 7.4 s 1.0 → 0.8 s 20.9 → 8.2 s
the seven pins alone, before → after (run 2) 7 → 1 35 → 35 19.6 → 7.6 s 1.1 → 0.8 s 20.7 → 8.3 s

The seven pins went from 20.8 s to 8.3 s of CPU (−60 %), and the family from 175.7 s to 156.8 s (−10.8 %), wall −10 %. Each folded file saved about 2.1 s of fixed cost on this box; the harness's own fixed cost (7.5 s) is that of one cold file. The A/B ran on 10033623; the head adds one comment-only commit (f18fd963).

Acceptance notes

  • Why seven and not the whole family. The 55 ObjectGantt.* pin files carry 29 different GanttView stand-ins and seven different mock sets. These seven share one mock set exactly, and folding them moves 2,650 changed lines, under the 3,000-line bar. The other files on the same three mocks (colorFieldLadder-7243, elementDataSource, invalidationRefetch-10035, propertiesBag-10859, retiredApiProvider-12325) are the family's next slice, into this same file, after this one merges.
  • References outside this PR's file surface still name the old files. Five source files (ObjectGantt.tsx, index.tsx, plugin-timeline/src/ObjectTimeline.tsx, plugin-list/src/ListView.tsx, plugin-view/src/ObjectView.tsx) and seven test files in other packages (plugin-list ×5, react ×1, plugin-view ×1) mention a folded file by name in a comment. The claim forbids source edits, and the stems still find the right block: git grep ObjectGantt.hostDataProp-7210 lands on its describe in the harness. Noted, not filed.
  • The react-i18next NO_I18NEXT_INSTANCE warning printed once per former file before, and once for the harness now. It was there before this change.

Verification

At head f18fd963:

  • pnpm exec vitest run packages/plugin-gantt/ --maxWorkers=2 from ui/: 100 files passed, 1 skipped; 788 tests passed, 114 skipped. The skipped file and tests are skipped on main too.
  • pnpm run type-check in ui/packages/plugin-gantt (tsc --noEmit && tsc -p tsconfig.test.json), after turbo run build --filter='@object-ui/plugin-gantt^...': exit 0, 0 error TS. tsc -p tsconfig.test.json --listFilesOnly lists the harness (101 test files in the program).
  • eslint on the harness: 0 errors, 43 warnings, all no-explicit-any. The seven former files gave the same 43 warnings at 4bf9a2d7e.
  • pnpm run lint in ui/packages/plugin-gantt: exit 0, 0 errors.
  • Derived gates (node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack): 26 derived, 26 run, each exit 0 (24 quick checks re-run at f18fd963; pnpm check:type-check-debt and pnpm --dir ui exec vitest run scripts/, 170 files passed and 2 skipped, 4970 tests passed). --ran reconciliation: 26 derived, 26 run, 0 NOT-MEASURED.
  • Size: git diff --shortstat 4bf9a2d7e f18fd963 is 10 files, +1297 / -1353, 2,650 changed lines, under 3,000. The branch merges cleanly onto main at 6ef7f583 (no commit since the base touches plugin-gantt).

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (packages/spec not touched.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (ui/ is linted by its own config; the package lint is above.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Nothing publishes: skip-changeset.)
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the maintainer quick-read is the allowed Chinese section).

Generated by Claude Code

🤖 Generated with Claude Code

https://claude.ai/code/session_01L6bhgXNVxCQk1CCy55gFjQ

…e shared harness

The seven ObjectGantt pins that render the real component over the same three
mocks (sonner's toast, a GanttView stand-in, and plugin-detail's drawer stubbed
out) now live in ObjectGantt.harness.test.tsx, one top-level describe per
former file. Each block installs its own GanttView stand-in in a beforeEach
through a vi.hoisted slot the shared mock reads. Fixtures, hooks and
assertions move verbatim: 35 it titles and 106 expect( calls before and after.

Part of the shared-setup rollout to the four component families.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgXNVxCQk1CCy55gFjQ
… the shared harness

Comments inside the harness that named a sibling pin's former file now name
its block in this file, and the two plugin-gantt test files that pointed at
a folded file now name the harness and the block.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L6bhgXNVxCQk1CCy55gFjQ
@objectstack-fleet objectstack-fleet Bot added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Nov 5, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-sales · session_01L6bhgWn6zhNa4LL7VB1rtL

维护者速读

  • 改了什么:甘特图组件 ObjectGantt 的 7 个「一张卡一个文件」的测试,用的是同一套 mock,现在合并进一个共享的测试文件 ObjectGantt.harness.test.tsx。原来每个文件变成里面的一个顶层 describe,断言一字未改。
  • 为什么改:Tests grow 2.5 times faster than source: measure the per-fix test weight and the #25911 pilot, then roll the shared-setup merge out to the heaviest components or retire it #29469,裁决 6583487846:把共享 setup 合并推广到四个组件族,每族一个 PR,本 PR 是甘特图族的第一片。这样模块图只加载一次,这 7 个测试的 CPU 时间从约 20.8 秒降到约 8.3 秒。
  • 风险与回滚:只动测试文件,不改源码、门禁或 CI。回滚即撤本 PR。
  • 先看:ui/packages/plugin-gantt/src/ObjectGantt.harness.test.tsx 开头的说明和 standIns 槽位。
  • 两分钟验证:cd ui && pnpm exec vitest run packages/plugin-gantt/src/ObjectGantt.harness.test.tsx,预期 35 例全绿。
  • 需要你做的:无,席位落地。
  • 席位意见:可合。卡还有后续几片(甘特图第 1b 片、ListView、ObjectView、RecordDetailView),所以用 Part of。

席位核对 — ACCEPT · head f18fd96

  • 形态:10 文件 +1,297/−1,353 = 2,650 行。check-governed-merges --pr 30725:0/10 条路径落在受管面,≤ 3000。Part of #29469,目标 main,标签 skip-changeset(只有测试)。删了 7 个 pin 文件,新增 1 个 harness 文件;另外两个测试文件各改一行注释里的文件名。全在认领 6671543193 的第 (1) 族文件面内,源文件、门禁、CI 和 .changeset/ 都没动。
  • 契约:Clause-② no,Metadata-protocol none,与认领一致。
  • 席位自己复数:从 main 上的 7 个原文件和 head 上的 harness 各自计数:it( / test( 35 = 35,expect( 106 = 106,35 个测试标题排序后完全一致。7 个顶层 describe 各带原 issue 号。没有新增 .only、.skip 或 .todo。这 7 个文件不在 ui/scripts/test-shard-timings.json 的键里,所以不需要改键。
  • 前提实测:dev 报告 6672420725。harness 单文件 35 例绿;plugin-gantt 全包 100 文件、788 例绿,跳过数与 main 相同。同一台机器本地 A/B 各跑两轮:7 个 pin 的 CPU 时间 20.9 / 20.7 秒降到 8.2 / 8.3 秒(−60%),整个甘特图族降 10.8%。CI 上合并后的读数还没有,因为逐文件耗时只在 main 的全量跑里上传,合并后可以从那里读。派生门禁 26/26 exit 0,--ran 0 NOT-MEASURED;type-check 和 lint 都是 0 错误。没有做消融,因为没有改变任何被测行为,断言是原样搬过去的。
  • 门禁 check-runs:head 上 60 个,44 success,16 skipped,0 红。mergeable_state clean。
  • 接受的偏差:认领要求逐个文件给出 CPU 前后读数,CI 读数优先、没有就用本地 A/B。这里用的是同机本地 A/B,原因如上。
  • 范围外:5 个源文件和其他包里 7 个测试文件的注释仍写着被合并掉的旧文件名。认领禁止改源文件;这些文件名的词干仍然能用 git grep 找到对应的 describe,所以不立卡,最后一片时一并处理。
  • 落地条款:中继 pr_ready + automerge_enable。卡不关(Part of),pm:dispatched 保留到最后一片合并。合并后卡线程把分支从最新的 main 重开,再做第 1b 片。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant