Repository navigation
test(plugin-view): fold nine ObjectView pins over stand-in child renderers onto one shared harness - #30872
Merged
Conversation
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxkcTyv8QYYuvpzAFL
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibxkcTyv8QYYuvpzAFL
Contributor
Author
|
domain:ui#2 · os-tesla · session_01L9qibw7DekEe3wx5f3zphf 席位核对 · ACCEPT · 2026-11-06T08:32Z · head
|
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.
Requested by Tesla · project thread
Part of #29469
Clause-②: no
Metadata-protocol: none
维护者速读
ObjectView(plugin-view包)的 9 个单卡测试文件合进一个新的共享测试文件ObjectView.harness.test.tsx。这 9 个文件原本各自 mock 同样三处(SchemaRenderer、ObjectGrid、ObjectForm换成替身),只是替身记录的东西不同;现在 mock 只写一次,每块在自己的beforeEach里装上自己的替身,断言一字未改。plugin-view里整个 ObjectView 测试族快约 13%。html元素的lang、替身槽位)和三种乱序运行排除。回滚 = revert 本 PR。ObjectView.harness.test.tsx开头 145 行(三个 mock 怎么读替身槽位,以及restoreAfterBlock()),再看ObjectView.formLabelsI18nLabel-10993一块(唯一挂I18nProvider的块,会在html元素上留下lang)。ui/下跑pnpm exec vitest run packages/plugin-view/src/__tests__/ObjectView.harness.test.tsx,应见 1 个文件、55 个测试全过。0ec2ac43的 diff 复核:10 个文件全在plugin-view/src/__tests__/,9 个共用三件 mock 的 ObjectView 单卡文件并入新的ObjectView.harness.test.tsx,mock 只声明一次、经vi.hoisted槽位取各块的替身,每块以restoreAfterBlock()开头复原注册表、存储、<html lang/dir>与槽位;断言与标题一字未改(it(47=47、expect(97=97),乱序三种种子全过;CI 全绿,纯测试改动无发布面,不欠契约复审。同意落地。What changes
Slice 3a, the first of the two
ObjectView*PRs of the shared-setup rollout (ruling 6583487846 on #29469; seat amendment 2, 6672694520: at most two PRs per family). Nine pins inui/packages/plugin-view/src/__tests__/render the realObjectViewover the same three mocks, and become one new file,ObjectView.harness.test.tsx:@object-ui/reactwithSchemaRendererreplaced, a freshSchemaRendererContextand the data-change bus (subscribeDataChanges,notifyDataChanged) made no-ops;@object-ui/plugin-gridwithObjectGridreplaced;@object-ui/plugin-formwithObjectFormreplaced. The nine differed only in the three stand-ins (what they record, what they draw). The harness declares each mock once, reading its stand-in from avi.hoistedslot (standIns.schemaRenderer,.objectGrid,.objectForm), the wayObjectGantt.harness.test.tsxreads itsGanttViewstand-in. A mock whose slot is empty throws, naming the slot, so a block can never draw an earlier block's stand-in.describenamed after its file stem, with its docblock above it. Its first lines arerestoreAfterBlock()and abeforeEachthat installs its three stand-ins, each copied verbatim from that file's mock factory; everything else is moved verbatim, re-indented by two spaces. The comment that sat aboveObjectView.tableSortKey-10664's mocks sits above itsbeforeEach. The 9 files are deleted.restoreAfterBlock(), the first line of every block, isListView.harness.test.tsx's helper plus the three slots. A probe that logged the state at each block's first test, with the helper's body removed, found:ObjectView.formLabelsI18nLabel-10993(the one block that mounts anI18nProvider) leftlang="zh"anddir="ltr"on thehtmlelement for every block after it, and every block after the first started with the previous block's three stand-ins installed. No block here registers a renderer or swapslocalStorage; the registry and storage halves stay for the next block that does. With the helper, the same probe finds every block starting from the same state (registry: every key, renderer name and meta equal;localStoragethe window's own getter, both storages empty; nolang/dir; react-i18next's globalundefined; all three slots empty; an emptybody; no new global), in declaration order and under three shuffled orders.I18nProvidercomes from@object-ui/i18n, as in the former file.No other file names any of the 9:
git grep -Fof each stem overui,scripts,packages,contentand.githubgives no hit outside the file itself, so no comment needed updating. Two blocks' prose names files that stay (ObjectView.sortSink.test.tsx,ObjectView.formTitleI18n.test.tsx); those references still hold.One harness file, in one package. The
ObjectViewfamily spans two packages: these pins test@object-ui/plugin-view'sObjectView, and theObjectView.*pins inui/packages/app-shell/src/views/test the Console'sObjectViewin@object-ui/app-shell, a different component over a different mock set. This PR adds only the plugin-view harness; see Acceptance notes for why this cluster comes first.Test files only: no source file, no changeset (
skip-changeset).@object-ui/plugin-viewbuilds from its entry withvite build, and no entry imports a test file.Tests
Former file → describe (no title or assertion dropped)
TypeScript AST walk of each former file at
e603385f(themainthis was cut from, where they still exist) against thedescribeof the same name in the harness at this PR's head. Anitis a call toit/test(anit.each(...)(...)counts once); titles are thedescribe > itpaths under the block, compared as sorted lists.ObjectView.calendarInitialDate-28102.test.tsxObjectView.tableSortKey-10664.test.tsxObjectView.kanbanDeclaredLanes-28211.test.tsxObjectView.namedViewEditInlineFold-5144.test.tsxObjectView.formLabelsI18nLabel-10993.test.tsxObjectView.refreshSignal.test.tsxObjectView.timelineBinding-7070.test.tsxObjectView.readersRetired-6152.test.tsxObjectView.filterSources.test.tsxThe 47
itcalls run as 55 tests (it.eachrows), in the harness as in the nine files: the A/B legs below ran 507 tests on both sides.A line-multiset comparison (every non-blank line of the 9 files, trimmed, against the harness) finds no test, fixture or comment line dropped: what the files had and the harness lacks is the 9 license headers, the import lines, the
vi.mock(wrappers and their shared keys, and the stand-ins' first lines, which now open withstandIns.SLOT =.CPU before and after (local A/B, one machine)
CI after: NOT MEASURED: the per-file timings reporter (#29517) uploads on
main's full-battery runs only. Its first after-reading is the first full-batterymainrun after this merges.Local A/B on one 4-vCPU container, under
os-verify-lock(shared-box seconds), same command both legs, fromui/:pnpm exec vitest run packages/plugin-view/src/__tests__/ObjectView. --maxWorkers=2, with a throwaway reporter reading each module'sdiagnostic(). Fixed = environment + prepare + setup + collect. The "before" leg restores the 9 files from the base into the branch's tree and removes the harness, so both legs run the same 46 other files. Run order: before 1, before 2, after 1, after 2, before 3.The family went from 261.6 s to 227.5 s of CPU on average (−13.0 %), wall from 137.1 s to 119.0 s (−13.2 %); the nine files' 39.0 s became 6.0 s in the harness (−85 %, about 33 s saved). The three before runs spread 13.6 s, so the change is well outside run-to-run noise.
Acceptance notes
plugin-view/src/__tests__/the largest same-setup cluster is the pins over the three-mock trio above: 31 of the 54 per-issueObjectView.*pins declare exactly those three mocks with the same overridden keys (SchemaRenderer,SchemaRendererContext,subscribeDataChanges,notifyDataChanged;ObjectGrid;ObjectForm), 7,367 lines.ObjectView.test.tsxis the component's main suite, not a per-issue pin, and is not counted. The app-shell side (ui/packages/app-shell/src/views/, 87 files) has 24 files that mock nothing, half of them.test.tsin theunitproject (not isolated per file, so a fold saves nothing), and its 63 mocked files spread over more than 40 different mock sets. Of the 31, this PR takes only files with none of the following:vi.spyOn,vi.stubGlobal,vi.useFakeTimersorvi.stubEnv(4), avi.hoistedorglobalThisslot of their own (3), a side-effect import other than@testing-library/jest-dom(0), an entry on thedom-heavylist inui/vitest.config.mts(0), and any other file naming it (18; some files fail more than one check). One of the named,ObjectView.contractEnvelope-6726, is named by path inscripts/check-vi-mock-inherit.mjs, a ledger outside__tests__, so it stays a file of its own. That leaves 12; this PR folds the 9 smallest, the most files per changed line: 1,317 lines moved make 2,589 changed lines, and the next smallest (ObjectView.tableColumnsForwarding, 298 lines) would take it past 3,000.tableColumnsForwarding,strayGroupByLane-9242,canonicalTableKeys), the trio pins another test file names (their comments get updated in the same PR, as amendment 2 asks), and the app-shell pins, which would need a second harness file in@object-ui/app-shell.check:new-line-citationsreads 0 new citations..claude/agents/os-dev.mdrule 2) reserves both for the seat at hand-over, so the dev set neither.Verification
At head
0ec2ac43, afterpnpm install --frozen-lockfileand building the closure (turbo run buildfor@objectstack/spec,formula,lint,client,metadata-protocol, then--filter='@object-ui/plugin-view^...'fromui/, underos-verify-lock, VERDICT command-exit 0):pnpm exec vitest run packages/plugin-view/ --maxWorkers=2fromui/underos-verify-lock(VERDICT command-exit 0): 71 files, 720 tests, all passed (this branch removes 9 files and adds 1).pnpm run type-checkinui/packages/plugin-view(tsc --noEmit && tsc -p tsconfig.test.json): exit 0, 0error TS. The harness is in thetsconfig.test.jsonprogram (--listFilesOnly).eslinton the harness fromui/: exit 0, 0 errors, 47 warnings (allno-explicit-any), the same 47 the 9 former files give ate603385f.--sequence.shuffle.testswith seeds 11, 222 and 3333 (each reorders the nine blocks). The block-boundary probe above (registry renderer + meta per key,localStoragedescriptor and both storage lengths, thehtmlelement'slang/dir, react-i18nextgetI18n(), the three slots,body, globals added since import) reads every block start identical in all four orders, and with the helper's body removed reads thelang/dirand slot leaks named in What changes. The probe was a throwaway copy of the harness, deleted.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack, change set 10 paths against merge basee603385f, 2,589 changed lines, under 3,000): 26 derived, 26 run with stdin from/dev/null, each exit 0 captured before any pipe;pnpm --dir ui exec vitest run scripts/underos-verify-lock(VERDICT command-exit 0) gave 170 files passed and 2 skipped, 4,979 tests passed and 2 skipped;node scripts/check-sdui-manifest.mjsand its--self-testexit 0.--ranreconciliation: 26 derived, 26 run, 0 NOT-MEASURED, 0 UNRUN.pnpm check:new-line-citationsfromui/: exit 0, 0 new citations.mainbefore opening:mainmoved paste603385f(tocf478ea3), and none of those commits touchesui/packages/plugin-view,ui/vitest.config.mtsor theui/vitest.setup.*files.mainat those paths, differ for none.Human Minimum
packages/specholds no runtime logic. (packages/specnot touched.)pnpm lintpasses. (ui/is linted by its own config; the harness lint is above.)main, one pull request.skip-changeset.)packages/spectouched: its generated artifacts are regenerated and committed. (Not touched.)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.