Skip to content

test(text-editor): real-stack test suite for schema, plugins, commands, and converters#4163

Draft
john-traas wants to merge 14 commits into
text-editor-real-stack-testsfrom
text-editor-e2e-suite
Draft

test(text-editor): real-stack test suite for schema, plugins, commands, and converters#4163
john-traas wants to merge 14 commits into
text-editor-real-stack-testsfrom
text-editor-e2e-suite

Conversation

@john-traas

@john-traas john-traas commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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 through handleTextInput, sends platform-aware key events. No bespoke framework, no vitest imports.
  • spec project (state-level, 127 tests): schema contracts, all 12 menu commands (apply/active()/allowed()), factory keymap, link mark + URL paste, image node/inserter/cache, table nodes + fixTables.
  • e2e project (real Chromium, 96 tests): keymap through the plugin chain, all exampleSetup input rules + history, link plugin mouse events, image node views, cell selection, menu-state tracking + action-bar event bridge, the full trigger flow, and markdown/HTML round-trips with the loss matrix.

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. toggleMark removes on partially-marked ranges, lists serialize loose, exampleSetup shadows the factory's Mod-b).

Where investigation found actual defects, no test pins the crashing path; those are filed as separate issues.

Notes for review

  • The spec vitest project runs in Stencil mock-doc, which lacks the selection API — anything needing a mounted EditorView lives in *.e2e.ts files (the e2e project runs plain TS in Chromium).
  • Zero production-code changes; editor-config.spec.ts untouched.

Verification

  • npm run test:spec: 1018/1018, run twice (guards the module-global imageCache against cross-file pollution)
  • text-editor e2e: 114/114 in Chromium

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3195d6f5-d4d3-47c7-ad54-30079946f93a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch text-editor-e2e-suite

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-4163/

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-stack helper to build the production schema/plugins, create states, mount real EditorViews, 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.

Comment on lines +142 to +146
const handled = view.someProp('handleTextInput', (handler) =>
handler(view, from, to, char, () =>
view.state.tr.insertText(char, from, to)
)
);
Comment on lines +72 to +76
onNewLinkSelection: overrides.onNewLinkSelection ?? (() => undefined),
onImagePasted:
overrides.onImagePasted ??
((() =>
undefined) as unknown as EditorPluginsOptions['onImagePasted']),
@john-traas john-traas force-pushed the text-editor-real-stack-tests branch from bc1e2e9 to 3e31c98 Compare July 8, 2026 10:49
@john-traas john-traas force-pushed the text-editor-e2e-suite branch from a66a4f3 to 34991c4 Compare July 8, 2026 10:50
@john-traas john-traas force-pushed the text-editor-real-stack-tests branch from 3e31c98 to eedd1f9 Compare July 8, 2026 11:13
@john-traas john-traas force-pushed the text-editor-e2e-suite branch from 34991c4 to 4867665 Compare July 8, 2026 11:14
@john-traas john-traas self-assigned this Jul 9, 2026
@john-traas john-traas force-pushed the text-editor-e2e-suite branch from 4867665 to fd01f6d Compare July 9, 2026 07:46
@john-traas john-traas force-pushed the text-editor-real-stack-tests branch from 6af6cc6 to c499fb6 Compare July 9, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants