Real-<Editor> integration test harness (catches the bug class mocked tests missed) #12

Merged
jknapp merged 1 commits from integration-test-harness into main 2026-07-14 00:12:49 +00:00
Owner

Adds src/test-utils/editorHarness.tsx mounting a REAL Craft.js <Editor>+<Frame> in jsdom (no @craftjs/core mock; 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 (real useApplyAiResponse).

RED-PROOF: reverting regenerateTreeIds to the historical structuredClone(oldNode.data) makes the duplicate suite fail with the exact DataCloneError (silent no-op) — restored → green. So these tests genuinely have teeth. Test-only (no runtime/bundle change). 622 tests.

🤖 Generated with Claude Code

Adds `src/test-utils/editorHarness.tsx` mounting a REAL Craft.js `<Editor>`+`<Frame>` in jsdom (no `@craftjs/core` mock; 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 (real `useApplyAiResponse`). RED-PROOF: reverting `regenerateTreeIds` to the historical `structuredClone(oldNode.data)` makes the duplicate suite fail with the exact `DataCloneError` (silent no-op) — restored → green. So these tests genuinely have teeth. Test-only (no runtime/bundle change). 622 tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
jknapp added 1 commit 2026-07-14 00:12:48 +00:00
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>
jknapp merged commit f80811318b into main 2026-07-14 00:12:49 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cloud-hosting-platform/site-builder#12