Fix tests that were not being run due to missing browser context#3340
Merged
BryanValverdeU merged 3 commits intoMay 12, 2026
Merged
Conversation
…ser cont…" This reverts commit 9aa472c.
juliaroldi
approved these changes
May 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Karma/browser-dependent test infrastructure and several paste/image-edit tests so they execute reliably again in a real browser context (and restores/adjusts some E2E paste coverage).
Changes:
- Adjusted Chrome-only test gating (
itChromeOnly) and updated multiple E2E/unit expectations to match browser-produced models/CSS rule serialization. - Extended Word paste E2E coverage with an additional Word clipboard fixture (
wordClipboardContent4) and a new E2E scenario. - Removed/avoided some test flakiness sources (e.g., clipboard write) and aligned test setup objects with required fields (e.g.,
globalCssRules).
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/roosterjs-content-model-plugins/test/paste/plugin/ContentModelPastePluginTest.ts | Adds missing globalCssRules field to the paste event setup used by plugin unit tests. |
| packages/roosterjs-content-model-plugins/test/paste/e2e/htmlTemplates/wordClipboardContent.ts | Adds a new Word clipboard fixture (wordClipboardContent4) for E2E coverage. |
| packages/roosterjs-content-model-plugins/test/paste/e2e/cmPasteTest.ts | Updates expected content model structures for paste E2E to match current output. |
| packages/roosterjs-content-model-plugins/test/paste/e2e/cmPasteFromWordTest.ts | Updates existing Word paste expectations, removes clipboard write, and adds a new E2E case (currently includes a blocking debugger). |
| packages/roosterjs-content-model-plugins/test/paste/e2e/cmPasteFromGoggleSheetsTest.ts | Updates expected table format to include legacy table attributes. |
| packages/roosterjs-content-model-plugins/test/paste/e2e/cmPasteFromExcelTest.ts | Updates expected Excel paste table/cell/segment formatting and legacy table attributes. |
| packages/roosterjs-content-model-plugins/test/imageEdit/utils/generateDataURLTest.ts | Makes generateDataURL tests deterministic by stubbing toDataURL and adjusting the error-case expectation. |
| packages/roosterjs-content-model-dom/test/testUtils.ts | Changes itChromeOnly implementation to use UA sniffing instead of __karma__ config. |
| packages/roosterjs-content-model-core/test/command/paste/retrieveHtmlInfoTest.ts | Updates expected CSS rule selector trimming and CSS text normalization; adds containsBlockElements expectation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const model = editor.getContentModelCopy('disconnected'); | ||
|
|
||
| expect(wordFile.processPastedContentFromWordDesktop).toHaveBeenCalled(); | ||
| debugger; |
| ) { | ||
| const func = __karma__.config.browser == 'Chrome' ? it : xit; | ||
| const ua = navigator.userAgent; | ||
| const isChrome = /Chrome\//.test(ua) && !/Edg\//.test(ua); |
Comment on lines
39
to
+44
| const image = document.createElement('img'); | ||
| image.width = 0; // Force error | ||
| image.height = 0; | ||
| image.src = 'https://th.bing.com/th/id/OIP.kJCCjl_yUweRlj94AdU-egHaFK?rs=1&pid=ImgDetMain'; | ||
| const url = generateDataURL(image, editInfo); | ||
| expect(url).toBe( | ||
| 'https://th.bing.com/th/id/OIP.kJCCjl_yUweRlj94AdU-egHaFK?rs=1&pid=ImgDetMain' | ||
| ); | ||
| expect(url).toBe('data:,'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-add tests not being executed and fix the coverage github action, confirmed it is working here: https://github.com/microsoft/roosterjs/actions/runs/25738247389/job/75581074727?pr=3340