Repository navigation
[Bugs] core, nodes: tests no longer leak registry and store state across files - #1120
Merged
Merged
Conversation
verify_scene reads a kind's schema from the node registry before core's
own. drag-session and alignment-anchors tests register a stub 'wall'
(z.object({ type: z.literal('wall') })) and never restore it; when bun
enumerates those files before operations.test.ts, a wall with start: null
validates and five verify_scene tests fail. #903 only added a file, which
reordered the CI runner's file enumeration so nothing reset the registry
in between.
A test preload snapshots the registry before each test and restores it
after, so in-test and beforeEach registrations cannot outlive their test.
File-scope stub registrations (top level, beforeAll) restore in afterAll.
…s plugin wall-batch-system.test.ts set selection.selectedIds and previewSelectedIds to Sets (the store holds arrays) and never restored them, so 22 later stair, column and plan tests failed on .includes. It now uses arrays and restores the viewer state it found. The stair paint test relied on an earlier test in its file to load the built-in plugin.
…ment The mounted move session writes the placement preview and alignment guides and these tests never commit or cancel it, so a later stair tool mount rendered guide labels needing a DOM. Restoring document by assignment left an own document: undefined instead of removing it.
A test preload snapshots the node registry and the scene, live override, live transform, viewer, editor, placement preview and alignment guide stores before each test and restores them after.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
6 of 8 tasks
cursor Bot
pushed a commit
that referenced
this pull request
Oct 23, 2026
#1120's test-setup.ts restores the node registry around every test, so the per-file afterAll restores this branch added to eighteen core test files are gone: none of them registers at file scope. stair-surface-snap's file-level restore goes too (main's): it registers only in tests. Files that register at file scope keep theirs (mutations' beforeAll; port-connectivity, system-graph and validate-dwv through a top-level stubDef). registry-isolation.test.ts now reads each test file's syntax: a registry write at file scope (top level, a describe body, beforeAll, or a call there to the file's own writing helper) needs the file's own snapshot; writes in tests, beforeEach and helpers they call are the shared setup's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes the
qualityjob onmain, which has been red since #903. It also fixes 22 order-dependentnodestests.Root cause on CI (core, 5
verify_scenetests). Bun runs all of a package's test files in one process, in filesystem enumeration order. That order differs between machines and changes when a file is added.verify_scenelooks up a kind's schema in the node registry before falling back to core's own schemas.services/drag-session.test.tsandservices/alignment-anchors.test.tsregister a stubwallkind with schemaz.object({ type: z.literal('wall') })and never restore the registry. So when those files run beforeagent-operations/operations.test.ts, malformed walls pass validation:start: null, or a pool retyped aswall.On the last green run,
hosting.test.tshappened to run in between, and itsbeforeEachwiped the registry by accident. #903 changed no logic involved here. It only added a test file, which reordered the runner's file list so nothing cleaned up beforeoperations.test.ts. Running core in CI's exact 336-file order reproduces exactly those 5 failures locally.Changes
packages/core/test-setup.ts) that snapshotsnodeRegistrybefore each test and restores it after. Preload hooks wrap each file's own hooks, so registrations made inside a test or itsbeforeEach(including after a_reset()) end with that test. Stub registrations made at file scope (top level orbeforeAll), which a per-test hook can't reach, now restore inafterAll:validate-dwv,system-graph,port-connectivity,stair-surface-snapandprocedural-items/mutations.wall-batch-system.test.tssetuseViewer'sselection.selectedIdsandpreviewSelectedIdstoSets. The store holds arrays. It never restored them, so later stair, column and floor-plan tests threw on.includes. The test now uses arrays and restores the viewer state it started with.cabinet/hostingandshelf-hostingstart a mounted move session that writes the placement preview and alignment guides, and never commit or cancel it. They now clear both inafterEach. Leftover guides made a later stair tool mount render DOM labels.documentby assignment, which left an owndocument: undefinedproperty instead of removing it. They now restore by property descriptor, the way they already restorewindow.packages/nodes/test-setup.ts) snapshots and restores, around every test, the node registry and theuseScene,useLiveNodeOverrides,useLiveTransforms,useViewer,useEditor,usePlacementPreviewanduseAlignmentGuidesstores (the built@pascal-app/*instances).No timeouts were raised and no tests were skipped.
Not done: a random-order CI step.
bun test --randomizestill finds a few latent dependencies unrelated to these fixes, so as a required gate it would flake today:core/src/lib/structure-kernel.test.ts(seed 12);spatialGridManagersingleton in nodesframe-pipeline.test.tsx(seed 6).The per-test reset preloads are the guardrail in this PR.
How to test
bunx turbo run build --filter=@pascal-app/nodes..., so core's and nodes' self-imports resolve todist.packages/core, runbun test ./src/services/drag-session.test.ts ./src/agent-operations/operations.test.ts. Onmainthis reports the same 5 failures as CI; on this branch it reports 0 failures.packages/core, runbun test src. Expected: 5414 pass, 0 fail. Under--randomize, seeds 1, 2, 3, 11, 13 and 14 also pass.packages/nodes, runbun test. Onmain: 22 failures. On this branch: 5021 pass, 0 fail. Under--randomize, seeds 1, 2, 3, 4, 5, 7 and 8 also pass.Screenshots / screen recording
N/A — non-visual change (tests only).
Checklist
bun devbun checkto verify)mainbranchNote
Low Risk
Test-only harness and teardown changes; no production runtime behavior is modified.
Reviewed by Cursor Bugbot for commit 7314993. Bugbot is set up for automated code reviews on this repo. Configure here.