Skip to content

Commit 81deb54

Browse files
test(app-shell): fold seven RecordDetailView pins over the shared chrome mocks onto one harness (#31051)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao6CPiJykR19ZgQhCLgp8Wkm)_ Part of #29469 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:记录详情页 `RecordDetailView`(`app-shell` 包)的 7 个单卡测试文件并入新建的共享测试文件 `RecordDetailView.harness.test.tsx`,每个原文件变成一个顶层 `describe`,断言和标题一字未改;这 7 个文件原本各自声明的同一组 8 个 mock 只在共享文件开头声明一次。 - **为什么改**:#29469 第四族、也是最后一族 RecordDetailView 的第一片(席位修订 2:每族最多两个 PR)。本地同机实测,这 7 个文件的 CPU 从约 37 秒降到并入后约 7 秒;这一族 103 个文件全部在 `app-shell/src/views/`,最大的同 setup 簇是 44 个 mock 逐字相同的文件,本片取其中最小的 7 个干净文件,第二片接着折同一簇。 - **风险与回滚**:只动测试文件,不改源码、门禁、CI,不发布任何东西。块之间串状态的风险用探针在原顺序和三种乱序下排除:没有复原帮手时,`html` 元素的 `lang`、`window.innerWidth`(几个原文件在 `beforeAll` 里钉成 1280 且从不复原)和 `localStorage` 会漏到后面的块。回滚 = revert 本 PR。 - **先看**:`RecordDetailView.harness.test.tsx` 开头的说明和 `restoreAfterBlock()`(比 ObjectView 那份多复原 `innerWidth` / `innerHeight` 和 mock 调用记录),再随便挑一块对照原文件。 - **两分钟验证**:在 `ui/` 下跑 `pnpm exec vitest run packages/app-shell/src/views/RecordDetailView.harness.test.tsx`,应见 1 个文件、29 个测试全过。 - **需要你做的**:无,席位落地。 - **席位意见**:ui 席 2 对照 head `dfc6062f` 的 diff 复核:8 个文件、+1327 / −1457,纯测试改动,无受治理路径。RecordDetailView 家族 7 个最小的同构用例文件并入 `RecordDetailView.harness.test.tsx`:八个 mock 只声明一次,每个原文件成为一个以 `restoreAfterBlock()` 开头的顶层 describe,正文原样搬移;it 29 = 29、expect 54 = 54、标题一致,乱序种子下通过;`restoreAfterBlock` 另外复原 innerWidth/innerHeight 并清空 mock 调用记录。这 7 个文件 CPU 37 s → 7 s。CI 60 项全绿,Clause-② no,不欠契约复审。同意落地。 ## What changes Slice 4a, the first of at most two `RecordDetailView*` PRs of the shared-setup rollout (ruling 6583487846 on #29469; seat amendment 2, 6672694520: at most two PRs per family). The family is 103 pin files at `f4d9c094`, all in `ui/packages/app-shell/src/views/`, so it has one harness file in one package. - **The cluster.** The largest set of pins that share one setup is 52 files that mock the same eight modules (`@object-ui/auth`, `@object-ui/collaboration`, `sonner`, `./ActionConfirmDialog`, `./ActionParamDialog`, `./ActionResultDialog`, `./FlowRunner`, `./MetadataInspector`). In 44 of them every one of the eight factories is the same text once whitespace and comments are set aside (13,000 lines); the other 8 answer a different user or organization from `@object-ui/auth`. This PR folds the 7 smallest of the 44 that pass every census check: `recordsRecentVisit-12604`, `appScopedPage-29592`, `titleFls-10434`, `auditDisplayLocale-10442`, `auditTenantCurrency-27640`, `setupManagedByChip-13385`, `pageHeaderTitleFls-10499`. - **The harness.** `RecordDetailView.harness.test.tsx` declares the eight mocks once, copied verbatim from the former files. Each former file is a top-level `describe` named after its file stem (`RecordDetailView.STEM`), with its docblock above it (license lines dropped). Its first line is `restoreAfterBlock()`; everything after the former file's imports and mocks is moved verbatim, re-indented by two spaces (lines inside a template literal keep their bytes). A former file's module-level `beforeAll` / `beforeEach` / `afterEach` is now its block's own hook. The imports are the union of the seven files' imports, plus `beforeAll` / `afterAll` and `ComponentRegistry` for the helper; no two files bound one local name to different modules. The 7 files are deleted. - **What was dropped:** the license header, the import lines and the eight `vi.mock` calls of each file, and the one-line comments that sat above those mocks (for example "Orthogonal chrome — this file observes the published record title only."), since the mocks they described now live in the header. A line-multiset check of the 7 former files against the harness finds nothing else missing. - **`restoreAfterBlock()`** is the ListView / ObjectView helper (registry entries, a swapped-in `localStorage`, both storages, the `html` element's `lang` / `dir`) plus two things this family needs: `window.innerWidth` / `innerHeight` (five of the seven pin `innerWidth` to 1280 in a `beforeAll` and never put it back, which a fresh window used to hide) and `vi.clearAllMocks()`, so a block starts with the shared `toast` spies at zero calls, as its former file did. No other file names any of the 7 (`git grep` of each stem over the whole tree finds only the harness; `record-details.titleFls-10434.test.tsx` in `plugin-detail` is its own file), so no comment elsewhere changes. Test files only: no source file, no changeset (`skip-changeset`). `@object-ui/app-shell` builds with `tsc` from `tsconfig.json`, which excludes test files. ## Tests ### Former file → describe (no title or assertion dropped) TypeScript AST walk of each former file at `f4d9c094` (the `main` this was cut from) against the `describe` of the same name in the harness at this PR's head. An `it` is a call to `it` / `test` (an `it.each(...)(...)` counts once); an `expect(` is a call to `expect`; titles are the `describe > it` paths under the block, compared as sorted lists. | former file | it before | it after | expect( before | expect( after | titles identical | |---|--:|--:|--:|--:|:-:| | `RecordDetailView.recordsRecentVisit-12604.test.tsx` | 1 | 1 | 4 | 4 | yes | | `RecordDetailView.appScopedPage-29592.test.tsx` | 6 | 6 | 11 | 11 | yes | | `RecordDetailView.titleFls-10434.test.tsx` | 4 | 4 | 4 | 4 | yes | | `RecordDetailView.auditDisplayLocale-10442.test.tsx` | 3 | 3 | 6 | 6 | yes | | `RecordDetailView.auditTenantCurrency-27640.test.tsx` | 3 | 3 | 5 | 5 | yes | | `RecordDetailView.setupManagedByChip-13385.test.tsx` | 5 | 5 | 13 | 13 | yes | | `RecordDetailView.pageHeaderTitleFls-10499.test.tsx` | 7 | 7 | 11 | 11 | yes | | **total** | 29 | 29 | 54 | 54 | yes | The whole harness holds 29 `it` and 54 `expect(` calls, the sum of the blocks; no statement outside the blocks holds either. ### 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-battery `main` run after this merges. Local A/B on one 4-vCPU container, under `os-verify-lock` (shared-box seconds), same command both legs, from `ui/`: `pnpm exec vitest run packages/app-shell/src/views/RecordDetailView. --maxWorkers=2` (every `RecordDetailView.*` file), with a throwaway reporter summing each module's `diagnostic()`. Fixed = environment + prepare + setup + collect (import). The "before" leg writes the 7 files from `f4d9c094` into the branch's tree and moves the harness out of the include, so both legs run the same 96 other files; the tree is reset to `HEAD` after each before leg and checked clean. Run order: after 1 and after 2, each following a before run that still ran the harness (both discarded), then before 1 and before 2. | | files | tests passed | fixed CPU | test CPU | total CPU | wall | |---|--:|--:|--:|--:|--:|--:| | RecordDetailView family, before (run 1 / 2) | 103 | 653 | 524.2 / 515.8 s | 105.3 / 109.7 s | 629.5 / 625.5 s | 329.2 / 327.4 s | | RecordDetailView family, after (run 1 / 2) | 97 | 653 | 481.5 / 504.7 s | 100.5 / 107.8 s | 582.1 / 612.5 s | 304.4 / 319.1 s | | the 7 files, before (run 1 / 2) | 7 | 29 | 33.8 / 32.8 s | 4.0 / 3.9 s | 37.8 / 36.7 s | | | the harness, after (run 1 / 2) | 1 | 29 | 4.8 / 4.9 s | 2.3 / 2.7 s | 7.1 / 7.6 s | | The 7 files took 37.3 s of CPU on average; the harness that holds them takes 7.4 s (−80 %). The family read 627.5 s before and 597.3 s after on average (−4.8 %), wall 328.3 s to 311.8 s; the two after runs differ by 30.4 s, so the family figure is a reading inside this box's run-to-run spread, not a measured saving; the per-file figures above are the measurement. ## Acceptance notes - **Why these 7, and why the next PR folds the same cluster.** Of the 44 pins with the same eight factories, a pin passes the census when no other file names it, it imports nothing for side effects of its own, it holds no `vi.hoisted` / `globalThis` slot or global installer of its own, it registers no test from a loop at collection time, and it calls no `vi.spyOn`. Nine pass; the 7 smallest make 1,457 deleted and 1,327 added lines, 2,784 changed. The next two (`relatedListTitlePlural-11733`, 262 lines; `feedRefusal-11195`, 301) would take this PR past 3,000. Slice 4b, the family's second and last PR under amendment 2, folds the next pins of the same cluster into this harness and lists every pin left unfolded; the table below is that census as it stands at this head. - **One harness, one package.** All 103 pins are in `ui/packages/app-shell/src/views/`; no `RecordDetailView` pin lives in another package. - **Not candidates in place:** `headerRefresh` is named by path in a script test outside the package, `ui/scripts/__tests__/check-vi-mock-override-shape.test.ts`, so it stays a file of its own. Five pins (`relatedBadgeArity-8882`, `discussionFallbackPipeline-8983`, `relatedListFilter-4664`, `activityMapIdentity-5878`, `reactionWriteFailure-10899`) are named in comments of source files; those comments stay as they are when a pin folds (claim 6694271643: source files are ⛔). - The moved docblocks keep the issue numbers in prose, as the ListView and ObjectView harness blocks do; no new citation line is added outside moved text (`pnpm check:new-line-citations`: 0 new). - `ui/scripts/test-shard-timings.json` is keyed by a hash of each file's path, so the 7 deleted files leave 7 stale keys and the harness has none until the timings refresh; the previous families' folds left theirs the same way. <details><summary>RecordDetailView pins left at this head: 96 files, 30,858 lines, by shared setup</summary> A file in the eight-mock cluster sits under the most restrictive check it fails, rows ordered from least to most restrictive. Names drop the `RecordDetailView.` prefix and `.test.tsx`. | shared setup (`vi.mock` modules and checks) | files (lines) | lines | |---|---|--:| | the eight harness mocks, verbatim, and passes every check: the next fold's first candidates | `feedRefusal-11195` (301), `relatedListTitlePlural-11733` (262) | 563 | | the eight harness mocks, but another file names it, so a fold also edits that file (a test file; a name in a source-file comment stays as it is) | `feedRecordScope` (461; named by `defaults-maps-mirror-en-pack.test.tsx`), `relatedBadgeArity-8882` (453; named by `related-count-store.ts`), `discussionFallbackPipeline-8983` (439; named by `record-chatter.tsx`), `relatedListFilter-4664` (420; named by `deriveRelatedLists.relatedListFilter-4664.test.ts`, `RecordDetailView.childWriteRefreshesParent-12244.test.tsx`, `RecordDetailView.relatedBadgeArity-8882.test.tsx`, `related-count-store.declaredScope-4664.test.ts`, `related-count-store.ts`, `buildDefaultPageSchema.relatedListFilter-4664.test.ts`), `feedLoading` (394; named by `RecordDetailView.discussionFallbackPipeline-8983.test.tsx`, `RecordDetailView.feedRefusal-11195.test.tsx`, `RecordDetailView.headerRefresh.test.tsx`), `authoredChildWriteRefreshesParent-26890` (351; named by `RecordDetailView.unregisteredObjectLists-26988.test.tsx`, `recordPageChildObjects.test.ts`), `discussionExplicitComposition-7298` (327; named by `RecordDetailView.discussionFallbackPipeline-8983.test.tsx`), `sectionHeadingsRenderPath-6190` (320; named by `CHANGELOG.md`, `CHANGELOG.md`, `DetailView.expandFls-7230.test.tsx`), `managedByBadgeAuthoring-12194` (213; named by `ObjectView.managedByBadgeAuthoring-12194.test.tsx`, `RecordFormPage.managedByBadgeAuthoring-12194.test.tsx`), `printAction-11958` (162; named by `RecordDetailView.harness.test.tsx`, `RecordDetailView.printPageHeaderActions-12906.test.tsx`) | 3540 | | the eight harness mocks, plus `vi.spyOn` (each restored in its `afterEach`) | `recordPageTiers-26678` (431), `phoneFace-27058` (425), `panelToggles-27052` (381), `activityMapIdentity-5878` (346), `topBar-27524` (312), `relatedListInheritedSort-5795` (296), `recordTabRowUrl-27524` (278), `relatedCountsFirst-27056` (262), `phoneOwnerLine-28909` (204), `bodyTablePredicate-27478` (186), `relatedListsOrder-27241` (170) | 3291 | | the eight harness mocks, plus a side-effect import of its own | `userActionPredicates` (513), `headerActionLookupPredicate` (352), `builtinActionSessionUserPredicate` (346), `reactionWriteFailure-10899` (346), `authoredActivityThreading-12249` (335), `replyCountOnRead-12144` (302), `commentWriteFailure-10899` (259), `accessibleNames-12625` (199) | 2652 | | the eight harness mocks, but its body registers tests from a loop or `describe.each` at collection time | `hiddenAffordanceVerdicts-13045` (250), `oneProvenanceFooter-12307` (208), `appendInset-27520` (183) | 641 | | the eight harness mocks, plus a `vi.hoisted` / `globalThis` slot or a global installer of its own | `unregisteredObjectLists-26988` (312), `namedRecordPage-12715` (293) | 605 | | the eight harness mocks, but named by path in a file outside the tests (a ledger or a script test): stays a file of its own | `headerRefresh` (251; named by `check-vi-mock-override-shape.test.ts`) | 251 | | the same eight modules, but its `@object-ui/auth` factory answers a different user or organization | `reactionRecords-12078` (567), `childWriteRefreshesParent-12244` (433), `feedGrant-12082` (428), `withheldMentions-28218` (310), `printPageHeaderActions-12906` (287), `reactionKeepIds-11019` (271), `reactionsCommentRowsOnly-11035` (265), `activityActorId-12067` (176) | 2737 | | mocks `../hooks/useActionModal` + `../utils/consoleServerAction` + `./ActionConfirmDialog` + `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/react` + `sonner`, not the harness set | `paramRuntimeParity-6431` (610), `approvalDeclaredActions` (543), `confirmRuntimeParity-5835` (458), `headerRecordIdLoadWindow` (404), `approvalRecallGate` (355), `approvalLock-25934` (348), `recordIdParamSeed` (339), `accessEndedAfterDecision-26589` (330), `undoLookupId-11122` (309), `paramDialogTitle` (302), `headerApiInterpolation` (296), `undoCapture-11082` (291), `apiActionDoor-27611` (280), `modalDispatch` (278), `approvalLock-12220` (273), `paramCancelText-28879` (263), `paramSubmitText-28158` (263), `undoneToast-11056` (231), `banCompanion-30205` (227), `ctxOrg-10918` (222), `apiFlowRefusal-27487` (212) | 6834 | | mocks `@object-ui/auth` + `@object-ui/collaboration` + `sonner`, not the harness set | `recordOpenWaves-13010` (811), `feedLoadFailure-29188` (462), `recordPagePayload-27627` (389), `timelineCount-28737` (368), `recordOpenRequests-12701` (350), `afterActionExplain-13341` (315), `recordReadFailure-11902` (303), `recordOpenOneRequest-28470` (290), `approvalRequestPage-28546` (180), `phoneGuardBar-28483` (161) | 3629 | | mocks `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `sonner`, not the harness set | `feedCommentEditDelete-12268` (518), `updateActionRefresh-29935` (329), `deleteConfirmDialog-11001` (310), `favoritesEntry-12427` (293), `paneOpenAsPage-27545` (292), `placedHeaderActions-29951` (262), `apiNewTabUrl-26747` (257), `headerMenuIcons-12529` (239), `deleteCascade-28472` (188) | 2688 | | mocks `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/react` + `sonner`, not the harness set | `flowActionDoor-12037` (277), `flowDoneSuccessMessage-12274` (240), `refusedLaunch-9973` (236), `flowActionSuccessMessage-12234` (219) | 972 | | mocks `./ActionConfirmDialog` + `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/fields` + `sonner`, not the harness set | `lookupDependsOn-7190` (619) | 619 | | mocks `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/permissions` + `react` + `sonner`, not the harness set | `recordOpenRequests-11699` (505) | 505 | | mocks `../context/NavigationContext` + `../hooks/useActionModal` + `../utils/consoleServerAction` + `./ActionConfirmDialog` + `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/react` + `react-router-dom` + `sonner`, not the harness set | `onSuccessNavigateHost-13396` (399) | 399 | | mocks `./ActionConfirmDialog` + `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/plugin-detail` + `sonner`, not the harness set | `activityUnmappedType-5896` (380) | 380 | | mocks `./ActionConfirmDialog` + `./ActionParamDialog` + `./ActionResultDialog` + `./FlowRunner` + `./MetadataInspector` + `@object-ui/auth` + `@object-ui/collaboration` + `@object-ui/permissions` + `sonner`, not the harness set | `expandFls-7230` (281) | 281 | | no `vi.mock` | `headerActionGates` (182), `actionUser` (89) | 271 | | **total** | 96 files | 30858 | </details> ## Verification At head `dfc6062f`, after `pnpm install --frozen-lockfile` and the closure build (`pnpm turbo run build --filter='@object-ui/app-shell^...' --concurrency=2`, 66 tasks, VERDICT command-exit 0), every run under `os-verify-lock`: - Harness: 1 file, 29 / 29 passed in declaration order and under `--sequence.shuffle.tests` with `--sequence.seed` 11, 222 and 3333 (each VERDICT command-exit 0). - Probe: a throwaway copy of the harness whose `restoreAfterBlock()` writes the state at each block's first test (each registry entry's renderer and meta length, the `localStorage` own descriptor and both storage lengths, the `html` element's `lang` / `dir`, the `innerWidth` / `innerHeight` own descriptors and values, react-i18next's `getI18n()`, `document.title`, `body`, window keys added since import, the `fetch` stub, the `toast` spy call counts, `location.href`) reads all 7 blocks starting from the same state in all four orders. The same copy with the helper's `afterAll` body removed finds, depending on the order, `lang="en"` / `dir="ltr"`, `innerWidth` pinned at 1280 and one `localStorage` entry carried into later blocks. The probe copies were deleted. - `pnpm run type-check` in `ui/packages/app-shell` (`tsc --noEmit && tsc -p tsconfig.test.json`, whose `include` is `src/**/*.test.tsx`): exit 0, 0 `error TS`. - `eslint` on the harness from `ui/packages/app-shell`: 0 errors, 12 warnings (all `no-explicit-any`), the same 12 that the 7 former files give at `f4d9c094` (read through `--stdin` at their own paths). - Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, change set 8 paths against merge base `f4d9c094`): 26 derived, 26 run with stdin from `/dev/null`, each exit 0 captured before any pipe; `pnpm --dir ui exec vitest run scripts/` gave 170 files passed and 2 skipped, 4,996 tests passed and 2 skipped; `node scripts/check-sdui-manifest.mjs` and its `--self-test` exit 0; `pnpm check:test-source-alias` exit 0 (the source reach judged the changed test files). `--ran` reconciliation: 26 derived, 26 run, 0 NOT-MEASURED, 0 UNRUN. `pnpm check:new-line-citations` from `ui/`: exit 0, 0 new citations. - The RecordDetailView family (97 files after, 103 before): 653 tests passed in every A/B leg, 0 failed. The rest of `@object-ui/app-shell`'s suite was not run locally; no file outside the family changed, and CI's Test UI runs it. - Size: `git diff --shortstat f4d9c09 HEAD` is 8 files, +1,327 / −1,457, 2,784 changed lines. - `main` has moved 8 commits past `f4d9c094` (to `e1dac192`); none touches `ui/packages/app-shell/src/views/`, `ui/vitest.config.mts` or the `ui/vitest.setup.*` files, so the branch is not re-merged and the readings above stand for this head. - Open pull requests: none of the 28 open PRs changes a `RecordDetailView` file (read from each PR's file list before the push). - No ablation of a product behaviour: none changed, and the assertions moved verbatim. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (`packages/spec` not touched.) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. (`ui/` is linted by its own config; the lint readings are above.) - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. (Nothing publishes: `skip-changeset`.) - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (Not touched.) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the maintainer quick-read is the allowed Chinese section). <!-- signed: domain:ui#2 · os-tesla · session_01L9qibw7DekEe3wx5f3zphf --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent a4d8755 commit 81deb54

8 files changed

Lines changed: 1327 additions & 1457 deletions

‎ui/packages/app-shell/src/views/RecordDetailView.appScopedPage-29592.test.tsx‎

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)