Real-<Editor> integration test harness (catches the bug class mocked tests missed) #12
Reference in New Issue
Block a user
Delete Branch "integration-test-harness"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds
src/test-utils/editorHarness.tsxmounting a REAL Craft.js<Editor>+<Frame>in jsdom (no@craftjs/coremock; ResizeObserver/matchMedia/innerText shims), plus 3 integration suites for the flows whose MOCKED unit tests silently let real bugs ship: duplicate/paste (useNodeActions/useKeyboardShortcuts), template load (real TemplateModal tree-build vs SaaS Landing), AI apply-response (realuseApplyAiResponse).RED-PROOF: reverting
regenerateTreeIdsto the historicalstructuredClone(oldNode.data)makes the duplicate suite fail with the exactDataCloneError(silent no-op) — restored → green. So these tests genuinely have teeth. Test-only (no runtime/bundle change). 622 tests.🤖 Generated with Claude Code
Mocked unit tests for regenerateTreeIds, TemplateModal.addTemplateComponents, and buildNodeTree each let a real bug ship (DataCloneError on duplicate/paste, dropped template children, no-op AI section-replace/insert) because their fake @craftjs/core query/actions never exercised Craft's real node shape (data.type as a live component reference) or real parseFreshNode validation. Adds src/test-utils/editorHarness.tsx, which mounts a REAL <Editor>+<Frame> (no vi.mock('@craftjs/core') anywhere) via react-dom/client + act, plus the jsdom shims Craft/this component library actually needs (ResizeObserver, matchMedia, and an HTMLElement.prototype.innerText polyfill -- jsdom has no native innerText, which Heading/TextBlock rely on to paint their text). Adds 3 integration suites under src/test-utils/integration/ driving the real useNodeActions/useKeyboardShortcuts, TemplateModal's real tree-build pipeline, and the real useApplyAiResponse hook against a live EditorStore, asserting on both the real rendered DOM and query.serialize()/exportBodyHtml output. Red-proofed the duplicate/paste suite: temporarily reverted regenerateTreeIds to structuredClone(oldNode.data) and confirmed both tests fail with the historical DataCloneError before restoring the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>