test(frontend): browser-mode spec for code-editor.component#5241
test(frontend): browser-mode spec for code-editor.component#5241Ma77Ball wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5241 +/- ##
============================================
- Coverage 48.72% 48.57% -0.16%
- Complexity 2375 2379 +4
============================================
Files 1044 1042 -2
Lines 40096 39971 -125
Branches 4252 4252
============================================
- Hits 19538 19415 -123
+ Misses 19411 19410 -1
+ Partials 1147 1146 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/request-review @aglinxinyuan |
There was a problem hiding this comment.
Pull request overview
Adds browser-mode frontend coverage for CodeEditorComponent paths that require Monaco/browser APIs, while routing .browser.spec.ts files to the existing Chromium-based Vitest target.
Changes:
- Adds
code-editor.component.browser.spec.tscovering Monaco initialization, diff config, AI actions, type annotation positioning, and resize layout. - Adds a browser
Buffer/processsetup shim and wires it intovitest.browser.config.ts. - Updates Angular test target globs so browser specs run only in
gui:test-browser.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
frontend/src/app/workspace/component/code-editor-dialog/code-editor.component.browser.spec.ts |
Adds browser-mode component tests for Monaco-bound behavior. |
frontend/src/browser-buffer-polyfill.ts |
Adds global browser shims needed by Monaco-related packages in browser tests. |
frontend/vitest.browser.config.ts |
Registers the buffer setup file first and pre-bundles buffer. |
frontend/angular.json |
Routes *.browser.spec.ts files to the browser test target and excludes them from jsdom tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // exposes neither a `Buffer` named export nor a `default` export at | ||
| // module-eval time. The namespace object always has the optimizer-injected | ||
| // shape, so we read `Buffer` off it dynamically. | ||
| import * as bufferModule from "buffer"; |
There was a problem hiding this comment.
I also have this concern. In addition, why do we need to have a polyfill file for buffer?
| // for a fake-with-real-DOM and running in vitest's Playwright/Chromium | ||
| // browser mode, where monaco-editor's codingame fork can be imported without | ||
| // jsdom's missing-canvas / Node-Buffer-allocation tripwires (see the | ||
| // nodePolyfills entry in vitest.browser.config.ts). |
| // exposes neither a `Buffer` named export nor a `default` export at | ||
| // module-eval time. The namespace object always has the optimizer-injected | ||
| // shape, so we read `Buffer` off it dynamically. | ||
| import * as bufferModule from "buffer"; |
There was a problem hiding this comment.
I also have this concern. In addition, why do we need to have a polyfill file for buffer?
| // (`addAction`, `updateOptions`, `layout`). The component does not introspect | ||
| // any of these beyond truthiness, so the stub does not need to be a real | ||
| // IStandaloneCodeEditor — TypeScript's structural check is the only gate. | ||
| interface FakeEditor { |
There was a problem hiding this comment.
why are we testing a fake editor?
What changes were proposed in this PR?
Any related issues, documentation, or discussions?
Closes: #5192
How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?
Co-authored with Claude Opus 4.7 in compliance with ASF