Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

fix(react): emit BaseSchema.testId as data-testid (objectui#8268) - #8931

Merged
os-zhuang merged 1 commit into
mainfrom
claude/issue-8268-testid-jsdoc-unhonoured
Sep 10, 2026
Merged

os-zhuang merged 1 commit into
mainfrom
claude/issue-8268-testid-jsdoc-unhonoured

Conversation

@claude

@claude claude Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #8268

BaseSchema.testId's JSDoc promised "Rendered as data-testid attribute." Nothing rendered
it. The key was absent from SchemaRenderer's metadata destructure, so it fell through into
the spread, was handed to the component as a React prop, and reached the DOM under React's
fallback spelling for an unrecognised prop — a non-standard lowercase testid that
screen.getByTestId(...) and [data-testid=...] both miss. The zod mirror accepts the key, so
the author got no parse-time warning either.

The measurement

Reproduced on my base 93127bd6f through the real ui:scroll-area renderer, node
{ id: 'my-scroll', testId: 'my-tid' }, both worlds on the same probe:

[data-testid="my-tid"] [testid="my-tid"] contrast leg: id
before false true id="my-scroll" + data-obj-id="my-scroll" — present
after true false id="my-scroll" + data-obj-id="my-scroll" — present

Root attributes, before and after:

before  dir="ltr" class="relative overflow-hidden" style="..." id="my-scroll" testid="my-tid" data-obj-id="my-scroll" data-obj-type="ui:scroll-area"
after   dir="ltr" class="relative overflow-hidden" style="..." id="my-scroll" data-testid="my-tid" data-obj-id="my-scroll" data-obj-type="ui:scroll-area"

The id leg is the firing positive control on the same run: the strip list and the spread
work as designed, and only this key had no mapping. It is deliberately green in both worlds,
and the source comment on it names the wrong fix it guards against — stopping the leak by
widening the strip list mechanically and sweeping id (or the data-obj-* pair emitted from
the same place) out with it.

Two things the card did not have, measured here:

  • React's own dev warning does fire — and makes it worse. It tells the author to
    "spell it as lowercase testid", i.e. steers them to the attribute that does not work,
    further from the documented one.
  • objectui#4795's unevaluated-expression diagnostic did report testId before this change
    (measured: an authored testId: '${data.x}' was named in its output), because the key was in
    componentProps. The strip list is that diagnostic's exclusion list, so stripping the key
    would have silently narrowed its coverage. testId holds a literal, not predicate source, so
    it is stripped from the spread and kept in the scan set; a case pins that.

Branch A, and why I departed from objectui#7088

objectui#7088 — the class-mirror, BaseSchema.hidden — resolved by fixing the declaration and
declining the renderer change
(director ruling 2026-09-01, maintainer 「同意」; 「分化不做」,
Clause-② no). That is branch B, and it is the strong prior. I took A, and the ruling's own
reasoning is why.

#7088 declined the renderer change because it was 「发布 prop 上的行为变更,零具名消费者」 — a
behaviour change on a published prop with zero named consumers. That premise does not hold
here. Measured on this base, the promise already has carriers outside the type declaration:

  • content/docs/api/schema-reference.md states it as a table row — "Test identifier, rendered
    as data-testid."
    — and authors testId in that page's own base-schema example.
  • packages/cli/src/commands/check.ts — OBJECTUI_STRUCTURAL_KEYS identifies a file as an
    ObjectUI schema node by this key, in a published CLI, with a comment saying the set
    "grows only when BaseSchema grows".
  • packages/types/src/objectql.ts — ObjectGridSlotKey and ObjectFormSlotKey both pin it.
  • packages/core — SchemaBuilder.testId() is a published builder method that writes it.
  • Two example suites declare it a key "the render pipeline handles for EVERY node".
  • 15 component doc pages carry the row. (The card said 16; that count has drifted —
    layout/box.mdx still carries a // Base properties block, so the 16 for that grep is
    intact, but its block was trimmed to id / visible and no longer lists testId.)
  • ADR-0054 C4 — shipped, all five phases — reads "The renderer emits data-testid … derived
    from metadata"
    . Retiring the key is a move against a landed ADR.

Two more asymmetries against B:

  1. The second carrier is fenced. The promise's most author-facing copy lives in
    content/docs/api/schema-reference.md, which this PR is fenced off (objectui#8914 is in
    flight there). Under B that page keeps a live falsehood this PR cannot fix; under A it
    becomes true with no doc edit at all.
  2. hidden had a behaviour to describe; this key has none. "Make the declaration honest"
    here means describing nothing, which is retirement — and retirement crosses types (decl +
    zod mirror + two pinned key unions), core (a published builder method), cli (a published
    marker list), 15 doc pages and the fenced file, for a p3 finding.

ADR-0049 is enforce-or-remove; this is the enforce arm. AGENTS.md #0.1 is not in tension:
there is no lenient fallback, no alias, no ??-default here — the key is BaseSchema's own
declaration and it is honoured under its own single spelling.

Triage's third determinate defect (the stray lowercase testid reaching the DOM whatever is
decided about the promise) is subsumed: the key is now in the strip list.

