From 4bc3d853a2ba3c5405e6544d1736043443780efe Mon Sep 17 00:00:00 2001 From: Yradex <11014207+Yradex@users.noreply.github.com> Date: Fri, 22 May 2026 17:40:19 +0800 Subject: [PATCH] test(react): organize ET runtime tests Move ET fixtures into owning runtime domains, align outputs with slot-index behavior, and format hydrate compiled golden output with readable alog commands. --- .../__test__/element-template/README.md | 75 ------ .../index.tsx | 0 .../output.txt | 19 ++ .../index.tsx | 0 .../output.txt | 19 ++ .../children.mixed-operations/index.tsx | 0 .../children.mixed-operations/output.txt | 28 ++ .../index.tsx | 0 .../output.txt | 11 + .../index.tsx | 0 .../output.txt | 21 ++ .../children.removes-missing/index.tsx | 0 .../children.removes-missing/output.txt | 13 + .../index.tsx | 0 .../output.txt | 11 + .../index.tsx | 0 .../output.txt | 16 ++ .../index.tsx | 0 .../output.txt | 25 ++ .../hydrate}/_shared.tsx | 0 .../attrs.adds-background-only/case.tsx | 0 .../attrs.adds-background-only/output.txt | 0 .../attrs.aligns-ids-and-patches/case.tsx | 0 .../attrs.aligns-ids-and-patches/output.txt | 0 .../hydrate}/attrs.array-diff/case.tsx | 0 .../hydrate}/attrs.array-diff/output.txt | 0 .../attrs.batch-multiple-patches/case.tsx | 0 .../attrs.batch-multiple-patches/output.txt | 0 .../hydrate}/attrs.nullish-values/case.tsx | 0 .../hydrate}/attrs.nullish-values/output.txt | 0 .../attrs.object-value-updates/case.tsx | 0 .../attrs.object-value-updates/output.txt | 0 .../attrs.patches-nested-component/case.tsx | 0 .../attrs.patches-nested-component/output.txt | 0 .../hydrate}/attrs.removes-missing/case.tsx | 0 .../hydrate}/attrs.removes-missing/output.txt | 0 .../hydrate}/attrs.skips-identical/case.tsx | 0 .../hydrate}/attrs.skips-identical/output.txt | 0 .../attrs.style-object-updates/case.tsx | 0 .../attrs.style-object-updates/output.txt | 0 .../hydrate}/attrs.type-diff/case.tsx | 0 .../hydrate}/attrs.type-diff/output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../children.iterates-existing-slots/case.tsx | 0 .../output.txt | 0 .../children.missing-attrs-element/case.tsx | 0 .../children.missing-attrs-element/output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../coverage.emit-create-raw-text/case.tsx | 0 .../coverage.emit-create-raw-text/output.txt | 0 .../coverage.move-before-child/case.tsx | 0 .../coverage.move-before-child/output.txt | 0 .../coverage.raw-text-key-branches/case.tsx | 0 .../coverage.raw-text-key-branches/output.txt | 0 .../case.tsx | 0 .../output.txt | 0 .../hydrate}/reports-key-mismatch/case.tsx | 0 .../hydrate}/reports-key-mismatch/output.txt | 0 .../updates-raw-text-instance-id/case.tsx | 0 .../updates-raw-text-instance-id/output.txt | 0 .../update}/index.tsx | 0 .../{ => keyed}/compiled-keyed-list/index.tsx | 0 .../compiled-keyed-subtree-list/index.tsx | 0 .../sparse/compiled-element-slot}/index.tsx | 0 .../output.txt | 15 -- .../output.txt | 15 -- .../children.mixed-operations/output.txt | 22 -- .../output.txt | 9 - .../output.txt | 17 -- .../children.removes-missing/output.txt | 11 - .../output.txt | 9 - .../output.txt | 12 - .../output.txt | 19 -- .../hydration-data/_shared.tsx | 0 .../multiple-root-instances/case.tsx | 0 .../multiple-root-instances/output.txt | 0 .../hydration-data/nested-instances/case.tsx | 0 .../nested-instances/output.txt | 0 .../hydration-data/simple-element/case.tsx | 0 .../hydration-data/simple-element/output.txt | 0 .../hydration-data/sub-components/case.tsx | 0 .../hydration-data/sub-components/output.txt | 4 +- .../hydration-data/sub-components/source.tsx | 0 .../hydration-data/text-children/case.tsx | 0 .../hydration-data/text-children/output.txt | 2 +- .../hydration-data/text-children/source.tsx | 0 .../event/compiled-fixtures.test.tsx | 94 +++---- .../runtime/background/hydrate.test.ts | 208 +-------------- .../hydrate}/compiled-fixtures.test.ts | 17 +- .../background/hydrate/fixtures.test.ts | 16 ++ .../compiled-fixtures.test.tsx} | 43 ++- .../background/instance/fixtures.test.ts | 1 - .../background/ref/compiled-fixtures.test.tsx | 42 ++- .../background/render/fixtures.test.ts | 1 - .../update/compiled-fixtures.test.tsx | 40 ++- .../update/sparse-fixtures.test.tsx | 18 +- .../runtime/hydration/fixtures.test.ts | 9 +- .../runtime/page/fixtures.test.ts | 1 - .../runtime/patch/fixtures.test.ts | 1 - .../runtime/prop-adapters/hydrate.test.ts | 245 ++++++++++++++++++ .../test-utils/debug/compiledFixtureModule.ts | 38 ++- .../debug/compiledHydrationScenario.ts | 14 +- .../test-utils/debug/compiledThreadRunner.ts | 36 ++- .../test-utils/debug/renderFixtureRunner.ts | 2 + 112 files changed, 610 insertions(+), 589 deletions(-) delete mode 100644 packages/react/runtime/__test__/element-template/README.md rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.creates-and-inserts-new/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.inserts-before-existing-sibling/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.mixed-operations/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.moves-before-existing-sibling/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.non-string-raw-text-key-on-main/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.removes-missing/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.reorders-when-order-differs/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/children.reuses-by-type-ignoring-keys/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate-compiled => background/hydrate-compiled}/complex-trees.deeply-nested-dynamic-content/index.tsx (100%) create mode 100644 packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/_shared.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.adds-background-only/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.adds-background-only/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.aligns-ids-and-patches/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.aligns-ids-and-patches/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.array-diff/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.array-diff/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.batch-multiple-patches/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.batch-multiple-patches/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.nullish-values/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.nullish-values/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.object-value-updates/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.object-value-updates/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.patches-nested-component/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.patches-nested-component/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.removes-missing/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.removes-missing/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.skips-identical/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.skips-identical/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.style-object-updates/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.style-object-updates/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.type-diff/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/attrs.type-diff/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.creates-missing-nodes-recursively/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.creates-missing-nodes-recursively/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.iterates-existing-slots/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.iterates-existing-slots/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-attrs-element/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-attrs-element/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-slot-record-on-background/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-slot-record-on-background/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-slot-record-on-main/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.missing-slot-record-on-main/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.raw-text-instance-empty-text/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/children.raw-text-instance-empty-text/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.emit-create-raw-text-non-text/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.emit-create-raw-text-non-text/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.emit-create-raw-text/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.emit-create-raw-text/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.move-before-child/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.move-before-child/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.raw-text-key-branches/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/coverage.raw-text-key-branches/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/full-flow.dispatches-update-event/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/full-flow.dispatches-update-event/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/reports-key-mismatch/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/reports-key-mismatch/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/updates-raw-text-instance-id/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate/background-hydrate => background/hydrate}/updates-raw-text-instance-id/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/background/{init-data-update => init-data/update}/index.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/background/update/{ => keyed}/compiled-keyed-list/index.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/background/update/{ => keyed}/compiled-keyed-subtree-list/index.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/background/{update-sparse/mount-sparse-template => update/sparse/compiled-element-slot}/index.tsx (100%) delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt delete mode 100644 packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/_shared.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/multiple-root-instances/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/multiple-root-instances/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/nested-instances/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/nested-instances/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/simple-element/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/simple-element/output.txt (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/sub-components/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/sub-components/output.txt (86%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/sub-components/source.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/text-children/case.tsx (100%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/text-children/output.txt (89%) rename packages/react/runtime/__test__/element-template/fixtures/{hydrate => hydration}/hydration-data/text-children/source.tsx (100%) rename packages/react/runtime/__test__/element-template/runtime/{hydration => background/hydrate}/compiled-fixtures.test.ts (56%) create mode 100644 packages/react/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts rename packages/react/runtime/__test__/element-template/runtime/background/{init-data-compiled-fixtures.test.tsx => init-data/compiled-fixtures.test.tsx} (67%) create mode 100644 packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts diff --git a/packages/react/runtime/__test__/element-template/README.md b/packages/react/runtime/__test__/element-template/README.md deleted file mode 100644 index 8efbf4e37c..0000000000 --- a/packages/react/runtime/__test__/element-template/README.md +++ /dev/null @@ -1,75 +0,0 @@ -# Element Template Tests - -This directory contains the dedicated test suite for `src/element-template/**`. - -## Layout - -- `runtime/`: tests mapped to runtime implementation areas under `src/element-template/runtime/`. -- `runtime/background/`: tests for background-side document, instance, commit, and render behavior. -- `native/`: tests for native entrypoints and thread bridge setup. -- `debug/`: tests for Element Template specific debug and profiling hooks. -- `lynx/`: tests for Lynx-facing timing and performance integration. -- `internal/`: tests for internal compatibility or guard behavior. -- `imports/`: guardrail tests that enforce import boundaries or entrypoint constraints. -- `fixtures/`: fixture data used by integration-style suites. -- `test-utils/`: mocks, serializers, fixture runners, and shared ET-only helpers. - -## Test Layers - -- `imports/` and `internal/` are architecture guardrails. - They should stay stable unless the ET entrypoint boundary itself changes. -- Narrow module tests under `runtime/`, `native/`, `debug/`, and `lynx/` primarily validate local module behavior. - They may move when source modules are split or renamed, but their behavioral assertions should remain stable. -- Fixture-driven suites validate cross-module contracts. - These are the primary protection for render, hydration, patch, and compiled ET flows. - -## Test Infrastructure Roles - -- `test-utils/mock/` owns fake native and environment surfaces: - - mock native PAPI - - mock JSContext - - performance / global setup helpers -- `test-utils/debug/` owns ET-specific execution helpers: - - fixture runners - - compiled render runners - - serializer / template registry helpers - - debug-only thread or update runners -- When runtime internals are refactored, prefer updating `test-utils/debug/` adapters instead of rewriting many suites independently. - -## Placement Rules - -- If a test targets one source module or one small group of closely related modules, place it under the matching source-domain directory. -- If a test validates a render, hydrate, patch, or background flow across multiple modules, prefer a fixture-based suite. -- Prefer `case.ts` / `case.tsx` fixtures by default. Use `index.tsx` fixtures only when the test is intentionally blessing compiled output and template registration together with runtime render. -- Put import-boundary and architecture guardrail tests in `imports/` instead of the root. -- Avoid adding new root-level test files unless the test truly spans multiple top-level ET domains. - -## Fixture Conventions - -- Fixture directories live under `fixtures/` and should mirror the owning test domain, for example `fixtures/patch/` or `fixtures/background/render/`. -- A fixture case is discovered when a directory contains `case.ts`, `case.tsx`, or `index.tsx`. -- Most case-driven suites should use `runCaseModuleFixtureTests(...)` from [test-utils/debug/fixtureRunner.ts](/Users/bytedance/lynx/workspace.worktrees/element-template-demo/rspeedy/lynx-stack/packages/react/runtime/__test__/element-template/test-utils/debug/fixtureRunner.ts). -- Compiled render fixtures should use [test-utils/debug/renderFixtureRunner.ts](/Users/bytedance/lynx/workspace.worktrees/element-template-demo/rspeedy/lynx-stack/packages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts) so compile, template blessing, and render assertions stay in one ET-specific runner instead of being reimplemented per suite. -- Expected `lynx.reportError` calls should be declared via `reportErrorCount` on fixture case modules or asserted locally and then reset explicitly before teardown. - -## Stability Rules - -- Refactors may change helper names, file locations, or runner internals, but should not silently relax: - - contract test assertions - - fixture output shape - - import-boundary guardrails -- If a runtime refactor requires broad test updates, update the shared runner or adapter layer first, then keep high-level contract expectations intact where possible. - -## Commands - -Run the ET suite from `packages/react/runtime/`: - -```bash -pnpm test:et -``` - -When debugging config-loader issues locally, this fallback runs the same suite without changing test semantics: - -```bash -pnpm exec vitest run --configLoader runner -c __test__/element-template/vitest.config.ts -``` diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt new file mode 100644 index 0000000000..53586eadfb --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.creates-and-inserts-new/output.txt @@ -0,0 +1,19 @@ +Object { + "ops": Array [ + Object { + "attributeSlots": Array [], + "bundleUrl": null, + "elementSlots": Array [], + "handleId": 3, + "op": "createTemplate", + "templateKey": "_et_c78ac_test_2", + }, + Object { + "childId": 3, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": 0, + "targetId": -1, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt new file mode 100644 index 0000000000..7588ad9497 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.inserts-before-existing-sibling/output.txt @@ -0,0 +1,19 @@ +Object { + "ops": Array [ + Object { + "attributeSlots": Array [], + "bundleUrl": null, + "elementSlots": Array [], + "handleId": 3, + "op": "createTemplate", + "templateKey": "_et_469e0_test_2", + }, + Object { + "childId": 3, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": -1, + "targetId": -3, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt new file mode 100644 index 0000000000..da3a74f6e7 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.mixed-operations/output.txt @@ -0,0 +1,28 @@ +Object { + "ops": Array [ + Object { + "childId": -1, + "elementSlotIndex": 0, + "op": "removeNode", + "removedSubtreeHandleIds": Array [ + -1, + ], + "targetId": -3, + }, + Object { + "attributeSlots": Array [], + "bundleUrl": null, + "elementSlots": Array [], + "handleId": 4, + "op": "createTemplate", + "templateKey": "_et_45693_test_3", + }, + Object { + "childId": 4, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": 0, + "targetId": -3, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt new file mode 100644 index 0000000000..1dc8756486 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.moves-before-existing-sibling/output.txt @@ -0,0 +1,11 @@ +Object { + "ops": Array [ + Object { + "childId": -1, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": -3, + "targetId": -4, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt new file mode 100644 index 0000000000..48fb404b89 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt @@ -0,0 +1,21 @@ +Object { + "ops": Array [ + Object { + "attributeSlots": Array [ + 2, + ], + "bundleUrl": null, + "elementSlots": Array [], + "handleId": 3, + "op": "createTemplate", + "templateKey": "_et_builtin_raw_text", + }, + Object { + "childId": 3, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": 0, + "targetId": -2, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt new file mode 100644 index 0000000000..a03ac8dab6 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.removes-missing/output.txt @@ -0,0 +1,13 @@ +Object { + "ops": Array [ + Object { + "childId": -1, + "elementSlotIndex": 0, + "op": "removeNode", + "removedSubtreeHandleIds": Array [ + -1, + ], + "targetId": -2, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt new file mode 100644 index 0000000000..fdee1b4476 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reorders-when-order-differs/output.txt @@ -0,0 +1,11 @@ +Object { + "ops": Array [ + Object { + "childId": -1, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": 0, + "targetId": -3, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt new file mode 100644 index 0000000000..24920b0ac3 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt @@ -0,0 +1,16 @@ +Object { + "ops": Array [ + Object { + "attrSlotIndex": 0, + "op": "setAttribute", + "targetId": -1, + "value": "2", + }, + Object { + "attrSlotIndex": 0, + "op": "setAttribute", + "targetId": -2, + "value": "1", + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt new file mode 100644 index 0000000000..a7e1326d7c --- /dev/null +++ b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt @@ -0,0 +1,25 @@ +Object { + "ops": Array [ + Object { + "attrSlotIndex": 0, + "op": "setAttribute", + "targetId": -1, + "value": "BG", + }, + Object { + "attributeSlots": Array [], + "bundleUrl": null, + "elementSlots": Array [], + "handleId": 7, + "op": "createTemplate", + "templateKey": "_et_25b95_test_5", + }, + Object { + "childId": 7, + "elementSlotIndex": 0, + "op": "insertNode", + "referenceId": 0, + "targetId": -4, + }, + ], +} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/_shared.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/_shared.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/_shared.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.adds-background-only/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.adds-background-only/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.adds-background-only/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.adds-background-only/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.adds-background-only/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.aligns-ids-and-patches/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.aligns-ids-and-patches/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.aligns-ids-and-patches/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.aligns-ids-and-patches/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.aligns-ids-and-patches/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.array-diff/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.array-diff/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.array-diff/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.array-diff/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.array-diff/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.batch-multiple-patches/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.batch-multiple-patches/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.batch-multiple-patches/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.batch-multiple-patches/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.batch-multiple-patches/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.nullish-values/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.nullish-values/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.nullish-values/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.nullish-values/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.nullish-values/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.object-value-updates/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.object-value-updates/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.object-value-updates/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.object-value-updates/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.object-value-updates/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.patches-nested-component/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.patches-nested-component/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.patches-nested-component/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.patches-nested-component/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.patches-nested-component/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.removes-missing/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.removes-missing/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.removes-missing/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.removes-missing/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.removes-missing/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.skips-identical/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.skips-identical/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.skips-identical/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.skips-identical/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.skips-identical/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.style-object-updates/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.style-object-updates/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.style-object-updates/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.style-object-updates/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.style-object-updates/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.type-diff/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.type-diff/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.type-diff/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/attrs.type-diff/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/attrs.type-diff/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.creates-missing-nodes-recursively/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.creates-missing-nodes-recursively/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.creates-missing-nodes-recursively/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.creates-missing-nodes-recursively/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.creates-missing-nodes-recursively/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.iterates-existing-slots/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.iterates-existing-slots/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.iterates-existing-slots/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.iterates-existing-slots/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.iterates-existing-slots/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-attrs-element/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-attrs-element/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-attrs-element/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-attrs-element/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-attrs-element/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-background/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-background/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-background/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-background/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-background/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-main/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-main/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-main/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.missing-slot-record-on-main/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.missing-slot-record-on-main/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.raw-text-instance-empty-text/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.raw-text-instance-empty-text/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.raw-text-instance-empty-text/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/children.raw-text-instance-empty-text/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/children.raw-text-instance-empty-text/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text-non-text/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text-non-text/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text-non-text/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text-non-text/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text-non-text/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.emit-create-raw-text/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.emit-create-raw-text/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.move-before-child/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.move-before-child/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.move-before-child/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.move-before-child/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.move-before-child/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.raw-text-key-branches/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.raw-text-key-branches/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.raw-text-key-branches/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/coverage.raw-text-key-branches/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/coverage.raw-text-key-branches/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/full-flow.dispatches-update-event/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/full-flow.dispatches-update-event/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/full-flow.dispatches-update-event/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/full-flow.dispatches-update-event/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/full-flow.dispatches-update-event/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/reports-key-mismatch/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/reports-key-mismatch/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/reports-key-mismatch/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/reports-key-mismatch/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/reports-key-mismatch/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/updates-raw-text-instance-id/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/updates-raw-text-instance-id/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/updates-raw-text-instance-id/output.txt b/packages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate/updates-raw-text-instance-id/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/background/hydrate/updates-raw-text-instance-id/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/init-data-update/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/init-data/update/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/background/init-data-update/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/init-data/update/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/update/compiled-keyed-list/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-list/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/background/update/compiled-keyed-list/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-list/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/update/compiled-keyed-subtree-list/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-subtree-list/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/background/update/compiled-keyed-subtree-list/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/update/keyed/compiled-keyed-subtree-list/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/background/update-sparse/mount-sparse-template/index.tsx b/packages/react/runtime/__test__/element-template/fixtures/background/update/sparse/compiled-element-slot/index.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/background/update-sparse/mount-sparse-template/index.tsx rename to packages/react/runtime/__test__/element-template/fixtures/background/update/sparse/compiled-element-slot/index.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txt deleted file mode 100644 index 425a5c230b..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.creates-and-inserts-new/output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Object { - "stream": Array [ - 1, - 3, - "_et_77307_test_2", - null, - Array [], - Array [], - 3, - -1, - 0, - 3, - 0, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txt deleted file mode 100644 index 9c533daae5..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.inserts-before-existing-sibling/output.txt +++ /dev/null @@ -1,15 +0,0 @@ -Object { - "stream": Array [ - 1, - 3, - "_et_f9aab_test_2", - null, - Array [], - Array [], - 3, - -3, - 0, - 3, - -1, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txt deleted file mode 100644 index 80cb62b7b8..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.mixed-operations/output.txt +++ /dev/null @@ -1,22 +0,0 @@ -Object { - "stream": Array [ - 4, - -3, - 0, - -1, - Array [ - -1, - ], - 1, - 4, - "_et_04991_test_3", - null, - Array [], - Array [], - 3, - -3, - 0, - 4, - 0, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txt deleted file mode 100644 index 51ed096c62..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.moves-before-existing-sibling/output.txt +++ /dev/null @@ -1,9 +0,0 @@ -Object { - "stream": Array [ - 3, - -4, - 0, - -1, - -3, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt deleted file mode 100644 index a6195536aa..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.non-string-raw-text-key-on-main/output.txt +++ /dev/null @@ -1,17 +0,0 @@ -Object { - "stream": Array [ - 1, - 3, - "_et_builtin_raw_text", - null, - Array [ - 2, - ], - Array [], - 3, - -2, - 0, - 3, - 0, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txt deleted file mode 100644 index 8edd66857d..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.removes-missing/output.txt +++ /dev/null @@ -1,11 +0,0 @@ -Object { - "stream": Array [ - 4, - -2, - 0, - -1, - Array [ - -1, - ], - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txt deleted file mode 100644 index 682c0467a3..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reorders-when-order-differs/output.txt +++ /dev/null @@ -1,9 +0,0 @@ -Object { - "stream": Array [ - 3, - -3, - 0, - -1, - 0, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt deleted file mode 100644 index 83d7dbd1d6..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/children.reuses-by-type-ignoring-keys/output.txt +++ /dev/null @@ -1,12 +0,0 @@ -Object { - "stream": Array [ - 2, - -1, - 0, - "2", - 2, - -2, - 0, - "1", - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt deleted file mode 100644 index 1b1a01ce5b..0000000000 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/background-hydrate-compiled/complex-trees.deeply-nested-dynamic-content/output.txt +++ /dev/null @@ -1,19 +0,0 @@ -Object { - "stream": Array [ - 2, - -1, - 0, - "BG", - 1, - 7, - "_et_c2579_test_5", - null, - Array [], - Array [], - 3, - -4, - 0, - 7, - 0, - ], -} diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/_shared.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/_shared.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/_shared.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/_shared.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/multiple-root-instances/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/multiple-root-instances/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/multiple-root-instances/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/multiple-root-instances/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/multiple-root-instances/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/nested-instances/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/nested-instances/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/nested-instances/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/nested-instances/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/nested-instances/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/simple-element/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/simple-element/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/simple-element/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/output.txt similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/simple-element/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/simple-element/output.txt diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txt similarity index 86% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txt index 896c24afab..298861340f 100644 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/output.txt +++ b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/output.txt @@ -17,12 +17,12 @@ Array [ }, ], ], - "templateKey": "_et_d549e_test_1", + "templateKey": "_et_afb9e_test_1", "uid": -2, }, ], ], - "templateKey": "_et_d549e_test_2", + "templateKey": "_et_afb9e_test_2", "uid": -3, }, ] diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/source.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/source.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/sub-components/source.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/sub-components/source.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/case.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/case.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/case.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/case.tsx diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/output.txt b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txt similarity index 89% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/output.txt rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txt index 32c10d1dfa..8bdd6a22e8 100644 --- a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/output.txt +++ b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/output.txt @@ -13,7 +13,7 @@ Array [ }, ], ], - "templateKey": "_et_d555c_test_1", + "templateKey": "_et_1692a_test_1", "uid": -2, }, ] diff --git a/packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/source.tsx b/packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/source.tsx similarity index 100% rename from packages/react/runtime/__test__/element-template/fixtures/hydrate/hydration-data/text-children/source.tsx rename to packages/react/runtime/__test__/element-template/fixtures/hydration/hydration-data/text-children/source.tsx diff --git a/packages/react/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx b/packages/react/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx index 53383ed561..619c51ab46 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx +++ b/packages/react/runtime/__test__/element-template/runtime/background/event/compiled-fixtures.test.tsx @@ -2,7 +2,6 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { createElement } from 'preact'; import { installElementTemplateCommitHook, @@ -17,7 +16,6 @@ import { BackgroundElementTemplateInstance, } from '../../../../../src/element-template/background/instance.js'; import { backgroundElementTemplateInstanceManager } from '../../../../../src/element-template/background/manager.js'; -import { root } from '../../../../../src/element-template/index.js'; import { clearEventState, getEventHandlerForEventValue, @@ -31,17 +29,17 @@ import type { } from '../../../../../src/element-template/protocol/types.js'; import { clearEtAttrPlanMap } from '../../../../../src/element-template/runtime/template/attr-slot-plan.js'; import { __root } from '../../../../../src/element-template/runtime/page/root-instance.js'; -import { compileFixtureSource } from '../../../test-utils/debug/compiledFixtureCompiler.js'; import { - loadCompiledFixtureModule, + loadCompiledFixturePair, type CompiledFixtureModuleExports, } from '../../../test-utils/debug/compiledFixtureModule.js'; -import { primeCompiledFixtureTemplates } from '../../../test-utils/debug/compiledFixtureRegistry.js'; +import { + renderCompiledFixtureOnBackground, + renderCompiledFixtureOnMainThread, +} from '../../../test-utils/debug/compiledThreadRunner.js'; import { ElementTemplateEnvManager } from '../../../test-utils/debug/envManager.js'; import { serializeBackgroundTree } from '../../../test-utils/debug/serializer.js'; -declare const renderPage: () => void; - const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const DIRECT_EVENT_FIXTURE = path.resolve(__dirname, '../../../fixtures/background/event/direct-event/index.tsx'); @@ -125,53 +123,34 @@ describe('Compiled direct event background updates', () => { backgroundModule: CompiledDirectEventModule; mainModule: CompiledDirectEventModule; }> { - const mainArtifact = await compileFixtureSource(DIRECT_EVENT_FIXTURE, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(DIRECT_EVENT_FIXTURE, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(DIRECT_EVENT_FIXTURE); } async function loadCompiledConditionalDirectEventFixture(): Promise<{ backgroundModule: CompiledConditionalDirectEventModule; mainModule: CompiledConditionalDirectEventModule; }> { - const mainArtifact = await compileFixtureSource(CONDITIONAL_DIRECT_EVENT_FIXTURE, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(CONDITIONAL_DIRECT_EVENT_FIXTURE, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule( - backgroundArtifact, + return loadCompiledFixturePair( + CONDITIONAL_DIRECT_EVENT_FIXTURE, ); - - return { backgroundModule, mainModule }; } async function loadCompiledSpreadEventFixture(): Promise<{ backgroundModule: CompiledSpreadEventModule; mainModule: CompiledSpreadEventModule; }> { - const mainArtifact = await compileFixtureSource(SPREAD_EVENT_FIXTURE, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(SPREAD_EVENT_FIXTURE, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(SPREAD_EVENT_FIXTURE); } function renderDirectEventOnBackground( moduleExports: CompiledDirectEventModule, onTap?: () => void, ): BackgroundElementTemplateInstance { - envManager.switchToBackground(); - root.render(createElement(moduleExports.App, { onTap })); - return getRenderedHost(); + const host = renderCompiledFixtureOnBackground(moduleExports, envManager, { onTap }); + if (!host) { + throw new Error('Missing rendered host.'); + } + return host; } function hydrateDirectEventFromMainThread( @@ -179,12 +158,7 @@ describe('Compiled direct event background updates', () => { onTap?: () => void, ): BackgroundElementTemplateInstance { const host = getRenderedHost(); - - envManager.switchToMainThread(); - root.render(createElement(moduleExports.App, { onTap })); - renderPage(); - envManager.switchToBackground(); - + renderCompiledFixtureOnMainThread(moduleExports, envManager, { onTap }); return host; } @@ -197,9 +171,15 @@ describe('Compiled direct event background updates', () => { childSpread?: SpreadFixtureProps; }, ): BackgroundElementTemplateInstance { - envManager.switchToBackground(); - root.render(createElement(moduleExports.App, { spread, onCatch, ...childOptions })); - return getRenderedHost(); + const host = renderCompiledFixtureOnBackground(moduleExports, envManager, { + spread, + onCatch, + ...childOptions, + }); + if (!host) { + throw new Error('Missing rendered host.'); + } + return host; } function hydrateSpreadEventFromMainThread( @@ -212,12 +192,11 @@ describe('Compiled direct event background updates', () => { }, ): BackgroundElementTemplateInstance { const host = getRenderedHost(); - - envManager.switchToMainThread(); - root.render(createElement(moduleExports.App, { spread, onCatch, ...childOptions })); - renderPage(); - envManager.switchToBackground(); - + renderCompiledFixtureOnMainThread(moduleExports, envManager, { + spread, + onCatch, + ...childOptions, + }); return host; } @@ -226,9 +205,11 @@ describe('Compiled direct event background updates', () => { show: boolean, onTap?: () => void, ): BackgroundElementTemplateInstance { - envManager.switchToBackground(); - root.render(createElement(moduleExports.App, { show, onTap })); - return getRenderedHost(); + const host = renderCompiledFixtureOnBackground(moduleExports, envManager, { show, onTap }); + if (!host) { + throw new Error('Missing rendered host.'); + } + return host; } function hydrateConditionalDirectEventFromMainThread( @@ -237,12 +218,7 @@ describe('Compiled direct event background updates', () => { onTap?: () => void, ): BackgroundElementTemplateInstance { const host = getRenderedHost(); - - envManager.switchToMainThread(); - root.render(createElement(moduleExports.App, { show, onTap })); - renderPage(); - envManager.switchToBackground(); - + renderCompiledFixtureOnMainThread(moduleExports, envManager, { show, onTap }); return host; } diff --git a/packages/react/runtime/__test__/element-template/runtime/background/hydrate.test.ts b/packages/react/runtime/__test__/element-template/runtime/background/hydrate.test.ts index bc360c843b..790904a18c 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/hydrate.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/background/hydrate.test.ts @@ -11,16 +11,9 @@ import { BUILTIN_RAW_TEXT_TEMPLATE_KEY, } from '../../../../src/element-template/background/instance.js'; import { backgroundElementTemplateInstanceManager } from '../../../../src/element-template/background/manager.js'; -import { clearEventState, getEventHandlerForEventValue } from '../../../../src/element-template/prop-adapters/event.js'; -import { clearRefState, flushPendingRefs } from '../../../../src/element-template/prop-adapters/ref.js'; import { ElementTemplateUpdateOps } from '../../../../src/element-template/protocol/opcodes.js'; import type { SerializedElementTemplate } from '../../../../src/element-template/protocol/types.js'; -import { - __etAttrPlanMap, - adaptEventAttrSlot, - adaptSpreadAttrSlot, - clearEtAttrPlanMap, -} from '../../../../src/element-template/runtime/template/attr-slot-plan.js'; +import { clearEtAttrPlanMap } from '../../../../src/element-template/runtime/template/attr-slot-plan.js'; function createHydrationTemplate( handleId: number, @@ -61,8 +54,6 @@ describe('hydrate', () => { backgroundElementTemplateInstanceManager.clear(); backgroundElementTemplateInstanceManager.nextId = 0; clearEtAttrPlanMap(); - clearEventState(); - clearRefState(); resetElementTemplateCommitState(); vi.clearAllMocks(); (globalThis as { __LYNX_REPORT_ERROR_CALLS?: Error[] }).__LYNX_REPORT_ERROR_CALLS = []; @@ -491,38 +482,6 @@ describe('hydrate', () => { expect(child.elementSlots[0]).toEqual([rawText]); }); - it('registers event handlers for background-only insertion subtrees during hydrate', () => { - __etAttrPlanMap.child = [0, adaptEventAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - const child = new BackgroundElementTemplateInstance('child'); - const handler = vi.fn(); - child.setAttribute('attributeSlots', [handler]); - root.appendChild(child); - - const stream = hydrate( - createHydrationTemplate(root.instanceId, 'root', { - elementSlots: [[]], - }), - root, - ); - - const eventValue = `${child.instanceId}:0:`; - expect(stream).toEqual([ - ElementTemplateUpdateOps.createTemplate, - child.instanceId, - 'child', - null, - [eventValue], - [], - ElementTemplateUpdateOps.insertNode, - root.instanceId, - 0, - child.instanceId, - 0, - ]); - expect(getEventHandlerForEventValue(eventValue)).toBe(handler); - }); - it('diffs multiple dynamic children slots independently during hydrate', () => { const root = new BackgroundElementTemplateInstance('root'); @@ -841,166 +800,27 @@ describe('hydrate', () => { expect(root.attributeSlots).toEqual([]); }); - it('prepares background event handlers with the serialized uid before diffing hydrate slots', () => { - __etAttrPlanMap.root = [0, adaptEventAttrSlot]; + it('skips sparse background slot indexes when checking trailing slots', () => { const root = new BackgroundElementTemplateInstance('root'); - const handler = vi.fn(); - root.setAttribute('attributeSlots', [handler]); - - const stream = hydrate( - createHydrationTemplate(-7, 'root', { - attributeSlots: ['-7:0:'], - }), - root, - ); - - expect(stream).toEqual([]); - expect(root.attributeSlots).toEqual(['-7:0:']); - expect(getEventHandlerForEventValue('-7:0:')).toBe(handler); - }); - - it('patches a hydrated event value when main thread serialized null but background has a handler', () => { - __etAttrPlanMap.root = [0, adaptEventAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - const handler = vi.fn(); - root.setAttribute('attributeSlots', [handler]); - - const stream = hydrate( - createHydrationTemplate(-8, 'root', { - attributeSlots: [null], - }), - root, - ); - - expect(stream).toEqual([ - ElementTemplateUpdateOps.setAttribute, - -8, - 0, - '-8:0:', - ]); - expect(root.attributeSlots).toEqual(['-8:0:']); - expect(getEventHandlerForEventValue('-8:0:')).toBe(handler); - }); - - it('patches null when main thread serialized an event value but background clears the handler', () => { - __etAttrPlanMap.root = [0, adaptEventAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - root.setAttribute('attributeSlots', [false]); - - const stream = hydrate( - createHydrationTemplate(-9, 'root', { - attributeSlots: ['-9:0:'], - }), - root, - ); - - expect(stream).toEqual([ - ElementTemplateUpdateOps.setAttribute, - -9, - 0, - null, - ]); - expect(root.attributeSlots).toEqual([null]); - expect(getEventHandlerForEventValue('-9:0:')).toBeUndefined(); - }); - - it('prepares background spread event handlers with the serialized uid before diffing hydrate slots', () => { - __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - const handleTap = vi.fn(); - root.setAttribute('attributeSlots', [{ - id: 'cta', - bindtap: handleTap, - }]); - const temporaryEventValue = `${root.instanceId}:0:bindtap`; - const preparedSpread = { id: 'cta', bindtap: '-10:0:bindtap' }; - expect(getEventHandlerForEventValue(temporaryEventValue)).toBe(handleTap); - - const stream = hydrate( - createHydrationTemplate(-10, 'root', { - attributeSlots: [preparedSpread], - }), - root, - ); - - expect(stream).toEqual([]); - expect(root.attributeSlots).toEqual([preparedSpread]); - expect(getEventHandlerForEventValue(temporaryEventValue)).toBeUndefined(); - expect(getEventHandlerForEventValue('-10:0:bindtap')).toBe(handleTap); - }); - - it('patches a hydrated spread value when main thread serialized null but background has a spread event', () => { - __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - const handleTap = vi.fn(); - root.setAttribute('attributeSlots', [{ - id: 'cta', - bindtap: handleTap, - }]); - const temporaryEventValue = `${root.instanceId}:0:bindtap`; - const preparedSpread = { id: 'cta', bindtap: '-11:0:bindtap' }; - expect(getEventHandlerForEventValue(temporaryEventValue)).toBe(handleTap); - - const stream = hydrate( - createHydrationTemplate(-11, 'root', { - attributeSlots: [null], - }), - root, - ); - - expect(stream).toEqual([ - ElementTemplateUpdateOps.setAttribute, - -11, - 0, - preparedSpread, - ]); - expect(root.attributeSlots).toEqual([preparedSpread]); - expect(getEventHandlerForEventValue(temporaryEventValue)).toBeUndefined(); - expect(getEventHandlerForEventValue('-11:0:bindtap')).toBe(handleTap); - }); - - it('patches null when main thread serialized a spread event value but background clears the spread slot', () => { - __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - root.setAttribute('attributeSlots', [false]); - - const stream = hydrate( - createHydrationTemplate(-12, 'root', { - attributeSlots: [{ bindtap: '-12:0:bindtap' }], - }), - root, - ); - - expect(stream).toEqual([ - ElementTemplateUpdateOps.setAttribute, - -12, - 0, - null, - ]); - expect(root.attributeSlots).toEqual([null]); - expect(getEventHandlerForEventValue('-12:0:bindtap')).toBeUndefined(); - }); - - it('prepares spread ref markers with the serialized uid without queueing hydrate ref callbacks', () => { - __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; - const root = new BackgroundElementTemplateInstance('root'); - const ref = vi.fn(); - root.setAttribute('attributeSlots', [{ ref }]); - flushPendingRefs(); - expect(ref).toHaveBeenCalledTimes(1); - ref.mockClear(); + const child = new BackgroundElementTemplateInstance('child'); + child.__slotIndex = 2; + root.appendChild(child); const stream = hydrate( - createHydrationTemplate(-13, 'root', { - attributeSlots: [{ ref: '-13-0' }], + createHydrationTemplate(root.instanceId, 'root', { + elementSlots: [ + undefined as unknown as SerializedElementTemplate[], + undefined as unknown as SerializedElementTemplate[], + [createHydrationChild(child.instanceId, 'child')], + ], }), root, ); - flushPendingRefs(); expect(stream).toEqual([]); - expect(root.attributeSlots).toEqual([{ ref: '-13-0' }]); - expect(ref).not.toHaveBeenCalled(); + expect(root.elementSlots[0]).toBeUndefined(); + expect(root.elementSlots[1]).toBeUndefined(); + expect(root.elementSlots[2]).toEqual([child]); }); it('emits create recursively for inserted nested children', () => { diff --git a/packages/react/runtime/__test__/element-template/runtime/hydration/compiled-fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.ts similarity index 56% rename from packages/react/runtime/__test__/element-template/runtime/hydration/compiled-fixtures.test.ts rename to packages/react/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.ts index 32fa408293..bab107292b 100644 --- a/packages/react/runtime/__test__/element-template/runtime/hydration/compiled-fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/background/hydrate/compiled-fixtures.test.ts @@ -4,15 +4,20 @@ import { fileURLToPath } from 'node:url'; import { beforeEach, describe } from 'vitest'; -import { clearTemplates } from '../../test-utils/debug/registry.js'; -import { assertOrUpdateTextFile, formatFixtureOutput, runFixtureTests } from '../../test-utils/debug/fixtureRunner.js'; -import { runCompiledHydrationScenario } from '../../test-utils/debug/compiledHydrationScenario.js'; +import { formatElementTemplateUpdateCommands } from '../../../../../src/element-template/debug/alog.js'; +import { clearTemplates } from '../../../test-utils/debug/registry.js'; +import { + assertOrUpdateTextFile, + formatFixtureOutput, + runFixtureTests, +} from '../../../test-utils/debug/fixtureRunner.js'; +import { runCompiledHydrationScenario } from '../../../test-utils/debug/compiledHydrationScenario.js'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/hydrate/background-hydrate-compiled'); +const FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/hydrate-compiled'); -describe('Compiled hydration fixtures', () => { +describe('Compiled background hydrate fixtures', () => { beforeEach(() => { clearTemplates(); }); @@ -28,7 +33,7 @@ describe('Compiled hydration fixtures', () => { const { stream } = await runCompiledHydrationScenario({ sourcePath }); assertOrUpdateTextFile({ path: path.join(fixtureDir, 'output.txt'), - actual: formatFixtureOutput({ stream }), + actual: formatFixtureOutput({ ops: formatElementTemplateUpdateCommands(stream) }), update, fixtureName, label: 'output', diff --git a/packages/react/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts new file mode 100644 index 0000000000..a763cef262 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/runtime/background/hydrate/fixtures.test.ts @@ -0,0 +1,16 @@ +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +import { describe } from 'vitest'; + +import { runCaseModuleFixtureTests } from '../../../test-utils/debug/fixtureRunner.js'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const BACKGROUND_HYDRATE_FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/hydrate'); + +describe('Background hydrate fixtures', () => { + runCaseModuleFixtureTests({ + fixturesRoot: BACKGROUND_HYDRATE_FIXTURES_DIR, + }); +}); diff --git a/packages/react/runtime/__test__/element-template/runtime/background/init-data-compiled-fixtures.test.tsx b/packages/react/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsx similarity index 67% rename from packages/react/runtime/__test__/element-template/runtime/background/init-data-compiled-fixtures.test.tsx rename to packages/react/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsx index 0623362616..41b37fb816 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/init-data-compiled-fixtures.test.tsx +++ b/packages/react/runtime/__test__/element-template/runtime/background/init-data/compiled-fixtures.test.tsx @@ -7,34 +7,34 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { installElementTemplateCommitHook, resetElementTemplateCommitState, -} from '../../../../src/element-template/background/commit-hook.js'; +} from '../../../../../src/element-template/background/commit-hook.js'; import { installElementTemplateHydrationListener, resetElementTemplateHydrationListener, -} from '../../../../src/element-template/background/hydration-listener.js'; -import { root } from '../../../../src/element-template/index.js'; -import { updateCardData } from '../../../../src/core/lynx-update-data.js'; +} from '../../../../../src/element-template/background/hydration-listener.js'; +import { root } from '../../../../../src/element-template/index.js'; +import { updateCardData } from '../../../../../src/core/lynx-update-data.js'; import { installElementTemplatePatchListener, resetElementTemplatePatchListener, -} from '../../../../src/element-template/native/patch-listener.js'; -import { ElementTemplateLifecycleConstant } from '../../../../src/element-template/protocol/lifecycle-constant.js'; -import type { ElementTemplateUpdateCommitContext } from '../../../../src/element-template/protocol/types.js'; -import { __page } from '../../../../src/element-template/runtime/page/page.js'; -import { clearEtAttrPlanMap } from '../../../../src/element-template/runtime/template/attr-slot-plan.js'; -import { LynxTestEventEmitter } from '../../../test-utils/lynx-event-emitter.js'; -import { compileFixtureSource } from '../../test-utils/debug/compiledFixtureCompiler.js'; -import { loadCompiledFixtureModule } from '../../test-utils/debug/compiledFixtureModule.js'; -import type { CompiledFixtureModuleExports } from '../../test-utils/debug/compiledFixtureModule.js'; -import { primeCompiledFixtureTemplates } from '../../test-utils/debug/compiledFixtureRegistry.js'; -import { ElementTemplateEnvManager } from '../../test-utils/debug/envManager.js'; -import { serializeToJSX } from '../../test-utils/debug/serializer.js'; +} from '../../../../../src/element-template/native/patch-listener.js'; +import { ElementTemplateLifecycleConstant } from '../../../../../src/element-template/protocol/lifecycle-constant.js'; +import type { ElementTemplateUpdateCommitContext } from '../../../../../src/element-template/protocol/types.js'; +import { __page } from '../../../../../src/element-template/runtime/page/page.js'; +import { clearEtAttrPlanMap } from '../../../../../src/element-template/runtime/template/attr-slot-plan.js'; +import { LynxTestEventEmitter } from '../../../../test-utils/lynx-event-emitter.js'; +import { + loadCompiledFixturePair, + type CompiledFixtureModuleExports, +} from '../../../test-utils/debug/compiledFixtureModule.js'; +import { ElementTemplateEnvManager } from '../../../test-utils/debug/envManager.js'; +import { serializeToJSX } from '../../../test-utils/debug/serializer.js'; declare const renderPage: (data?: Record) => void; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const FIXTURE = path.resolve(__dirname, '../../fixtures/background/init-data-update/index.tsx'); +const FIXTURE = path.resolve(__dirname, '../../../fixtures/background/init-data/update/index.tsx'); function waitForRender(): Promise { return new Promise(resolve => setTimeout(resolve, 0)); @@ -44,14 +44,7 @@ async function loadCompiledInitDataFixture(): Promise<{ backgroundModule: CompiledFixtureModuleExports; mainModule: CompiledFixtureModuleExports; }> { - const mainArtifact = await compileFixtureSource(FIXTURE, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(FIXTURE, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(FIXTURE); } describe('Compiled ET InitData updateData fixture', () => { diff --git a/packages/react/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts index 05cc80cc70..369645c1c9 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/background/instance/fixtures.test.ts @@ -12,6 +12,5 @@ const FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/insta describe('Background instance fixtures', () => { runCaseModuleFixtureTests({ fixturesRoot: FIXTURES_DIR, - allowEmpty: true, }); }); diff --git a/packages/react/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx b/packages/react/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx index 16f8f6128a..45c0206126 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx +++ b/packages/react/runtime/__test__/element-template/runtime/background/ref/compiled-fixtures.test.tsx @@ -2,7 +2,6 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { createElement } from 'preact'; import { installElementTemplateCommitHook, @@ -13,23 +12,22 @@ import { resetElementTemplateHydrationListener, } from '../../../../../src/element-template/background/hydration-listener.js'; import { BackgroundElementTemplateInstance } from '../../../../../src/element-template/background/instance.js'; -import { root } from '../../../../../src/element-template/index.js'; import { clearRefState } from '../../../../../src/element-template/prop-adapters/ref.js'; import { ElementTemplateLifecycleConstant } from '../../../../../src/element-template/protocol/lifecycle-constant.js'; import { ElementTemplateUpdateOps } from '../../../../../src/element-template/protocol/opcodes.js'; import type { ElementTemplateUpdateCommitContext } from '../../../../../src/element-template/protocol/types.js'; import { clearEtAttrPlanMap } from '../../../../../src/element-template/runtime/template/attr-slot-plan.js'; import { __root } from '../../../../../src/element-template/runtime/page/root-instance.js'; -import { compileFixtureSource } from '../../../test-utils/debug/compiledFixtureCompiler.js'; import { - loadCompiledFixtureModule, + loadCompiledFixturePair, type CompiledFixtureModuleExports, } from '../../../test-utils/debug/compiledFixtureModule.js'; -import { primeCompiledFixtureTemplates } from '../../../test-utils/debug/compiledFixtureRegistry.js'; +import { + renderCompiledFixtureOnBackground, + renderCompiledFixtureOnMainThread, +} from '../../../test-utils/debug/compiledThreadRunner.js'; import { ElementTemplateEnvManager } from '../../../test-utils/debug/envManager.js'; -declare const renderPage: () => void; - const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const DIRECT_REF_FIXTURE = path.resolve(__dirname, '../../../fixtures/background/ref/direct-ref/index.tsx'); @@ -63,7 +61,7 @@ interface UnsupportedFixtureProps { workletRef?: unknown; } -interface CompiledAppModule extends CompiledFixtureModuleExports { +interface CompiledAppModule extends CompiledFixtureModuleExports { App: (props: TProps) => JSX.Element; } @@ -73,14 +71,7 @@ async function loadCompiledFixture( backgroundModule: T; mainModule: T; }> { - const mainArtifact = await compileFixtureSource(sourcePath, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(sourcePath, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(sourcePath); } function getRenderedHost(): BackgroundElementTemplateInstance { @@ -98,26 +89,23 @@ describe('Compiled ordinary ref background updates', () => { updateEvents.push(event.data as ElementTemplateUpdateCommitContext); }; - function renderOnBackground( + function renderOnBackground( moduleExports: CompiledAppModule, props: TProps, ): BackgroundElementTemplateInstance { - envManager.switchToBackground(); - root.render(createElement(moduleExports.App, props)); - return getRenderedHost(); + const host = renderCompiledFixtureOnBackground(moduleExports, envManager, props); + if (!host) { + throw new Error('Missing rendered host.'); + } + return host; } - function hydrateFromMainThread( + function hydrateFromMainThread( moduleExports: CompiledAppModule, props: TProps, ): BackgroundElementTemplateInstance { const host = getRenderedHost(); - - envManager.switchToMainThread(); - root.render(createElement(moduleExports.App, props)); - renderPage(); - envManager.switchToBackground(); - + renderCompiledFixtureOnMainThread(moduleExports, envManager, props); return host; } diff --git a/packages/react/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts index 13a3d0b2b7..7d7c52715f 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/background/render/fixtures.test.ts @@ -12,6 +12,5 @@ const FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/rende describe('Background render fixtures', () => { runCaseModuleFixtureTests({ fixturesRoot: FIXTURES_DIR, - allowEmpty: true, }); }); diff --git a/packages/react/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx b/packages/react/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx index 05d56288de..a254207078 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx +++ b/packages/react/runtime/__test__/element-template/runtime/background/update/compiled-fixtures.test.tsx @@ -2,7 +2,6 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; -import { createElement } from 'preact'; import { installElementTemplateCommitHook, @@ -17,7 +16,6 @@ import { BackgroundElementTemplateInstance, } from '../../../../../src/element-template/background/instance.js'; import { backgroundElementTemplateInstanceManager } from '../../../../../src/element-template/background/manager.js'; -import { root } from '../../../../../src/element-template/index.js'; import { ElementTemplateLifecycleConstant } from '../../../../../src/element-template/protocol/lifecycle-constant.js'; import { ElementTemplateUpdateOps } from '../../../../../src/element-template/protocol/opcodes.js'; import type { @@ -26,21 +24,21 @@ import type { } from '../../../../../src/element-template/protocol/types.js'; import { clearEtAttrPlanMap } from '../../../../../src/element-template/runtime/template/attr-slot-plan.js'; import { __root } from '../../../../../src/element-template/runtime/page/root-instance.js'; -import { compileFixtureSource } from '../../../test-utils/debug/compiledFixtureCompiler.js'; import { - loadCompiledFixtureModule, + loadCompiledFixturePair, type CompiledFixtureModuleExports, } from '../../../test-utils/debug/compiledFixtureModule.js'; -import { primeCompiledFixtureTemplates } from '../../../test-utils/debug/compiledFixtureRegistry.js'; +import { + renderCompiledFixtureOnBackground, + renderCompiledFixtureOnMainThread, +} from '../../../test-utils/debug/compiledThreadRunner.js'; import { ElementTemplateEnvManager } from '../../../test-utils/debug/envManager.js'; import { runFixtureTests } from '../../../test-utils/debug/fixtureRunner.js'; import { serializeBackgroundTree } from '../../../test-utils/debug/serializer.js'; -declare const renderPage: () => void; - const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/update'); +const FIXTURES_DIR = path.resolve(__dirname, '../../../fixtures/background/update/keyed'); const SLOT_ID = 0; interface CompiledKeyedListModule extends CompiledFixtureModuleExports { @@ -101,23 +99,20 @@ describe('Compiled background Preact updates', () => { backgroundModule: CompiledKeyedListModule; mainModule: CompiledKeyedListModule; }> { - const mainArtifact = await compileFixtureSource(sourcePath, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(sourcePath, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(sourcePath); } function renderCompiledOnBackground( moduleExports: CompiledKeyedListModule, items: readonly string[], ): BackgroundElementTemplateInstance { - envManager.switchToBackground(); - root.render(createElement(moduleExports.App, { items: [...items] })); - return getRenderedHost(); + const host = renderCompiledFixtureOnBackground(moduleExports, envManager, { + items: [...items], + }); + if (!host) { + throw new Error('Missing rendered host.'); + } + return host; } function hydrateFromMainThread( @@ -125,12 +120,7 @@ describe('Compiled background Preact updates', () => { items: readonly string[], ): BackgroundElementTemplateInstance { const host = getRenderedHost(); - - envManager.switchToMainThread(); - root.render(createElement(moduleExports.App, { items: [...items] })); - renderPage(); - envManager.switchToBackground(); - + renderCompiledFixtureOnMainThread(moduleExports, envManager, { items: [...items] }); return host; } diff --git a/packages/react/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx b/packages/react/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx index bb7d277313..cf0d76b1e7 100644 --- a/packages/react/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx +++ b/packages/react/runtime/__test__/element-template/runtime/background/update/sparse-fixtures.test.tsx @@ -22,12 +22,10 @@ import type { } from '../../../../../src/element-template/protocol/types.js'; import { clearEtAttrPlanMap } from '../../../../../src/element-template/runtime/template/attr-slot-plan.js'; import { __root } from '../../../../../src/element-template/runtime/page/root-instance.js'; -import { compileFixtureSource } from '../../../test-utils/debug/compiledFixtureCompiler.js'; import { - loadCompiledFixtureModule, type CompiledFixtureModuleExports, + loadCompiledFixturePair, } from '../../../test-utils/debug/compiledFixtureModule.js'; -import { primeCompiledFixtureTemplates } from '../../../test-utils/debug/compiledFixtureRegistry.js'; import { ElementTemplateEnvManager } from '../../../test-utils/debug/envManager.js'; declare const renderPage: () => void; @@ -36,11 +34,11 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const FIXTURE_DIR = path.resolve( __dirname, - '../../../fixtures/background/update-sparse/mount-sparse-template', + '../../../fixtures/background/update/sparse/compiled-element-slot', ); interface SparseTemplateAppProps { - mounted?: boolean; + showCard?: boolean; showHeader?: boolean; items?: string[]; } @@ -61,15 +59,7 @@ async function loadFixture(): Promise<{ backgroundModule: SparseTemplateModule; mainModule: SparseTemplateModule; }> { - const sourcePath = path.join(FIXTURE_DIR, 'index.tsx'); - const mainArtifact = await compileFixtureSource(sourcePath, { target: 'LEPUS' }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); - - const backgroundArtifact = await compileFixtureSource(sourcePath, { target: 'JS' }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); - - return { backgroundModule, mainModule }; + return loadCompiledFixturePair(path.join(FIXTURE_DIR, 'index.tsx')); } describe('Sparse element slot updates', () => { diff --git a/packages/react/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts index dd3609b5b4..ebb5eb4645 100644 --- a/packages/react/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/hydration/fixtures.test.ts @@ -7,17 +7,10 @@ import { runCaseModuleFixtureTests } from '../../test-utils/debug/fixtureRunner. const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -const HYDRATION_DATA_FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/hydrate/hydration-data'); -const BACKGROUND_HYDRATE_FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/hydrate/background-hydrate'); +const HYDRATION_DATA_FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/hydration/hydration-data'); describe('Hydration fixtures', () => { runCaseModuleFixtureTests({ fixturesRoot: HYDRATION_DATA_FIXTURES_DIR, - allowEmpty: true, - }); - - runCaseModuleFixtureTests({ - fixturesRoot: BACKGROUND_HYDRATE_FIXTURES_DIR, - allowEmpty: true, }); }); diff --git a/packages/react/runtime/__test__/element-template/runtime/page/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/page/fixtures.test.ts index 60c2d02a6a..6e7488fb1f 100644 --- a/packages/react/runtime/__test__/element-template/runtime/page/fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/page/fixtures.test.ts @@ -12,6 +12,5 @@ const FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/page'); describe('Page fixtures', () => { runCaseModuleFixtureTests({ fixturesRoot: FIXTURES_DIR, - allowEmpty: true, }); }); diff --git a/packages/react/runtime/__test__/element-template/runtime/patch/fixtures.test.ts b/packages/react/runtime/__test__/element-template/runtime/patch/fixtures.test.ts index 0ee3a8a13c..5d283f1cac 100644 --- a/packages/react/runtime/__test__/element-template/runtime/patch/fixtures.test.ts +++ b/packages/react/runtime/__test__/element-template/runtime/patch/fixtures.test.ts @@ -12,6 +12,5 @@ const FIXTURES_DIR = path.resolve(__dirname, '../../fixtures/patch'); describe('Patch fixtures', () => { runCaseModuleFixtureTests({ fixturesRoot: FIXTURES_DIR, - allowEmpty: true, }); }); diff --git a/packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts b/packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts new file mode 100644 index 0000000000..452fb02105 --- /dev/null +++ b/packages/react/runtime/__test__/element-template/runtime/prop-adapters/hydrate.test.ts @@ -0,0 +1,245 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest'; + +import { resetElementTemplateCommitState } from '../../../../src/element-template/background/commit-hook.js'; +import { hydrate } from '../../../../src/element-template/background/hydrate.js'; +import { BackgroundElementTemplateInstance } from '../../../../src/element-template/background/instance.js'; +import { backgroundElementTemplateInstanceManager } from '../../../../src/element-template/background/manager.js'; +import { clearEventState, getEventHandlerForEventValue } from '../../../../src/element-template/prop-adapters/event.js'; +import { clearRefState, flushPendingRefs } from '../../../../src/element-template/prop-adapters/ref.js'; +import { ElementTemplateUpdateOps } from '../../../../src/element-template/protocol/opcodes.js'; +import type { SerializedElementTemplate } from '../../../../src/element-template/protocol/types.js'; +import { + __etAttrPlanMap, + adaptEventAttrSlot, + adaptSpreadAttrSlot, + clearEtAttrPlanMap, +} from '../../../../src/element-template/runtime/template/attr-slot-plan.js'; + +function createHydrationTemplate( + handleId: number, + templateKey: string, + options: { + attributeSlots?: unknown[] | null; + elementSlots?: SerializedElementTemplate[][] | null; + } = {}, +): SerializedElementTemplate { + const serialized: SerializedElementTemplate = { + templateKey, + uid: handleId, + }; + if ('attributeSlots' in options) { + serialized.attributeSlots = options.attributeSlots as SerializedElementTemplate['attributeSlots']; + } + if ('elementSlots' in options) { + serialized.elementSlots = options.elementSlots as SerializedElementTemplate['elementSlots']; + } + return serialized; +} + +describe('Element Template prop adapter hydration', () => { + beforeEach(() => { + globalThis.__MAIN_THREAD__ = false; + globalThis.__BACKGROUND__ = true; + backgroundElementTemplateInstanceManager.clear(); + backgroundElementTemplateInstanceManager.nextId = 0; + clearEtAttrPlanMap(); + clearEventState(); + clearRefState(); + resetElementTemplateCommitState(); + vi.clearAllMocks(); + }); + + it('registers event handlers for background-only insertion subtrees during hydrate', () => { + __etAttrPlanMap.child = [0, adaptEventAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const child = new BackgroundElementTemplateInstance('child'); + const handler = vi.fn(); + child.setAttribute('attributeSlots', [handler]); + root.appendChild(child); + + const stream = hydrate( + createHydrationTemplate(root.instanceId, 'root', { + elementSlots: [[]], + }), + root, + ); + + const eventValue = `${child.instanceId}:0:`; + expect(stream).toEqual([ + ElementTemplateUpdateOps.createTemplate, + child.instanceId, + 'child', + null, + [eventValue], + [], + ElementTemplateUpdateOps.insertNode, + root.instanceId, + 0, + child.instanceId, + 0, + ]); + expect(getEventHandlerForEventValue(eventValue)).toBe(handler); + }); + + it('prepares background event handlers with the serialized uid before diffing hydrate slots', () => { + __etAttrPlanMap.root = [0, adaptEventAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const handler = vi.fn(); + root.setAttribute('attributeSlots', [handler]); + + const stream = hydrate( + createHydrationTemplate(-7, 'root', { + attributeSlots: ['-7:0:'], + }), + root, + ); + + expect(stream).toEqual([]); + expect(root.attributeSlots).toEqual(['-7:0:']); + expect(getEventHandlerForEventValue('-7:0:')).toBe(handler); + }); + + it('patches a hydrated event value when main thread serialized null but background has a handler', () => { + __etAttrPlanMap.root = [0, adaptEventAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const handler = vi.fn(); + root.setAttribute('attributeSlots', [handler]); + + const stream = hydrate( + createHydrationTemplate(-8, 'root', { + attributeSlots: [null], + }), + root, + ); + + expect(stream).toEqual([ + ElementTemplateUpdateOps.setAttribute, + -8, + 0, + '-8:0:', + ]); + expect(root.attributeSlots).toEqual(['-8:0:']); + expect(getEventHandlerForEventValue('-8:0:')).toBe(handler); + }); + + it('patches null when main thread serialized an event value but background clears the handler', () => { + __etAttrPlanMap.root = [0, adaptEventAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + root.setAttribute('attributeSlots', [false]); + + const stream = hydrate( + createHydrationTemplate(-9, 'root', { + attributeSlots: ['-9:0:'], + }), + root, + ); + + expect(stream).toEqual([ + ElementTemplateUpdateOps.setAttribute, + -9, + 0, + null, + ]); + expect(root.attributeSlots).toEqual([null]); + expect(getEventHandlerForEventValue('-9:0:')).toBeUndefined(); + }); + + it('prepares background spread event handlers with the serialized uid before diffing hydrate slots', () => { + __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const handleTap = vi.fn(); + root.setAttribute('attributeSlots', [{ + id: 'cta', + bindtap: handleTap, + }]); + const temporaryEventValue = `${root.instanceId}:0:bindtap`; + const preparedSpread = { id: 'cta', bindtap: '-10:0:bindtap' }; + expect(getEventHandlerForEventValue(temporaryEventValue)).toBe(handleTap); + + const stream = hydrate( + createHydrationTemplate(-10, 'root', { + attributeSlots: [preparedSpread], + }), + root, + ); + + expect(stream).toEqual([]); + expect(root.attributeSlots).toEqual([preparedSpread]); + expect(getEventHandlerForEventValue(temporaryEventValue)).toBeUndefined(); + expect(getEventHandlerForEventValue('-10:0:bindtap')).toBe(handleTap); + }); + + it('patches a hydrated spread value when main thread serialized null but background has a spread event', () => { + __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const handleTap = vi.fn(); + root.setAttribute('attributeSlots', [{ + id: 'cta', + bindtap: handleTap, + }]); + const temporaryEventValue = `${root.instanceId}:0:bindtap`; + const preparedSpread = { id: 'cta', bindtap: '-11:0:bindtap' }; + expect(getEventHandlerForEventValue(temporaryEventValue)).toBe(handleTap); + + const stream = hydrate( + createHydrationTemplate(-11, 'root', { + attributeSlots: [null], + }), + root, + ); + + expect(stream).toEqual([ + ElementTemplateUpdateOps.setAttribute, + -11, + 0, + preparedSpread, + ]); + expect(root.attributeSlots).toEqual([preparedSpread]); + expect(getEventHandlerForEventValue(temporaryEventValue)).toBeUndefined(); + expect(getEventHandlerForEventValue('-11:0:bindtap')).toBe(handleTap); + }); + + it('patches null when main thread serialized a spread event value but background clears the spread slot', () => { + __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + root.setAttribute('attributeSlots', [false]); + + const stream = hydrate( + createHydrationTemplate(-12, 'root', { + attributeSlots: [{ bindtap: '-12:0:bindtap' }], + }), + root, + ); + + expect(stream).toEqual([ + ElementTemplateUpdateOps.setAttribute, + -12, + 0, + null, + ]); + expect(root.attributeSlots).toEqual([null]); + expect(getEventHandlerForEventValue('-12:0:bindtap')).toBeUndefined(); + }); + + it('prepares spread ref markers with the serialized uid without queueing hydrate ref callbacks', () => { + __etAttrPlanMap.root = [0, adaptSpreadAttrSlot]; + const root = new BackgroundElementTemplateInstance('root'); + const ref = vi.fn(); + root.setAttribute('attributeSlots', [{ ref }]); + flushPendingRefs(); + expect(ref).toHaveBeenCalledTimes(1); + ref.mockClear(); + + const stream = hydrate( + createHydrationTemplate(-13, 'root', { + attributeSlots: [{ ref: '-13-0' }], + }), + root, + ); + flushPendingRefs(); + + expect(stream).toEqual([]); + expect(root.attributeSlots).toEqual([{ ref: '-13-0' }]); + expect(ref).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts index 7697190a7e..7cb7dc68a5 100644 --- a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts +++ b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledFixtureModule.ts @@ -3,7 +3,12 @@ import os from 'node:os'; import path from 'node:path'; import { pathToFileURL } from 'node:url'; -import type { CompiledFixtureArtifact } from './compiledFixtureCompiler.js'; +import { + compileFixtureSource, + type CompiledFixtureArtifact, + type CompiledFixtureTarget, +} from './compiledFixtureCompiler.js'; +import { primeCompiledFixtureTemplates } from './compiledFixtureRegistry.js'; export interface CompiledFixtureModuleExports { App: (props?: Record) => JSX.Element; @@ -24,3 +29,34 @@ export async function loadCompiledFixtureModule( + sourcePath: string, + options: LoadCompiledFixturePairOptions = {}, +): Promise<{ + backgroundModule: T; + mainModule: T; +}> { + const { + backgroundTarget = 'JS', + mainTarget = 'LEPUS', + registerMainTemplates = true, + } = options; + + const mainArtifact = await compileFixtureSource(sourcePath, { target: mainTarget }); + if (registerMainTemplates) { + primeCompiledFixtureTemplates(mainArtifact); + } + const mainModule = await loadCompiledFixtureModule(mainArtifact); + + const backgroundArtifact = await compileFixtureSource(sourcePath, { target: backgroundTarget }); + const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); + + return { backgroundModule, mainModule }; +} diff --git a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts index 5f75b458ee..9be94bdf08 100644 --- a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts +++ b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledHydrationScenario.ts @@ -8,11 +8,10 @@ import type { SerializedElementTemplate, } from '../../../../src/element-template/protocol/types.js'; import { installMockNativePapi } from '../mock/mockNativePapi.js'; -import { compileFixtureSource, type CompiledFixtureTarget } from './compiledFixtureCompiler.js'; -import { loadCompiledFixtureModule } from './compiledFixtureModule.js'; +import type { CompiledFixtureTarget } from './compiledFixtureCompiler.js'; +import { loadCompiledFixturePair } from './compiledFixtureModule.js'; import { ElementTemplateEnvManager } from './envManager.js'; import { extractSerializedHydrateInstances } from './hydratePayload.js'; -import { primeCompiledFixtureTemplates } from './compiledFixtureRegistry.js'; import { renderCompiledFixtureOnBackground, renderCompiledFixtureOnMainThread } from './compiledThreadRunner.js'; interface RunCompiledHydrationScenarioOptions { @@ -53,9 +52,10 @@ export async function runCompiledHydrationScenario( lynx.getCoreContext().addEventListener(ElementTemplateLifecycleConstant.hydrate, onHydrate); try { - const mainArtifact = await compileFixtureSource(sourcePath, { target: mainTarget }); - primeCompiledFixtureTemplates(mainArtifact); - const mainModule = await loadCompiledFixtureModule(mainArtifact); + const { backgroundModule, mainModule } = await loadCompiledFixturePair(sourcePath, { + backgroundTarget, + mainTarget, + }); renderCompiledFixtureOnMainThread(mainModule, envManager, mainProps); const before = hydrationData[0]; @@ -63,8 +63,6 @@ export async function runCompiledHydrationScenario( throw new Error('Missing compiled main-thread hydration data.'); } - const backgroundArtifact = await compileFixtureSource(sourcePath, { target: backgroundTarget }); - const backgroundModule = await loadCompiledFixtureModule(backgroundArtifact); const after = renderCompiledFixtureOnBackground(backgroundModule, envManager, backgroundProps); if (!after) { throw new Error('Missing compiled background root child.'); diff --git a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts index 4b9b939c43..f2bdf634e9 100644 --- a/packages/react/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts +++ b/packages/react/runtime/__test__/element-template/test-utils/debug/compiledThreadRunner.ts @@ -8,8 +8,14 @@ import type { CompiledFixtureModuleExports } from './compiledFixtureModule.js'; declare const renderPage: () => void; +interface RenderableCompiledFixture { + App: (props: TProps) => JSX.Element; + mainProps?: TProps; + backgroundProps?: TProps; +} + function resolveThreadProps( - moduleExports: CompiledFixtureModuleExports, + moduleExports: RenderableCompiledFixture> | CompiledFixtureModuleExports, thread: 'main' | 'background', overrideProps?: Record, ): Record { @@ -23,19 +29,23 @@ function resolveThreadProps( } function createAppVNode( - moduleExports: CompiledFixtureModuleExports, + moduleExports: RenderableCompiledFixture> | CompiledFixtureModuleExports, props: Record, ) { - return createElement(moduleExports.App, props); + return createElement(moduleExports.App as (props: Record) => JSX.Element, props); } -export function renderCompiledFixtureOnMainThread( - moduleExports: CompiledFixtureModuleExports, +export function renderCompiledFixtureOnMainThread>( + moduleExports: RenderableCompiledFixture | CompiledFixtureModuleExports, envManager: ElementTemplateEnvManager, - props?: Record, + props?: TProps, ): void { envManager.switchToMainThread(); - const resolvedProps = resolveThreadProps(moduleExports, 'main', props); + const resolvedProps = resolveThreadProps( + moduleExports, + 'main', + props as Record | undefined, + ); const vnode = createAppVNode(moduleExports, resolvedProps); root.render(vnode); renderPage(); @@ -43,13 +53,17 @@ export function renderCompiledFixtureOnMainThread( envManager.switchToBackground(); } -export function renderCompiledFixtureOnBackground( - moduleExports: CompiledFixtureModuleExports, +export function renderCompiledFixtureOnBackground>( + moduleExports: RenderableCompiledFixture | CompiledFixtureModuleExports, envManager: ElementTemplateEnvManager, - props?: Record, + props?: TProps, ): BackgroundElementTemplateInstance | null { envManager.switchToBackground(); - const resolvedProps = resolveThreadProps(moduleExports, 'background', props); + const resolvedProps = resolveThreadProps( + moduleExports, + 'background', + props as Record | undefined, + ); root.render(createAppVNode(moduleExports, resolvedProps)); const backgroundRoot = __root as BackgroundElementTemplateInstance; return backgroundRoot.firstChild; diff --git a/packages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts b/packages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts index fc2b1869e3..0a6b72aa8e 100644 --- a/packages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts +++ b/packages/react/runtime/__test__/element-template/test-utils/debug/renderFixtureRunner.ts @@ -138,6 +138,7 @@ async function runCompiledRenderFixture(options: { elementTemplateRegistry.clear(); clearEtAttrPlanMap(); resetTemplateId(); + clearEtAttrPlanMap(); globalThis.__USE_ELEMENT_TEMPLATE__ = true; globalThis.__LEPUS__ = true; @@ -260,6 +261,7 @@ async function runCompiledRenderFixture(options: { expectReportErrorCount(0); } finally { resetElementTemplateHydrationListener(); + clearEtAttrPlanMap(); cleanup(); globalThis.__USE_ELEMENT_TEMPLATE__ = undefined; }