Skip to content

Re-enable and stabilize previously-disabled tests#3377

Merged
JiuqingSong merged 6 commits into
masterfrom
stabilize-disabled-tests
Jun 19, 2026
Merged

Re-enable and stabilize previously-disabled tests#3377
JiuqingSong merged 6 commits into
masterfrom
stabilize-disabled-tests

Conversation

@JiuqingSong

@JiuqingSong JiuqingSong commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

A number of unit tests were previously disabled (xit / xdescribe) because they were flaky or platform-dependent. This PR re-enables them and fixes the underlying causes so they pass deterministically regardless of OS, browser, and spec execution order.

Changes

roosterjs-content-model-core — paste

  • pasteTest.ts: Re-enabled the 'Second paste' test.

roosterjs-content-model-plugins — image edit

  • updateRotateHandleTest.ts: Re-enabled the rotate-handle positioning suite. The spy was attached to the wrong element (rotateHandle instead of rotateCenter), and the test geometry/expected values were corrected so the assertions reflect the actual layout math. These tests were previously marked "not consistent".
  • applyChangeTest.ts: Re-enabled the suite (was disabled because it "fails on Linux").
    • The contentModelImage was shared module-level state; applyChange persists/clears editingInfo on it, so a stale rotation/crop from a prior test could misclassify the next one. It is now recreated fresh in beforeEach.
    • canvas.toDataURL() output varies by browser/OS/Chrome version (compression, ancillary chunks), so exact base64 comparison wasn't portable — the original reason the tests were Linux-disabled. Assertions now verify the data URL is a PNG and compare the IHDR width/height, which is stable across encoders by the PNG spec. The one case where newSrc comes verbatim from the mocked event handler still uses exact comparison (documented inline).

roosterjs-content-model-plugins — table edit

  • tableEditorTest.ts: Re-enabled the disableFeatures suite. The editor div now gets a deterministic size with padding on every side, so the table is never flush against the scroll-container edge. Previously, whether the cell inserter was suppressed (isOutsideTop/isOutsideBottom) depended on leftover document.body layout from earlier specs, making the test order-dependent.
  • tableResizerTest.ts: Re-enabled the onDragging resize suite.
    • cmTable is now recreated in beforeEachonDragging mutates it in place, leaking resized widths/heights into later tests.
    • onDragging rewrites both width and height of every cell (switching to border-box), so resizing one axis incidentally shifts the other by the border width. The assertion now checks only the axis being resized (gated by growth sign) so small cross-axis shifts don't flip the expected direction.

roosterjs-editor-adapter — selection conversion

  • selectionConverterTest.ts: Re-enabled the 'image selection' test. createRange is re-exported through the roosterjs-editor-dom barrel via a getter, which webpack won't let us spy on. The test now uses a real <img> node and asserts on the resulting Range instead of mocking createRange.

Testing

  • yarn test:fast

Several test suites were disabled (xit/xdescribe) due to flakiness or
environment dependence. Re-enable them and fix the underlying issues so
they pass deterministically regardless of spec order:

- selectionConverterTest: spy on the deep createRange module did not
  intercept the barrel import; exercise the real createRange with a
  document-attached image instead.
- updateRotateHandleTest: the spy targeted rotateHandle while the code
  reads rotateCenter; point it at the right element and feed each
  "hidden" case the intended edge distance (and correct an impossible
  expected handle value).
- applyChangeTest: replace brittle exact PNG data-URL comparisons with
  IHDR-dimension checks (encoder-independent), and create a fresh
  contentModelImage per test to remove order-dependent editingInfo state.
- tableEditorTest: give the editor a deterministic size so the table is
  never flush against the scroll-container edge, which otherwise made
  inserter visibility depend on leftover document.body layout.
- tableResizerTest: recreate the content model table per test (onDragging
  mutates it in place) and gate verifyCellRectChange on growth only so an
  incidental cross-axis border-box shift does not flip the assertion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 18, 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-3377/

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

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

This PR re-enables previously disabled/flaky unit tests across multiple RoosterJS packages by removing order-dependent shared state, avoiding platform-dependent assertions (e.g., canvas/base64 output), and making layout/selection setup deterministic so results are consistent across OS/browser variations.

Changes:

  • Re-enabled multiple xit/xdescribe suites and addressed root flakiness causes (shared mutable models, viewport/layout dependence).
  • Updated image-edit tests to avoid non-portable canvas.toDataURL() byte-for-byte comparisons by asserting stable PNG IHDR dimensions instead.
  • Stabilized selection- and paste-related tests by relying on real DOM nodes / deterministic selection placement.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/roosterjs-editor-adapter/test/editor/utils/selectionConverterTest.ts Re-enables image-selection coverage by asserting against a real DOM <img> and the produced Range (avoids brittle spying).
packages/roosterjs-content-model-plugins/test/tableEdit/tableResizerTest.ts Re-enables resize dragging suite and removes cross-test state leakage by recreating the table model per test.
packages/roosterjs-content-model-plugins/test/tableEdit/tableEditorTest.ts Re-enables disableFeatures tests by enforcing deterministic editor sizing/padding to avoid order-dependent layout.
packages/roosterjs-content-model-plugins/test/paste/e2e/testUtils.ts Simplifies expectEqual to a strict model equality assertion after normalization (clone + JSON roundtrip).
packages/roosterjs-content-model-plugins/test/imageEdit/utils/applyChangeTest.ts Re-enables Linux-disabled suite by eliminating shared module state and replacing non-portable base64 comparisons with PNG-dimension checks.
packages/roosterjs-content-model-plugins/test/imageEdit/Rotator/updateRotateHandleTest.ts Re-enables rotate-handle positioning tests with corrected spying target and updated expected geometry.
packages/roosterjs-content-model-core/test/command/paste/pasteTest.ts Re-enables “Second paste” by setting a deterministic collapsed selection before reading the content model.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JiuqingSong JiuqingSong merged commit 62516e6 into master Jun 19, 2026
8 checks passed
@JiuqingSong JiuqingSong deleted the stabilize-disabled-tests branch June 19, 2026 17:14
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.

3 participants