The one thing that had to be measured, not reasoned

The emission is spread conditionally:

...(_testId === undefined ? {} : { 'data-testid': _testId }),

The unconditional 'data-testid': _testId form was written first and turned 9 tests red
across 5 files
, three of them the byte-for-byte props-bag pins (objectui#6708 / #6752 /
#6760). Passing undefined is invisible in rendered HTML but puts the key in every node's props
bag, and a component that sets its own data-testid before spreading what it is handed — the
ADR-0054 C4 shape, common here — has its locator overwritten with undefined and loses it. A
node that authors no testId is now byte-identical to before this PR, and two cases pin both
sides of that precedence.

Verification

Everything below at 94326f2dd unless stated.

  • pnpm exec vitest run packages/react/src packages/types/src → Test Files 238 passed (238) · Tests 4084 passed (4084)
  • pnpm exec vitest run packages/components/src packages/app-shell/src → Test Files 925 passed (925) · Tests 8825 passed, 1 skipped (8826) (the published-face consumers)
  • pnpm --filter @object-ui/types --filter @object-ui/react run type-check → both Done. Coverage of the new file proved, not assumed: tsc -p packages/react/tsconfig.test.json --listFiles lists SchemaRenderer.testIdEmission.test.tsx.
  • turbo run lint --filter=@object-ui/react --filter=@object-ui/types → Tasks: 3 successful, 3 total, 0 errors. Warnings are pre-existing no-explicit-any; none falls on an edited line (SchemaRenderer.tsx warnings stop at 1440, edits are 1477+; no base.ts warning in 415–460; none on the new file).
  • pnpm changeset:check → 3 assertions pass · pnpm check:control-bytes → OK (scanned 7113 tracked text file(s)) · pnpm check:vi-mock-specifiers → OK · pnpm check:shell-escape-residue → OK · pnpm check:doc-types → Every documented component type is registered. · pnpm check:doc-fences → OK
  • Self-scan beyond the gate: grep -naP for control bytes over all four diff files → 0 each, with a proven-positive probe.
  • node scripts/check-governed-queue-guard.mjs --test THE-FOUR-PATHS → NOT GOVERNED.

Ablation — the pin can actually fail, twice, and the control survives both. Run on the
committed implementation, each leg with its on-disk mutation proved by blob hash and restored
with git checkout HEAD -- PATH under a trap, restore proved by an empty git diff HEAD
and by the blob returning to 90426f2740737ede85a4ed871b899822ab9b3fd3:

leg mutation result
A delete the data-testid emission Tests 2 failed · 4 passed (6)
B put testId back in the spread (re-create the leak) Tests 1 failed · 5 passed (6) — the "NOT the lowercase spelling" case

The id control was green in all four worlds.

pnpm check:doc-snippets and pnpm check:doc-examples first returned exit 2 =
PREREQUISITE NOT MET
, which is neither red nor green. Rather than report that, the
prerequisite was satisfied — turbo run build $(node scripts/check-doc-snippet-types.mjs --build-filter) --concurrency=2 → Tasks: 35 successful, 35 total — and both re-run to a real
verdict:

  • pnpm check:doc-snippets → exit 0, Semantic phase: 638 of 638 block(s) judged, 0 failed.
  • pnpm check:doc-examples → exit 0, Every covered @example compiles, or fails exactly as its ledger row declares.

Consistent with the independent argument that they could not move: their population is
TypeScript fences in documents, this diff changes 0 document files, and
packages/types/src/base.ts's diff is comment-only — every changed line in it is a JSDoc
line, verified with a probe whose positive control finds the non-comment changed lines in
SchemaRenderer.tsx. No declaration byte moved.

验收备注 — measured, deliberately not fixed

  • content/docs/api/schema-reference.md line ~90 carries the promise as a table row and line
    ~61 authors testId in the base-schema example. Both become correct with this PR and no
    edit
    — which is the point — but the file is fenced (objectui#8914). Flagged, not touched.
  • The two example suites' PIPELINE_KEYS lists (examples/schema-catalog/test/) call testId
    "a key the render pipeline handles for EVERY node". That was false before this PR and is true
    after it. No edit needed; noted so the next reader knows it was checked, not missed.
  • Triage's p2 re-grade condition — testId authored in a live schema node — is not met:
    the only authored occurrence in the tree is the doc JSON example above. Left at p3.

Clause-②

Clause-②: yes, declared on the card's claim comment and carried here. Both branches move a
published face and this one moves the renderer's DOM output on nodes that author testId — in
both directions, since the accidental [testid=…] stops matching. The A-vs-B call itself is the
contract-face question the carrier exists for, and this PR is the reviewable increment it is
supposed to go up with.


🤖 Generated with Claude Code

https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH


Generated by Claude Code

`testId` was absent from `SchemaRenderer`'s metadata destructure, so it fell
through into the spread and reached the DOM as the non-standard lowercase
`testid` that React writes for an unrecognised prop — the attribute the
declaration promises was never emitted, and no query helper finds the one that
was. Strip the key and re-emit it as `data-testid` beside `data-obj-id`.

Spread conditionally: `'data-testid': undefined` would add the key to every
node's props bag and overwrite a component's own locator.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
@github-actions

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 50 chunks) 3487.6 KB 3512.7 KB
Main entry chunk (gzip) 144.1 KB 350 KB
Entry file index-CR5NiO_F.js —
Status PASS —

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 16.69KB 6.21KB
app-shell (runtime-config.js) 20.68KB 7.36KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.06KB 3.86KB
auth (ActiveOrganizationStorage.js) 25.05KB 9.16KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.18KB 10.59KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.15KB 5.39KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.65KB 2.22KB
auth (SocialSignInButtons.js) 9.61KB 3.89KB
auth (UserMenu.js) 3.41KB 1.23KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.21KB 10.80KB
auth (createAuthenticatedFetch.js) 8.46KB 3.43KB
auth (index.js) 3.19KB 1.44KB
auth (invitation-status.js) 1.22KB 0.70KB
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) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 11.08KB 4.58KB
collaboration (CommentThread.js) 26.08KB 7.56KB
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.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.05KB 2.52KB
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) 500.20KB 114.67KB
core (index.js) 7.48KB 2.96KB
create-plugin (index.js) 28.04KB 9.46KB
data-objectstack (index.js) 200.01KB 55.77KB
fields (index.js) 246.97KB 62.30KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 1.22KB 0.64KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 6.57KB 2.76KB
i18n (index.js) 3.65KB 1.47KB
i18n (pickLocalized.js) 7.62KB 3.26KB
i18n (provider.js) 26.89KB 9.04KB
i18n (useDisplayLocale.js) 2.85KB 1.45KB
i18n (useObjectLabel.js) 34.34KB 9.17KB
i18n (useSafeTranslation.js) 5.60KB 2.33KB
layout (index.js) 38.84KB 10.94KB
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.75KB
mobile (index.js) 1.99KB 0.87KB
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.72KB 0.42KB
mobile (useSpecGesture.js) 4.39KB 1.66KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 13.52KB 4.88KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.24KB 2.16KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 8.39KB 3.10KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 14.81KB 3.63KB
plugin-calendar (index.js) 49.03KB 13.93KB
plugin-charts (index.js) 71.39KB 19.92KB
plugin-chatbot (index.js) 194.54KB 46.34KB
plugin-dashboard (index.js) 132.41KB 34.84KB
plugin-designer (index.js) 215.69KB 44.34KB
plugin-detail (index.js) 252.45KB 65.33KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 136.79KB 34.19KB
plugin-gantt (index.js) 166.96KB 40.93KB
plugin-grid (index.js) 210.86KB 57.28KB
plugin-kanban (index.js) 57.58KB 16.47KB
plugin-list (index.js) 112.54KB 27.65KB
plugin-map (index.js) 20.49KB 6.83KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 43.42KB 11.92KB
plugin-timeline (index.js) 30.10KB 8.74KB
plugin-tree (index.js) 9.55KB 3.32KB
plugin-view (index.js) 84.42KB 20.80KB
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.66KB 3.50KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 83.34KB 27.61KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.63KB 2.18KB
react (schema-input.js) 2.32KB 1.24KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (codegen.js) 6.58KB 2.74KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 5.55KB 2.45KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 20.57KB 5.88KB
sdui-parser (provenance.js) 3.66KB 1.82KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 13.64KB 4.59KB
types (ai.js) 0.20KB 0.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 2.87KB 1.00KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (complex.js) 2.93KB 1.49KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 4.74KB 2.25KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 4.73KB 2.28KB
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 (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 5.05KB 1.93KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (strict-authoring-face.js) 14.27KB 5.47KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
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

@os-zhuang
os-zhuang marked this pull request as ready for review September 10, 2026 02:54
@os-zhuang
os-zhuang added this pull request to the merge queue Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Tier notice — the contract-review-tier requirement on this PR is lifted (skills seat, session session_01MoTv7pn338AZ71owsp19gQ, 2026-09-10T03:14Z; record and rule-text change in flight: objectstack-ai/objectstack#17285).

Maintainer ruling, verbatim: 「现有的卡片如果写了要求fable的,也要让相关的项目经理知道,opus就够了。」 Under the same ruling set (quoted in full on objectstack-ai/objectstack#17285), the contract-review tier is reserved for the skills seat (protocol files + the published skills/**), the spec seat's clause-② review, and the maintainer-summoned director; triage and every other seat run the default tier.

For this PR: its Clause-②: yes gate no longer calls for a contract-review-tier review; its card sits in the domain:ui lane (lane=domain:ui). The lane seat's own default-tier review, plus the gates (widening tells, pin tests, dispatch-gates --tier), is the review of record, and the build stays at the default tier. Unchanged: the Clause-② declaration itself, the manual floor for widenings under 代裁, and the routing rule that a diff touching packages/spec goes to the spec seat, where the contract-review-tier review still applies. This comment changes no label, assignee or claim.


Generated by Claude Code

Merged via the queue into main with commit 4eaa835 Sep 10, 2026
35 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-8268-testid-jsdoc-unhonoured branch September 10, 2026 03:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

3 participants