Skip to content

test(endpoint): add process normalize sequencing tests#3909

Merged
ntucker merged 1 commit intomasterfrom
enhance/nested-process-schema
Apr 15, 2026
Merged

test(endpoint): add process normalize sequencing tests#3909
ntucker merged 1 commit intomasterfrom
enhance/nested-process-schema

Conversation

@ntucker
Copy link
Copy Markdown
Collaborator

@ntucker ntucker commented Apr 14, 2026

Motivation

Verify that nested entity process() is called with correct parent, key, and args during normalize, and that the call sequencing (process → pk → validate → visit children) supports all dependency patterns.

Solution

Add a dedicated process.test.ts suite covering:

  • pk from args: entity pk computed from endpoint arguments injected by process
  • pk from parent: composite pk using parent entity's id via process
  • pk from input transform: pk derived from URL parsing in process (GitHub Issue pattern)
  • pk from parent + args + input: all three sources combined
  • Invalidation: process returning undefined triggers entity invalidation
  • Validation: validate sees fields added by process; fails when process doesn't provide them
  • Deep nesting: args propagate through 3+ levels to affect grandchild pk
  • Parent is processed: child process sees fields added by parent's process
  • Circular references: self-referential entities normalize without infinite recursion
  • EntityMixin: same behavior via EntityMixin as Entity

No production code changes — normalize already handles all of this correctly.

Open questions

N/A


Note

Low Risk
Adds a large new test suite without changing runtime code; risk is limited to longer test execution and potential flakiness if assumptions about normalization behavior differ across environments.

Overview
Adds process.test.ts, a comprehensive set of normalization tests asserting that process() runs for nested schema members (direct, arrays, and deep chains), preserves null/missing keys, and correctly handles non-entity schemas like schema.Collection, schema.Values, and serializable functions.

Expands coverage for edge cases where process() affects pk()/validation, supports invalidation when process() returns undefined, ensures args/processed-parent propagation to grandchildren, and verifies circular/self-referential entities and EntityMixin parity.

Reviewed by Cursor Bugbot for commit b379653. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: c97b4d0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@data-client/endpoint Patch
@data-client/graphql Patch
@data-client/img Patch
@data-client/rest Patch
example-benchmark Patch
example-benchmark-react Patch
normalizr-github-example Patch
normalizr-redux-example Patch
normalizr-relationships Patch
test-bundlesize Patch
coinbase-lite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

Size Change: 0 B

Total Size: 80.7 kB

ℹ️ View Unchanged
Filename Size
examples/test-bundlesize/dist/App.js 1.46 kB
examples/test-bundlesize/dist/polyfill.js 307 B
examples/test-bundlesize/dist/rdcClient.js 10.5 kB
examples/test-bundlesize/dist/rdcEndpoint.js 8 kB
examples/test-bundlesize/dist/react.js 59.7 kB
examples/test-bundlesize/dist/webpack-runtime.js 726 B

compressed-size-action

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark React

