aglinxinyuan opened a new issue, #6256:
URL: https://github.com/apache/texera/issues/6256

   ### Task Summary
   
   Add `array-utils.spec.ts` covering `replaceOneImmutable`, which returns a 
new array with the first predicate-matching element replaced and leaves the 
original untouched.
   
   ## Background
   
   `frontend/src/app/common/util/array-utils.ts` exports one generic immutable 
helper and has no test. Its immutability / no-op contract is exactly the kind 
of thing a regression can silently break.
   
   ```ts
   export function replaceOneImmutable<T>(
     arr: ReadonlyArray<T>,
     predicate: (t: T, idx: number) => boolean,
     item: T
   ): ReadonlyArray<T> {
     const idx = arr.findIndex(predicate);
     if (idx < 0) return arr;
     const next = arr.slice();
     (next as T[])[idx] = item;
     return next;
   }
   ```
   
   ## Behavior to pin
   
   | Scenario | Contract |
   | --- | --- |
   | predicate matches | replaces the element at the first matching index and 
returns a **new** array reference |
   | source untouched | the input array is not mutated |
   | no match | returns the **same** array reference (identity), unchanged |
   | predicate arg | receives the element index as its second argument |
   
   Follow `size-formatter.util.spec.ts` in `common/util/` as the style template 
(plain `describe`/`it`/`expect`, run with `ng test`).
   
   ## Scope
   
   - New spec: `frontend/src/app/common/util/array-utils.spec.ts`.
   - No production-code changes.
   
   ### Task Type
   
   - [ ] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [x] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other
   


-- 
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