You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/08/01 08:17:39 UTC
[PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
aglinxinyuan opened a new pull request, #7241:
URL: https://github.com/apache/texera/pull/7241
### What changes were proposed in this PR?
Three existing specs under `frontend/src/app/workspace/`, extended to cover what their subjects had left untested:
| File | Before | Tests now |
|---|---|---|
| `mini-map.component.ts` | 42.9% | 16 |
| `preset.service.ts` | 81.0% | 55 |
| `jupyter-panel.service.ts` | 82.2% | 41 |
Two of these have traps that make a naive extension pass for the wrong reason, which is most of why they were left half-covered:
**jsdom has no layout.** `src/jsdom-svg-polyfill.ts` stubs `getScreenCTM`/`getCTM` to an identity matrix and `getBBox` to a zero rect, and `offsetWidth`/`offsetHeight` are 0. So `ngAfterViewInit` computes `scale = 0`, and a geometry assertion reads `"0px"` — true because there is no layout, not because the formula is right. The mini-map specs use a stub paper with explicit, mutually distinguishable geometry plus `Object.defineProperty`'d offset dimensions, and every expected value is a non-zero literal (`200px`, `100px`, `37.5px`, `matrix(0.25,0,0,0.25,240,135)`), so a regression back to zero-layout fails.
**`catchError` swallows the difference between two branches.** `fetchNotebookAndMapping` wraps its `switchMap` in `catchError(() => of(0))`. The base mock has no `sendNotebookToJupyter`, so flushing `{exists:true}` without defining it throws a `TypeError` that becomes `0` — indistinguishable from the send-failed branch under test. Every spec on that path defines the mock explicitly *and* asserts it was called; the reject case additionally asserts `console.error` was not called, which is what separates it from the `catchError` path.
Also handled: Angular's automatic fixture teardown fires `ngOnDestroy` after every test, which writes `localStorage["mini-map"]`. The key is cleared before `TestBed.createComponent` and again in `afterEach`, so ordering cannot decide a result.
Two things deliberately left uncovered, with the reasoning in the files:
- `updatePreset`'s splice/replace branches. The method has **no production caller** and carries a real bug — lodash `indexOf` against a list that was just `JSON.parse`'d always returns `-1`, so `splice(-1, 1)` deletes the *last* preset instead of the intended one, and `presets[-1] = replacement` writes a non-index property that `JSON.stringify` silently drops. Its sibling `updateOrCreatePreset` already uses the correct `findIndex(p => isEqual(p, original))`. Testing it would cement the bug; it wants a separate fix-or-delete.
- The two `no default save preset info/warning message` throws — pinning them would assert a limitation that adding a default message would fix.
Assertion strength was checked by mutation and every mutation reverted; the production diff is empty.
### Any related issues, documentation, discussions?
Closes #7238
### How was this PR tested?
```
npx ng test --watch=false --include="**/mini-map.component.spec.ts" --include="**/jupyter-panel.service.spec.ts" --include="**/preset.service.spec.ts"
```
```
✓ src/app/workspace/service/jupyter-panel/jupyter-panel.service.spec.ts (41 tests)
✓ src/app/workspace/service/preset/preset.service.spec.ts (55 tests)
✓ src/app/workspace/component/workflow-editor/mini-map/mini-map.component.spec.ts (16 tests)
Test Files 3 passed (3)
```
`yarn format:ci` passes (prettier-eslint + eslint), which Vitest does not cover on its own.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 merged PR #7241:
URL: https://github.com/apache/texera/pull/7241
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #7241:
URL: https://github.com/apache/texera/pull/7241#issuecomment-5150608414
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/7241?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 81.18%. Comparing base ([`18ebb0d`](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2b55262`](https://app.codecov.io/gh/apache/texera/commit/2b55262f956308d8d8d2c8286b7d31b09f12267c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 4 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #7241 +/- ##
============================================
+ Coverage 81.04% 81.18% +0.13%
Complexity 3968 3968
============================================
Files 1162 1162
Lines 46259 46259
Branches 5153 5153
============================================
+ Hits 37490 37554 +64
+ Misses 7096 7049 -47
+ Partials 1673 1656 -17
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
|---|---|---|---|
| [access-control-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [agent-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.49% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [amber](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.66% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `20.49% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [config-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `65.97% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [file-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.80% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [frontend](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.54% <ø> (+0.31%)` | :arrow_up: | |
| [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.89% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [pyamber](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `97.36% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/7241/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `26.31% <ø> (ø)` | | Carriedforward from [18ebb0d](https://app.codecov.io/gh/apache/texera/commit/18ebb0d1e6dded6f8bc04b7c52be4fa31cb27916?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
*This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/7241?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #7241:
URL: https://github.com/apache/texera/pull/7241#discussion_r3695217094
##########
frontend/src/app/workspace/component/workflow-editor/mini-map/mini-map.component.spec.ts:
##########
@@ -49,13 +130,276 @@ describe("MiniMapComponent", () => {
}).compileComponents();
});
+ // The fixture is created but NOT change-detected here: ngAfterViewInit reads
+ // the mini-map container's size and the persisted flag, so each test sets its
+ // own environment up before triggering it.
beforeEach(() => {
fixture = TestBed.createComponent(MiniMapComponent);
- TestBed.inject(WorkflowActionService);
- fixture.detectChanges();
+ component = fixture.componentInstance;
+ workflowActionService = TestBed.inject(WorkflowActionService);
+ panelService = TestBed.inject(PanelService);
});
+ /** Gives the mini-map container a size, which jsdom otherwise reports as 0. */
+ function sizeMiniMapContainer(width: number, height: number): HTMLElement {
+ const map = fixture.nativeElement.querySelector("#mini-map") as HTMLElement;
+ Object.defineProperty(map, "offsetWidth", { value: width, configurable: true });
+ Object.defineProperty(map, "offsetHeight", { value: height, configurable: true });
+ return map;
+ }
+
+ /**
+ * The mini-map reads the main editor's element out of the document by id, so
+ * mount a stand-in with an explicit size and viewport rect.
+ */
+ function mountWorkflowEditorStub(width: number, height: number, left: number, top: number): HTMLDivElement {
+ const editor = document.createElement("div");
+ editor.id = "workflow-editor";
+ Object.defineProperty(editor, "offsetWidth", { value: width, configurable: true });
+ Object.defineProperty(editor, "offsetHeight", { value: height, configurable: true });
+ editor.getBoundingClientRect = () => ({ left, top, right: left + width, bottom: top + height }) as DOMRect;
+ document.body.appendChild(editor);
+ editorStub = editor;
+ return editor;
+ }
+
+ /** Publishes `paper` on the stream the mini-map subscribes to in ngAfterViewInit. */
+ function attachMainPaper(paper: StubPaper): void {
+ (workflowActionService.getJointGraphWrapper().getMainJointPaperAttachedStream() as Subject<joint.dia.Paper>).next(
+ paper as unknown as joint.dia.Paper
+ );
Review Comment:
Agreed — fixed in ee52720fca, using the `vi.spyOn(...).mockReturnValue(...)` approach you suggested.
The suite now owns a `ReplaySubject<joint.dia.Paper>(1)` and stubs the getter to return `mainPaper$.asObservable()`, so it depends only on the declared `Observable<Paper>` type. `attachMainPaper` pushes through the subject it owns.
Confirmed the concern is real rather than theoretical: `getMainJointPaperAttachedStream()` is declared `Observable<joint.dia.Paper>` (joint-graph-wrapper.ts:213) and just returns the backing field, so the cast worked purely by implementation accident. Switching it to `.asObservable()` would have made `.next()` undefined at runtime — a silent break, since the cast type-checks either way.
`ReplaySubject(1)` rather than a plain `Subject` so a paper attached before the component subscribes in `ngAfterViewInit` is still delivered. All 16 tests still pass.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7241:
URL: https://github.com/apache/texera/pull/7241#discussion_r3695197797
##########
frontend/src/app/workspace/component/workflow-editor/mini-map/mini-map.component.spec.ts:
##########
@@ -49,13 +130,276 @@ describe("MiniMapComponent", () => {
}).compileComponents();
});
+ // The fixture is created but NOT change-detected here: ngAfterViewInit reads
+ // the mini-map container's size and the persisted flag, so each test sets its
+ // own environment up before triggering it.
beforeEach(() => {
fixture = TestBed.createComponent(MiniMapComponent);
- TestBed.inject(WorkflowActionService);
- fixture.detectChanges();
+ component = fixture.componentInstance;
+ workflowActionService = TestBed.inject(WorkflowActionService);
+ panelService = TestBed.inject(PanelService);
});
+ /** Gives the mini-map container a size, which jsdom otherwise reports as 0. */
+ function sizeMiniMapContainer(width: number, height: number): HTMLElement {
+ const map = fixture.nativeElement.querySelector("#mini-map") as HTMLElement;
+ Object.defineProperty(map, "offsetWidth", { value: width, configurable: true });
+ Object.defineProperty(map, "offsetHeight", { value: height, configurable: true });
+ return map;
+ }
+
+ /**
+ * The mini-map reads the main editor's element out of the document by id, so
+ * mount a stand-in with an explicit size and viewport rect.
+ */
+ function mountWorkflowEditorStub(width: number, height: number, left: number, top: number): HTMLDivElement {
+ const editor = document.createElement("div");
+ editor.id = "workflow-editor";
+ Object.defineProperty(editor, "offsetWidth", { value: width, configurable: true });
+ Object.defineProperty(editor, "offsetHeight", { value: height, configurable: true });
+ editor.getBoundingClientRect = () => ({ left, top, right: left + width, bottom: top + height }) as DOMRect;
+ document.body.appendChild(editor);
+ editorStub = editor;
+ return editor;
+ }
+
+ /** Publishes `paper` on the stream the mini-map subscribes to in ngAfterViewInit. */
+ function attachMainPaper(paper: StubPaper): void {
+ (workflowActionService.getJointGraphWrapper().getMainJointPaperAttachedStream() as Subject<joint.dia.Paper>).next(
+ paper as unknown as joint.dia.Paper
+ );
Review Comment:
`attachMainPaper` is calling `.next()` by casting the return of `getMainJointPaperAttachedStream()` (declared as `Observable<Paper>`) to a `Subject`. This couples the spec to `JointGraphWrapper`'s current implementation detail (a `ReplaySubject`), and will fail (or silently stop emitting) if the wrapper is ever changed to return `asObservable()`.
Consider stubbing the stream via `vi.spyOn(jointGraphWrapper, "getMainJointPaperAttachedStream").mockReturnValue(mainPaper$.asObservable())` and emitting through `mainPaper$`, or exposing a test helper API for attaching a paper.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(frontend): extend workspace mini-map, jupyter-panel and preset specs [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #7241:
URL: https://github.com/apache/texera/pull/7241#issuecomment-5150586191
<!-- texera-reviewer-suggestion -->
### Automated Reviewer Suggestions
Based on the `git blame` history of the changed files, we recommend the following reviewers:
- **Contributors with relevant context:** `@Yicong-Huang`, `@zyratlo`, `@Ma77Ball`
You can notify them by mentioning `@Yicong-Huang`, `@zyratlo`, `@Ma77Ball` in a comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org