test(frontend): cover the debugger's breakpoint gutter - #7425
test(frontend): cover the debugger's breakpoint gutter#7425aglinxinyuan wants to merge 1 commit into
Conversation
setupMonacoBreakpointMethods was the component's one uncovered block. The existing suite stubs it out because the minimal editor mock cannot back a real MonacoBreakpoint, so neither of the two overrides it installs was exercised. Adds 13 tests over both. The glyph override: a plain breakpoint, one carrying a condition, a whitespace-only condition that must not claim to be conditional, a hovered line, and the condition being looked up on the line the glyph starts at rather than where its range ends. The mouse-down override: the library's own handler is disposed before the replacement registers, since two live handlers would add and immediately remove a breakpoint on one click; a left click toggles; a right click opens the condition input instead of toggling, and only for a line that has a breakpoint; clicks below the last line and outside the gutter do nothing. The stand-in editor answers any unstubbed on* listener with an inert disposable, so it does not have to track which events monaco-breakpoints subscribes to. No production file is touched.
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7425 +/- ##
============================================
+ Coverage 85.00% 85.15% +0.15%
Complexity 4148 4148
============================================
Files 1169 1169
Lines 46740 46740
Branches 5202 5202
============================================
+ Hits 39731 39802 +71
+ Misses 5289 5219 -70
+ Partials 1720 1719 -1
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds dedicated unit coverage for CodeDebuggerComponent.setupMonacoBreakpointMethods, specifically the breakpoint gutter glyph rendering and gutter mouse interactions, without modifying production code.
Changes:
- Introduces a new test suite that drives the
MonacoBreakpointdecoration override to validate glyph class selection (plain/conditional/hover). - Adds tests for the overridden gutter mouse-down handler to validate left-click toggle vs right-click condition input behavior and guard conditions.
- Implements a proxy-based stand-in Monaco editor to avoid brittle stubbing of all
monaco-breakpointsevent subscriptions.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const fake = makeEditor(); | ||
| editor = fake.editor; | ||
| component.monacoEditor = editor; | ||
| component.setupMonacoBreakpointMethods(editor); | ||
| }); |
|
|
||
| expect(component.breakpointConditionLine).not.toBe(12); | ||
| }); |
What changes were proposed in this PR?
setupMonacoBreakpointMethodswas the component's one uncovered block. The existing suite stubs it out — with a comment saying so — because the minimal editor mock cannot back a realMonacoBreakpoint, so neither of the two overrides it installs was exercised.Adds 13 tests over both.
The glyph override decides what the gutter shows:
Covered including the
Boolean(condition?.trim())guard — a condition left as whitespace must render as an ordinary breakpoint rather than claiming a condition the debugger will not apply — and the lookup happening atrange.startLineNumber, since readingendLineNumberwould attribute another line's condition to this glyph.The mouse-down override replaces the library's own handler. The
dispose()before re-registering is load-bearing: two live handlers would add and immediately remove a breakpoint on a single click. A left click toggles; a right click opens the condition input instead of toggling, and only for a line that already has a breakpoint; clicks below the last line and outside the gutter do nothing.Verified by mutation, all reverted (production diff empty):
The stand-in editor is a
Proxythat answers any unstubbedon*listener with an inert disposable, so the spec does not have to track which eventsmonaco-breakpointssubscribes to — the first attempt failed ononDidChangeCursorPosition, and guessing at the rest would have been fragile.No production file is touched.
Any related issues, documentation, discussions?
Closes #7422
How was this PR tested?
13 new on top of the existing 16.
yarn format:cipasses.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)