test(react): organize ET runtime tests#2699
Conversation
Move ET fixtures into owning runtime domains, align outputs with slot-index behavior, and format hydrate compiled golden output with readable alog commands.
|
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts (1)
21-35: ⚡ Quick winTighten helper option types to avoid
unknown[]+ cast escape hatch.
attributeSlotsis typed asunknown[]and then force-cast, which weakens strict-mode value checks in this test helper. Prefer typing it asSerializedElementTemplate['attributeSlots']directly.Suggested diff
function createHydrationTemplate( handleId: number, templateKey: string, options: { - attributeSlots?: unknown[] | null; - elementSlots?: SerializedElementTemplate[][] | null; + attributeSlots?: SerializedElementTemplate['attributeSlots']; + elementSlots?: SerializedElementTemplate['elementSlots']; } = {}, ): SerializedElementTemplate { const serialized: SerializedElementTemplate = { templateKey, uid: handleId, }; if ('attributeSlots' in options) { - serialized.attributeSlots = options.attributeSlots as SerializedElementTemplate['attributeSlots']; + serialized.attributeSlots = options.attributeSlots; } if ('elementSlots' in options) { - serialized.elementSlots = options.elementSlots as SerializedElementTemplate['elementSlots']; + serialized.elementSlots = options.elementSlots; } return serialized; }As per coding guidelines: "Enable TypeScript strict mode configured in tsconfig.json for all TypeScript development".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts` around lines 21 - 35, The test helper currently types options.attributeSlots as unknown[] and then force-casts it when assigning to serialized.attributeSlots; change the options parameter so attributeSlots is typed as SerializedElementTemplate['attributeSlots'] | null (and keep elementSlots as SerializedElementTemplate[][] | null or adjust to SerializedElementTemplate['elementSlots'] for symmetry), then remove the cast in the assignment inside the if ('attributeSlots' in options) branch so you assign options.attributeSlots directly to serialized.attributeSlots (referencing the helper function that constructs the SerializedElementTemplate, the options parameter, and the 'attributeSlots' and 'elementSlots' properties).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts`:
- Around line 21-35: The test helper currently types options.attributeSlots as
unknown[] and then force-casts it when assigning to serialized.attributeSlots;
change the options parameter so attributeSlots is typed as
SerializedElementTemplate['attributeSlots'] | null (and keep elementSlots as
SerializedElementTemplate[][] | null or adjust to
SerializedElementTemplate['elementSlots'] for symmetry), then remove the cast in
the assignment inside the if ('attributeSlots' in options) branch so you assign
options.attributeSlots directly to serialized.attributeSlots (referencing the
helper function that constructs the SerializedElementTemplate, the options
parameter, and the 'attributeSlots' and 'elementSlots' properties).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 24c9486c-fba1-416a-85a3-e72a48d9b392
📒 Files selected for processing (112)
packages/react/runtime/__test__/element-template/README.mdpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/case.tsxpackages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/output.txtpackages/react/runtime/__test__/element-template/fixtures/background/init-data/update/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-list/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-subtree-list/index.tsxpackages/react/runtime/__test__/element-template/fixtures/background/update/sparse/compiled-element-slot/index.tsxpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/_shared.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/case.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/case.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/case.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/case.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/source.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/case.tsxpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txtpackages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/source.tsxpackages/react/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsxpackages/react/runtime/__test__/element-template/runtime/background/hydrate.test.tspackages/react/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsxpackages/react/runtime/__test__/element-template/runtime/background/instance/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsxpackages/react/runtime/__test__/element-template/runtime/background/render/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsxpackages/react/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsxpackages/react/runtime/__test__/element-template/runtime/hydration/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/page/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/patch/fixtures.test.tspackages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.tspackages/react/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.tspackages/react/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.tspackages/react/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.tspackages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts
💤 Files with no reviewable changes (14)
- packages/react/runtime/test/element-template/runtime/background/instance/fixtures.test.ts
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txt
- packages/react/runtime/test/element-template/runtime/page/fixtures.test.ts
- packages/react/runtime/test/element-template/README.md
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txt
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txt
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txt
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt
- packages/react/runtime/test/element-template/runtime/patch/fixtures.test.ts
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt
- packages/react/runtime/test/element-template/runtime/background/render/fixtures.test.ts
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txt
- packages/react/runtime/test/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txt
Merging this PR will not alter performance
Comparing Footnotes
|
React External#1741 Bundle Size — 699.03KiB (0%).4bc3d85(current) vs 5b052c5 main#1737(baseline) Bundle metrics
|
| Current #1741 |
Baseline #1737 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
42.61% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
7.13% |
7.13% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch Yradex:wt/pick-5645-et-test-stru... Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#893 Bundle Size — 203.8KiB (0%).4bc3d85(current) vs 5b052c5 main#889(baseline) Bundle metrics
|
| Current #893 |
Baseline #889 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
27.72% |
|
0 |
0 |
|
4 |
4 |
|
121 |
121 |
|
49 |
49 |
|
45.28% |
45.28% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #893 |
Baseline #889 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
58.04KiB |
58.04KiB |
Bundle analysis report Branch Yradex:wt/pick-5645-et-test-stru... Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#10200 Bundle Size — 903.53KiB (0%).4bc3d85(current) vs 5b052c5 main#10196(baseline) Bundle metrics
Bundle size by type
|
| Current #10200 |
Baseline #10196 |
|
|---|---|---|
499.15KiB |
499.15KiB |
|
402.16KiB |
402.16KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch Yradex:wt/pick-5645-et-test-stru... Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8624 Bundle Size — 237.82KiB (0%).4bc3d85(current) vs 5b052c5 main#8620(baseline) Bundle metrics
|
| Current #8624 |
Baseline #8620 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
38.71% |
|
0 |
0 |
|
4 |
4 |
|
201 |
201 |
|
80 |
80 |
|
44.66% |
44.66% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8624 |
Baseline #8620 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
92.07KiB |
92.07KiB |
Bundle analysis report Branch Yradex:wt/pick-5645-et-test-stru... Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1758 Bundle Size — 208.77KiB (0%).4bc3d85(current) vs 5b052c5 main#1754(baseline) Bundle metrics
|
| Current #1758 |
Baseline #1754 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
46.72% |
|
0 |
0 |
|
3 |
3 |
|
196 |
196 |
|
77 |
77 |
|
44.15% |
44.15% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1758 |
Baseline #1754 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
97.54KiB |
97.54KiB |
Bundle analysis report Branch Yradex:wt/pick-5645-et-test-stru... Project dashboard
Generated by RelativeCI Documentation Report issue
Summary by CodeRabbit
Tests
Chores
Overview
This PR reorganizes Element Template runtime tests so each fixture root maps to the runtime domain that owns the behavior under test. The previous layout mixed background hydrate, serialized hydration data, prop-adapter behavior, and compiled background fixtures under broad hydrate/background buckets, which made ownership and long-term fixture maintenance harder to reason about.
The new layout keeps behavior unchanged while moving fixtures and suites into capability-specific roots, reusing shared compiled fixture helpers, and making compiled hydrate golden output readable through the existing ET alog formatter.
Key Points
background/hydrate,hydration/hydration-data,background/init-data/update, and keyed/sparse update subtrees.Checklist