Details
Benchmark suite Current: b379653 Previous: e66cc98 Ratio
data-client: getlist-100 141.85 ops/s (± 5.6%) 136.06 ops/s (± 7.2%) 0.96
data-client: getlist-500 37.53 ops/s (± 8.6%) 40.73 ops/s (± 6.2%) 1.09
data-client: update-entity 350.99 ops/s (± 9.9%) 294.12 ops/s (± 7.4%) 0.84
data-client: update-user 333.33 ops/s (± 7.1%) 333.33 ops/s (± 8.3%) 1
data-client: getlist-500-sorted 43.38 ops/s (± 5.8%) 41.76 ops/s (± 7.1%) 0.96
data-client: update-entity-sorted 270.27 ops/s (± 7.2%) 294.12 ops/s (± 5.7%) 1.09
data-client: update-entity-multi-view 322.58 ops/s (± 7.6%) 322.58 ops/s (± 7.1%) 1
data-client: list-detail-switch-10 7.66 ops/s (± 7.0%) 6.46 ops/s (± 5.6%) 0.84
data-client: update-user-10000 73.81 ops/s (± 14.6%) 78.12 ops/s (± 1.5%) 1.06
data-client: invalidate-and-resolve 34.13 ops/s (± 4.3%) 33.9 ops/s (± 5.5%) 0.99
data-client: unshift-item 208.33 ops/s (± 3.6%) 212.77 ops/s (± 3.7%) 1.02
data-client: delete-item 259.78 ops/s (± 4.6%) 270.27 ops/s (± 5.2%) 1.04
data-client: move-item 175.49 ops/s (± 6.4%) 172.41 ops/s (± 6.2%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Details
Benchmark suite Current: b379653 Previous: e66cc98 Ratio
normalizeLong 459 ops/sec (±0.96%) 458 ops/sec (±1.77%) 1.00
normalizeLong Values 421 ops/sec (±0.59%) 403 ops/sec (±1.01%) 0.96
denormalizeLong 252 ops/sec (±4.49%) 279 ops/sec (±5.83%) 1.11
denormalizeLong Values 228 ops/sec (±3.80%) 326 ops/sec (±0.48%) 1.43
denormalizeLong donotcache 1022 ops/sec (±0.10%) 1087 ops/sec (±0.61%) 1.06
denormalizeLong Values donotcache 758 ops/sec (±0.26%) 764 ops/sec (±0.17%) 1.01
denormalizeShort donotcache 500x 1561 ops/sec (±0.20%) 1520 ops/sec (±0.09%) 0.97
denormalizeShort 500x 734 ops/sec (±3.39%) 988 ops/sec (±1.85%) 1.35
denormalizeShort 500x withCache 7345 ops/sec (±0.14%) 7951 ops/sec (±0.13%) 1.08
queryShort 500x withCache 2996 ops/sec (±0.14%) 3134 ops/sec (±0.50%) 1.05
buildQueryKey All 54639 ops/sec (±0.93%) 49814 ops/sec (±0.40%) 0.91
query All withCache 6403 ops/sec (±0.35%) 5680 ops/sec (±0.49%) 0.89
denormalizeLong with mixin Entity 361 ops/sec (±2.16%) 350 ops/sec (±2.40%) 0.97
denormalizeLong withCache 7775 ops/sec (±0.19%) 7652 ops/sec (±0.56%) 0.98
denormalizeLong Values withCache 5128 ops/sec (±0.17%) 6209 ops/sec (±1.48%) 1.21
denormalizeLong All withCache 6159 ops/sec (±0.24%) 5440 ops/sec (±0.56%) 0.88
denormalizeLong Query-sorted withCache 6431 ops/sec (±0.19%) 5743 ops/sec (±0.13%) 0.89
denormalizeLongAndShort withEntityCacheOnly 1831 ops/sec (±0.13%) 1667 ops/sec (±0.18%) 0.91
denormalize bidirectional 50 7102 ops/sec (±0.34%) 6655 ops/sec (±0.23%) 0.94
denormalize bidirectional 50 donotcache 41164 ops/sec (±1.39%) 44707 ops/sec (±1.21%) 1.09
getResponse 4526 ops/sec (±0.60%) 5600 ops/sec (±1.29%) 1.24
getResponse (null) 10568521 ops/sec (±0.86%) 10824484 ops/sec (±0.56%) 1.02
getResponse (clear cache) 342 ops/sec (±0.30%) 335 ops/sec (±1.92%) 0.98
getSmallResponse 3556 ops/sec (±0.19%) 4075 ops/sec (±0.24%) 1.15
getSmallInferredResponse 2736 ops/sec (±0.14%) 2906 ops/sec (±0.05%) 1.06
getResponse Collection 4582 ops/sec (±0.53%) 5497 ops/sec (±1.19%) 1.20
get Collection 4639 ops/sec (±0.25%) 5463 ops/sec (±0.68%) 1.18
get Query-sorted 4641 ops/sec (±0.34%) 5542 ops/sec (±0.27%) 1.19
setLong 469 ops/sec (±0.37%) 461 ops/sec (±0.18%) 0.98
setLongWithMerge 256 ops/sec (±0.29%) 253 ops/sec (±0.97%) 0.99
setLongWithSimpleMerge 275 ops/sec (±0.14%) 271 ops/sec (±0.20%) 0.99
setSmallResponse 500x 933 ops/sec (±0.96%) 888 ops/sec (±0.95%) 0.95

This comment was automatically generated by workflow using github-action-benchmark.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 35cfc41. Configure here.

Comment thread packages/endpoint/src/schemas/EntityMixin.ts Outdated
Comment thread packages/endpoint/src/schemas/EntityMixin.ts Outdated
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 14, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs-site Ignored Ignored Preview Apr 15, 2026 1:20pm

Request Review

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.11%. Comparing base (81c63a0) to head (b379653).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3909   +/-   ##
=======================================
  Coverage   98.11%   98.11%           
=======================================
  Files         153      153           
  Lines        2916     2916           
  Branches      566      566           
=======================================
  Hits         2861     2861           
  Misses         11       11           
  Partials       44       44           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ntucker ntucker force-pushed the enhance/nested-process-schema branch from 9e56061 to c97b4d0 Compare April 15, 2026 13:10
Add comprehensive tests verifying that nested entity process() is
called with correct parent, key, and args during normalize, covering
pk derivation, invalidation, validation, deep nesting, and circular
references.

Made-with: Cursor
@ntucker ntucker force-pushed the enhance/nested-process-schema branch from c97b4d0 to b379653 Compare April 15, 2026 13:20
@ntucker ntucker changed the title enhance(endpoint): process nested schema members test(endpoint): add process normalize sequencing tests Apr 15, 2026
@ntucker ntucker merged commit 5e0b02c into master Apr 15, 2026
27 checks passed
@ntucker ntucker deleted the enhance/nested-process-schema branch April 15, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant