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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to