mengw15 opened a new pull request, #7797: URL: https://github.com/apache/texera/pull/7797
### What changes were proposed in this PR? `PresetService.updatePreset` located the preset to replace with lodash `indexOf`, which compares by reference. The list it searches comes straight out of `JSON.parse`, so the lookup always returned `-1` while the `contains` guard above it — which compares with `isEqual` — still let execution through. Both arms then did the wrong thing: - `presets[-1] = replacementPreset` writes a non-index property on the array, so the edit was silently discarded and the unchanged list written back. - `presets.splice(-1, 1)` removes the **last** element, so replacing a preset with one that already existed deleted the wrong preset. The sibling `updateOrCreatePreset` directly below already used a deep-equality `findIndex`, with a comment naming this cause; this applies the same lookup to `updatePreset`. `indexOf` is no longer used in the file, so the import drops with it. Three tests come with it — the two that reproduce the defect (an in-place replace, and a replace onto an existing preset), plus the absent-entry case that reaches the `?? "[]"` default. They fail against the old code with exactly the wrong values described above. ### Any related issues, documentation, discussions? Closes #7795 Both lines were unhit, which is how this went unnoticed; they are among the gaps listed in #7777, so that issue's `PresetService` portion is handled here. ### How was this PR tested? Unit tests, run locally in `frontend/`: ``` ng test --watch=false --include .../preset.service.spec.ts # Test Files 1 passed (1) | Tests 61 passed (61) prettier --write / eslint # clean ``` The failure path was verified by reverting the production change and re-running: the run exits non-zero with `2 failed | 59 passed`, the in-place replace writing back the unchanged list and the merge case deleting `v2` instead of `v1`. The coverage report over this spec now shows no unhit line and no partial branch in `preset.service.ts`. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.8 [1M context]) -- 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]
