test(text-editor): real-stack test suite for schema, plugins, commands, and converters#4163
test(text-editor): real-stack test suite for schema, plugins, commands, and converters#4163john-traas wants to merge 14 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4163/ |
There was a problem hiding this comment.
Pull request overview
Adds a substantial “real stack” integration test suite for the ProseMirror-based text editor, exercising production schema + full plugin ordering and validating cross-plugin behaviors that are hard to catch with unit tests.
Changes:
- Introduces a shared
editor-test-stackhelper to build the production schema/plugins, create states, mount realEditorViews, and simulate typing/key events. - Adds spec-level coverage for schema contracts, menu commands, links, images, and tables.
- Adds browser e2e coverage for triggers, keymap/input rules through the full plugin chain, menu-state/action-bar interactions, and markdown/HTML serialization behavior.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/text-editor/prosemirror-adapter/editor-test-stack.ts | Shared harness for assembling the production editor stack and driving real-state/view interactions in tests. |
| src/components/text-editor/prosemirror-adapter/editor-triggers.e2e.ts | Browser e2e tests for trigger start/change/stop behavior and inserter mechanics. |
| src/components/text-editor/prosemirror-adapter/editor-commands.spec.ts | Spec tests for all menu commands (apply/active/allowed) against the real schema. |
| src/components/text-editor/prosemirror-adapter/editor-schema.spec.ts | Spec tests pinning schema divergence/semantics (marks, nodes, custom elements, lists). |
| src/components/text-editor/prosemirror-adapter/editor-links.spec.ts | Spec tests for link mark parsing + link plugin paste and selection-callback behavior. |
| src/components/text-editor/prosemirror-adapter/editor-links.e2e.ts | Browser e2e tests for link plugin DOM interactions (dblclick, click suppression, mod-click). |
| src/components/text-editor/prosemirror-adapter/editor-images.spec.ts | Spec tests for image node spec, image paste detection, and inserter behavior. |
| src/components/text-editor/prosemirror-adapter/editor-images.e2e.ts | Browser e2e tests for image node view rendering/state transitions and ARIA attributes. |
| src/components/text-editor/prosemirror-adapter/editor-tables.spec.ts | Spec tests for table plugin wiring, parse/serialize, and table repair behavior. |
| src/components/text-editor/prosemirror-adapter/editor-tables.e2e.ts | Browser e2e tests for table editing behaviors on a mounted view. |
| src/components/text-editor/prosemirror-adapter/editor-keymap.spec.ts | Spec tests for factory keymap bindings and equivalence to menu commands. |
| src/components/text-editor/prosemirror-adapter/editor-keymap.e2e.ts | Browser e2e tests for keymap resolution through the real plugin chain (history/lists/etc.). |
| src/components/text-editor/prosemirror-adapter/editor-input-rules.e2e.ts | Browser e2e tests for exampleSetup input rules + undo/redo sequencing. |
| src/components/text-editor/prosemirror-adapter/editor-menu-state.e2e.ts | Browser e2e tests for active-items tracking and action-bar event bridging. |
| src/components/text-editor/prosemirror-adapter/editor-serialization.e2e.ts | Browser e2e tests for markdown/html round-trips, loss matrix, sanitizer/custom-element plumbing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const handled = view.someProp('handleTextInput', (handler) => | ||
| handler(view, from, to, char, () => | ||
| view.state.tr.insertText(char, from, to) | ||
| ) | ||
| ); |
| onNewLinkSelection: overrides.onNewLinkSelection ?? (() => undefined), | ||
| onImagePasted: | ||
| overrides.onImagePasted ?? | ||
| ((() => | ||
| undefined) as unknown as EditorPluginsOptions['onImagePasted']), |
bc1e2e9 to
3e31c98
Compare
a66a4f3 to
34991c4
Compare
3e31c98 to
eedd1f9
Compare
34991c4 to
4867665
Compare
4867665 to
fd01f6d
Compare
6af6cc6 to
c499fb6
Compare
What
Adds 223 integration tests for the text editor's real stack, built on the
buildEditorSchema()/buildEditorPlugins()exports from #4139. Ten commits, one per surface — reviewable commit-by-commit:editor-test-harness.ts— shared helper: assembles the production schema + full ordered plugin list, mounts real views, types throughhandleTextInput, sends platform-aware key events. No bespoke framework, no vitest imports.active()/allowed()), factory keymap, link mark + URL paste, image node/inserter/cache, table nodes +fixTables.Why
The editor is used across the CRM; regressions in cross-plugin behavior (paste ordering, keymap precedence, trigger lifecycle, serialization losses) only surface when the real, full plugin set runs against the real schema. This suite pins those contracts — including deliberate characterization of quirks (e.g.
toggleMarkremoves on partially-marked ranges, lists serialize loose, exampleSetup shadows the factory'sMod-b).Where investigation found actual defects, no test pins the crashing path; those are filed as separate issues.
Notes for review
specvitest project runs in Stencil mock-doc, which lacks the selection API — anything needing a mountedEditorViewlives in*.e2e.tsfiles (the e2e project runs plain TS in Chromium).editor-config.spec.tsuntouched.Verification
npm run test:spec: 1018/1018, run twice (guards the module-globalimageCacheagainst cross-file pollution)🤖 Generated with Claude Code