Skip to content

Add unit tests to increase coverage for plugins and editor-adapter#3378

Open
JiuqingSong wants to merge 1 commit into
masterfrom
increase-test-coverage
Open

Add unit tests to increase coverage for plugins and editor-adapter#3378
JiuqingSong wants to merge 1 commit into
masterfrom
increase-test-coverage

Conversation

@JiuqingSong

@JiuqingSong JiuqingSong commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add unit tests to cover code paths that previously had no test coverage, with no production code changes. A full Istanbul coverage pass confirmed these files/branches were either untested or had zero-hit paths; the additions close those gaps.

  • roosterjs-content-model-plugins
    • ContextMenuPluginBase — new test file (was untested): event handling, container init/reuse, onDismiss, dispose.
    • TouchPlugin — new test file (was untested): pointerDown detection timer, word-boundary snapping, doubleClick punctuation/space/word selection, dispose.
    • CustomReplacePlugin — added guard-branch coverage and actually exercised the formatTextSegmentBeforeSelectionMarker callback (match vs no-match, canUndoByBackspace).
    • TableEditPlugin — added onMouseMove / ensureTableRects / defaultTableSelector coverage (rect hit/miss, caching, editor forwarding).
    • TableEditor — added editing-lifecycle handlers (onFinishEditing, onStart*, onEnd*, onAfterInsert, onBeforeEditTable), public isEditing/isOwnedElement/onSelect, getOnMouseOut, and RTL coverage.
  • roosterjs-editor-adapter
    • EditorAdapter — new "API coverage" describe block for the public surface (addDomEventHandler, selection getters, getContent, setZoomScale, node manipulation, custom data, dom attributes, undo state, content-edit features, runAsync, etc.).
    • buildRangeEx and insertNode utils — new test files (were untested), covering every input/branch.

How to test

  1. Run the affected test suites:
    yarn test:fast --testPathPattern="ContextMenuPluginBase|TouchPlugin|CustomReplacePlugin|tableEditPluginTest|tableEditorTest|EditorAdapterTest|buildRangeExTest|insertNodeTest"
    
    All tests should pass.
  2. Optionally verify the whole suite and lint are still green:
    yarn test:fast
    yarn eslint
    

These are test-only changes, so there is no runtime behavior to verify manually.

Before:
image

After:
image

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://microsoft.github.io/roosterjs/pr-preview/pr-3378/

Built to branch gh-pages at 2026-06-19 19:43 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Cover previously-untested code paths:
- ContextMenuPluginBase, TouchPlugin (new test files)
- CustomReplacePlugin guard branches and replacement callback
- TableEditPlugin onMouseMove/ensureTableRects/defaultTableSelector
- TableEditor editing lifecycle, public methods, getOnMouseOut, RTL
- EditorAdapter API surface (new describe block)
- buildRangeEx and insertNode utils (new test files)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JiuqingSong JiuqingSong force-pushed the increase-test-coverage branch from aaa12c1 to eeeeb6b Compare June 19, 2026 19:40
@JiuqingSong JiuqingSong marked this pull request as ready for review June 19, 2026 19:46
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.

1 participant