Repository navigation
test(frontend): cover the codearea template and breakpoint popup placement - #7304
Conversation
…ement Two workspace editor sub-components whose specs stopped at "should create" or at the keyboard paths. CodeareaCustomTemplateComponent had a single creation test. Its actual job is keeping one shared, per-operator "is the editor open" flag in sync across three inputs -- this component opening or closing the editor, a co-editor opening the same one remotely, and the component being torn down while the editor is still up. The flag lives in CodeEditorService keyed by operator id, so a mix-up there silently reopens the wrong operator's editor. Five tests cover that, including that ngOnDestroy persists the current flag rather than a hardcoded false, and that the created editor is handed this field's form control rather than a fresh one. The co-editor test stubs getCoeditorOpenedCodeEditorSubject and builds its own fixture, because the component subscribes in its constructor and the getter returns asObservable() -- casting the result back to a Subject would only work by accident of the current implementation. BreakpointConditionInputComponent's popup has no layout of its own; it is positioned by arithmetic over Monaco's reported geometry, and none of left(), top(), isVisible or the css offsets written by ngOnChanges were tested. The existing stub supplies distinguishable non-zero values, so every new expectation is a specific number (-120px, 55px) rather than a zero that jsdom would produce anyway. Also covers both no-editor and no-line guards, the horizontal scroll offset that only left() reads, and a keypress arriving with no line targeted. code-debugger.component.ts was left alone: its spec already has 16 tests covering the decoration and status-change handlers, and the residue looked like it would need padding rather than real assertions.
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
This PR increases frontend unit test coverage for two workspace editor sub-components whose specs previously stopped early, focusing on editor-open state synchronization and breakpoint condition popup placement logic. No production code is modified.
Changes:
- Expanded
CodeareaCustomTemplateComponentspec to cover open/close lifecycle, co-editor-triggered opens, and persistence behavior across destroy/re-init. - Expanded
BreakpointConditionInputComponentspec to cover popup placement arithmetic (left/top),ngOnChanges-driven CSS offsets, and visibility/guard behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/app/workspace/component/codearea-custom-template/codearea-custom-template.component.spec.ts | Adds tests around shared editor-open state behavior, including co-editor and lifecycle interactions. |
| frontend/src/app/workspace/component/code-editor-dialog/breakpoint-condition-input/breakpoint-condition-input.component.spec.ts | Adds tests for breakpoint condition popup placement math, CSS position updates, visibility, and guard paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7304 +/- ##
============================================
+ Coverage 82.72% 82.93% +0.20%
Complexity 4087 4087
============================================
Files 1162 1165 +3
Lines 46302 46384 +82
Branches 5162 5170 +8
============================================
+ Hits 38305 38470 +165
+ Misses 6303 6216 -87
- Partials 1694 1698 +4
*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
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
frontend/src/app/workspace/component/codearea-custom-template/codearea-custom-template.component.spec.ts:105
subscribe(...)inside tests without an unsubscribe can leak subscriptions across specs and can also become timing-sensitive ifgetEditorState()ever emits asynchronously. Prefer reading a single value viafirstValueFrom(...)ortake(1)(and awaiting it if needed) so the test is both self-contained and resilient to implementation changes.
let published: boolean | undefined;
codeEditorService.getEditorState(highlightedOperatorId()).subscribe(v => (published = v));
expect(published).toBe(true);
frontend/src/app/workspace/component/codearea-custom-template/codearea-custom-template.component.spec.ts:131
- This test creates an additional fixture and installs a spy, but neither is explicitly cleaned up. To avoid cross-test pollution (especially if the suite doesn’t globally restore mocks/fixtures), destroy
remoteFixtureat the end of the test and restore the spy (mockRestore()), ideally using atry/finally.
vi.spyOn(TestBed.inject(CoeditorPresenceService), "getCoeditorOpenedCodeEditorSubject").mockReturnValue(
opened.asObservable()
);
const remoteFixture = TestBed.createComponent(CodeareaCustomTemplateComponent);
const remoteComponent = remoteFixture.componentInstance;
remoteComponent.field = { props: {}, formControl: new FormControl() } as any;
remoteFixture.detectChanges();
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Xinyuan Lin <xinyual3@uci.edu>
…9113) ### What changes were proposed in this PR? Removes `BreakpointConditionInputComponent.left()` and `top()`, two positioning methods that nothing in production calls. **−66 lines.** There is no behaviour change. The popup is positioned by `ngOnChanges`, which computes `topPosition` and `leftPosition` for the template's `[ngStyle]="{ top: topPosition, left: leftPosition }"` binding. The template never calls `left()` or `top()`. The component's one host, `code-debugger`, binds only its inputs and output, and the two parent `ViewChild` fields that reference the component are never read. Every import is still used. The spec loses the five cases that only exercised the two methods. Its coverage of the surviving positioning (`ngOnChanges`, `topPosition`, `leftPosition`) stays. ### History | | | | --- | --- | | **Introduced by** | apache#2953 (2024-10-25), "Add Udon breakpoint UI - breakpoint-related operations", in the same commit as the `[ngStyle]` positioning that is actually used | | **Usage removed by** | **never used**. Only spec cases (apache#7304, apache#7988) ever called them | They have been unused for the two years since they were added. ### Any related issues, documentation, discussions? Closes apache#9110 ### How was this PR tested? No new tests. The surviving positioning keeps its cases. From `frontend/`: - `npx ng test --watch=false --include='**/breakpoint-condition-input.component.spec.ts' --include='**/code-debugger.component.spec.ts' --include='**/code-editor.component.spec.ts'`: 3 files, 126 tests, all pass. The last two specs cover the component's host and the code editor that declares it. - `npx tsc --noEmit -p src/tsconfig.app.json` and `-p src/tsconfig.spec.json`: clean. - `yarn format:ci`: clean. - `npx ng build`: success. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
What changes were proposed in this PR?
Two workspace editor sub-components whose specs stopped early.
codearea-custom-templatebreakpoint-condition-inputCodeareaCustomTemplateComponenthad a single creation test. Its actual job is keeping one shared, per-operator "is the editor open" flag in sync across three inputs — this component opening or closing the editor, a co-editor opening the same one remotely, and the component being torn down while the editor is still up. The flag lives inCodeEditorServicekeyed by operator id, so a mix-up there silently reopens the wrong operator's editor.Also pinned:
ngOnDestroypersists the current flag rather than a hardcoded false (so a component torn down with its editor up comes back open), and the created editor is handed this field's form control rather than a fresh one — otherwise the dialog opens detached from the property it is meant to edit.The co-editor test stubs
getCoeditorOpenedCodeEditorSubjectand builds its own fixture, because the component subscribes in its constructor and that getter returnsasObservable(). Casting the result back to aSubjectwould only work by accident of the current implementation — the same trap that came up in review on the mini-map spec.BreakpointConditionInputComponent's popup has no layout of its own; it is positioned by arithmetic over Monaco's reported geometry, and none ofleft(),top(),isVisibleor the css offsets written byngOnChangeswas tested. The existing stub supplies distinguishable non-zero values, so every new expectation is a specific number —— rather than a zero that jsdom would produce anyway. Also covers both the no-editor and no-line guards, and the horizontal scroll offset that only
left()reads (so a copy-paste oftop()'s body would be caught).code-debugger.component.ts(20 missed) is deliberately out of scope: its spec already has 16 tests covering the decoration and status-change handlers, and the residue looked like it would need padding rather than real assertions. Said plainly rather than quietly skipped.No production file is touched.
Any related issues, documentation, discussions?
Closes #7301
How was this PR tested?
yarn format:cipasses (prettier-eslint + eslint), which Vitest does not cover on its own — it flagged both files on the first attempt.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)