Skip to content

test(frontend): cover the codearea template and breakpoint popup placement - #7304

Merged
aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:test-code-editor-fe
Aug 5, 2026
Merged

aglinxinyuan merged 2 commits into
apache:mainfrom
aglinxinyuan:test-code-editor-fe

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Two workspace editor sub-components whose specs stopped early.

Component Before Tests now
codearea-custom-template 64.5%, one "should create" test 6
breakpoint-condition-input 63.9%, condition + keyboard paths 13

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.

Also pinned: ngOnDestroy persists 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 getCoeditorOpenedCodeEditorSubject and builds its own fixture, because the component subscribes in its constructor and that getter returns asObservable(). Casting the result back to a Subject would 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 of left(), top(), isVisible or the css offsets written by ngOnChanges was tested. The existing stub supplies distinguishable non-zero values, so every new expectation is a specific number —

left() = 30 (rect.left) + 10 (glyphMarginLeft) - 0 (scrollLeft) - 160 (popup width) = -120
top()  = 20 (rect.top)  + 40 (line bottom)    - 5 (scrollTop)                       =   55

— 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 of top()'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?

npx ng test --watch=false --include="**/codearea-custom-template.component.spec.ts" --include="**/breakpoint-condition-input.component.spec.ts"
 ✓ .../breakpoint-condition-input.component.spec.ts (13 tests)
 ✓ .../codearea-custom-template.component.spec.ts (6 tests)
 Test Files  2 passed (2)

yarn format:ci passes (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)

…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.
Copilot AI lite review requested due to automatic review settings August 4, 2026 05:21
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Ma77Ball, @Yicong-Huang
    You can notify them by mentioning @Ma77Ball, @Yicong-Huang in a comment.

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 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 CodeareaCustomTemplateComponent spec to cover open/close lifecycle, co-editor-triggered opens, and persistence behavior across destroy/re-init.
  • Expanded BreakpointConditionInputComponent spec 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-commenter

codecov-commenter commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.93%. Comparing base (608a5e8) to head (e0aa041).
⚠️ Report is 23 commits behind head on main.

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     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from f5281ae
agent-service 83.65% <ø> (ø) Carriedforward from f5281ae
amber 79.51% <ø> (ø) Carriedforward from f5281ae
computing-unit-managing-service 43.60% <ø> (ø) Carriedforward from f5281ae
config-service 65.97% <ø> (ø) Carriedforward from f5281ae
file-service 67.74% <ø> (ø) Carriedforward from f5281ae
frontend 84.03% <ø> (+0.47%) ⬆️
notebook-migration-service 78.89% <ø> (ø) Carriedforward from f5281ae
pyamber 97.36% <ø> (ø) Carriedforward from f5281ae
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from f5281ae

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aglinxinyuan
aglinxinyuan requested a review from mengw15 August 4, 2026 05:32
@mengw15
mengw15 requested a lite review from Copilot August 4, 2026 09:44

@mengw15 mengw15 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.

LGTM

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

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 if getEditorState() ever emits asynchronously. Prefer reading a single value via firstValueFrom(...) or take(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 remoteFixture at the end of the test and restore the spy (mockRestore()), ideally using a try/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>
@aglinxinyuan
aglinxinyuan enabled auto-merge August 5, 2026 00:33
@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 5, 2026
Merged via the queue into apache:main with commit cd28761 Aug 5, 2026
22 checks passed
@aglinxinyuan
aglinxinyuan deleted the test-code-editor-fe branch August 5, 2026 00:58
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Oct 25, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend the codearea template and breakpoint popup specs

4 participants