test(et): migrate background snapshot coverage#2559
Conversation
🦋 Changeset detectedLatest commit: ec9280d The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
📝 WalkthroughWalkthroughThis PR adds Element Template runtime test coverage for hydration behavior and Preact child rendering, and applies a minor logic adjustment in ChangesElement Template Hydration & Rendering Test Coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested labels
Suggested reviewers
Poem
🚥 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✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Web Explorer#9358 Bundle Size — 900.03KiB (0%).ec9280d(current) vs 68502b7 main#9352(baseline) Bundle metrics
Bundle size by type
|
| Current #9358 |
Baseline #9352 |
|
|---|---|---|
495.9KiB |
495.9KiB |
|
401.92KiB |
401.92KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch Yradex:slice/element-template/02 Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#917 Bundle Size — 196.68KiB (0%).ec9280d(current) vs 68502b7 main#911(baseline) Bundle metrics
|
| Current #917 |
Baseline #911 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
174 |
174 |
|
66 |
66 |
|
44.05% |
44.05% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #917 |
Baseline #911 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
85.45KiB |
85.45KiB |
Bundle analysis report Branch Yradex:slice/element-template/02 Project dashboard
Generated by RelativeCI Documentation Report issue
React External#900 Bundle Size — 680.82KiB (0%).ec9280d(current) vs 68502b7 main#894(baseline) Bundle metrics
|
| Current #900 |
Baseline #894 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch Yradex:slice/element-template/02 Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#7785 Bundle Size — 225.52KiB (0%).ec9280d(current) vs 68502b7 main#7779(baseline) Bundle metrics
|
| Current #7785 |
Baseline #7779 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
180 |
180 |
|
69 |
69 |
|
44.54% |
44.54% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #7785 |
Baseline #7779 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
79.77KiB |
79.77KiB |
Bundle analysis report Branch Yradex:slice/element-template/02 Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#52 Bundle Size — 198.12KiB (+0.01%).ec9280d(current) vs 68502b7 main#46(baseline) Bundle metrics
Bundle size by type
Bundle analysis report Branch Yradex:slice/element-template/02 Project dashboard Generated by RelativeCI Documentation Report issue |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/react/runtime/__test__/element-template/runtime/background/render/preact.test.tsx (1)
25-25: ⚡ Quick winUse
BUILTIN_RAW_TEXT_TEMPLATE_KEYinstead of the hardcoded magic string.If the constant's value changes,
collectRawTextwould silently stop matching raw-text nodes without any compile-time or import-time signal. The sibling test files (instance.test.ts,hydrate.test.ts) already import the constant.♻️ Proposed fix
Add the import at the top:
+import { BackgroundElementTemplateInstance, BUILTIN_RAW_TEXT_TEMPLATE_KEY } from '../../../../../src/element-template/background/instance.js'; -import { BackgroundElementTemplateInstance } from '../../../../../src/element-template/background/instance.js';Then use the constant:
- if (child.type === '__et_builtin_raw_text__') { + if (child.type === BUILTIN_RAW_TEXT_TEMPLATE_KEY) {🤖 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/background/render/preact.test.tsx` at line 25, Replace the hardcoded magic string '__et_builtin_raw_text__' used in the test assertion with the shared constant BUILTIN_RAW_TEXT_TEMPLATE_KEY: add an import for BUILTIN_RAW_TEXT_TEMPLATE_KEY at the top of the test file and update the condition (wherever child.type is compared, e.g., in the collectRawText/test block) to use BUILTIN_RAW_TEXT_TEMPLATE_KEY so the test tracks the canonical symbol used by instance.test.ts and hydrate.test.ts.
🤖 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/background/render/preact.test.tsx`:
- Line 25: Replace the hardcoded magic string '__et_builtin_raw_text__' used in
the test assertion with the shared constant BUILTIN_RAW_TEXT_TEMPLATE_KEY: add
an import for BUILTIN_RAW_TEXT_TEMPLATE_KEY at the top of the test file and
update the condition (wherever child.type is compared, e.g., in the
collectRawText/test block) to use BUILTIN_RAW_TEXT_TEMPLATE_KEY so the test
tracks the canonical symbol used by instance.test.ts and hydrate.test.ts.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ccbed2fc-a91a-498b-b838-04f77666bf6d
📒 Files selected for processing (5)
.changeset/quiet-templates-smile.mdpackages/react/runtime/__test__/element-template/runtime/background/hydrate.test.tspackages/react/runtime/__test__/element-template/runtime/background/instance.test.tspackages/react/runtime/__test__/element-template/runtime/background/render/preact.test.tsxpackages/react/runtime/src/element-template/background/hydrate.ts
Summary by CodeRabbit
Tests
Bug Fixes
Overview
This migrates the currently supported
BackgroundSnapshotInstancebehavior coverage into Element Template runtime tests. The new coverage focuses on ET hydrate diffing, background update emission, keyed reorder stability, and post-hydrate handle continuity.It also aligns ET hydrate handling for serialized
nullversus missing background attribute slots with the existing Snapshot behavior, avoiding meaningless update noise caused by JSON serialization.Key Points
null.Verification
pnpm exec vitest run --configLoader runner -c __test__/element-template/vitest.config.ts __test__/element-template/runtime/background/hydrate.test.ts __test__/element-template/runtime/background/instance.test.ts __test__/element-template/runtime/background/render/preact.test.tsxChecklist