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

   ### Task Summary
   
   Three workspace files are at 95–98 % line coverage but still carry **22 
half-taken branches and one unreached line** between them. Every one is an 
ordinary data-driven conditional — a `??` fallback whose left side is never 
null, an `if` whose else never runs, an `else if` never entered — so each is 
one input value away from being covered. Goal: take the missing arm of each 
branch and bring the three files toward complete branch coverage.
   
   Vitest/jsdom; see `frontend/TESTING.md` and `frontend/AGENTS.md`. Use the 
local coverage report to confirm each arm actually flipped — the lines below 
are where the report points today, not a fence.
   
   ### Behavior to add
   
   **HuggingFaceComponent** 
(`frontend/src/app/workspace/component/hugging-face/hugging-face.component.ts`, 
codecov 97.55 %, 7 half-taken branches — EXTEND)
   
   - `ngOnInit` (181) and `onTaskSelected` (291) — both read 
`this.getCurrentTaskTag() ?? this.selectedTaskTag`, and the fallback side never 
runs. Add a case where `getCurrentTaskTag()` returns null/undefined so 
`selectedTaskTag` is used.
   - `ngOnDestroy` (198) — `if (this.initTimeout !== null)`. Only one side is 
taken; destroy the component both after a pending init timeout exists and after 
it has already been cleared. Do **not** reach for `vi.useFakeTimers()` just to 
stop the timer from firing: a synchronous test body cannot let it run anyway, 
and layering fake timers over zone.js's patched `setTimeout` has produced 
Node-version-dependent failures. Set the field, call `ngOnDestroy`, assert with 
`vi.spyOn(globalThis, "clearTimeout")`, and clear any real handle in a 
`finally`.
   - `loadTasks` (235) — the `} else if (tasksFetchSubscription === null)` arm. 
Drive a second load while no fetch is in flight.
   - `loadAllModels` (347) — the `} else if (!inFlightByTag.has(tag))` arm. 
Call it for a tag that has no in-flight request.
   - `restoreTaskState` (610) — the 
`Object.prototype.hasOwnProperty.call(snapshot, key)` guard. Pass a snapshot 
missing one of the keys being restored.
   - `resetTaskStateForFirstVisit` (636) — `defaults[key] ?? ""`. Supply a 
defaults map with a missing/undefined entry so the empty-string fallback is 
written.
   
   **WorkflowActionService** 
(`frontend/src/app/workspace/service/workflow-graph/model/workflow-action.service.ts`,
 codecov 97.68 %, 7 half-taken branches — EXTEND)
   
   - `addOperatorsAndLinks` (319) — `if (links)`. Call it once without the 
optional `links` argument.
   - `autoLayoutWorkflow` (372, 379) — both guards compare 
`sharedModel.elementPositionMap.get(id)` against the newly computed position. 
Only the "changed" side runs; lay out a graph where an operator and a comment 
box are already at the position the layout produces, so the equal branch is 
taken too.
   - `calculateTopLeftOperatorPosition` (403, 406) — `if (position.x < minX)` 
and `if (position.y < minY)`. Feed at least two operators ordered so each 
comparison is false once and true once.
   - `setTempWorkflow` (781) — `if 
(this.texeraGraph.sharedModel.wsProvider.shouldConnect)`. Exercise it with 
`shouldConnect` both true and false.
   - `handleJointElementDrag` (872) — a multi-clause condition where at least 
one clause never flips; cover the combination that is currently missing.
   
   **SharedModelChangeHandler** 
(`frontend/src/app/workspace/service/workflow-graph/model/shared-model-change-handler.ts`,
 codecov 95.91 %, 1 unreached line + 7 half-taken branches — EXTEND)
   
   This file was partly covered by #7683; what follows is the remainder.
   
   - `handleOperatorAddAndDelete` (101) — `if (event.transaction.local)`. Emit 
an event with `transaction.local` false (a remote change) as well as a local 
one.
   - `handleElementPositionChange` (243) — `if (newPosition)`. Emit a position 
event whose new value is absent.
   - `handlePortEvent` (376, 383, 391, 393, 408) — the port add/remove/property 
chain. Cover the delete arm (`event.delta[0]?.delete`), the `event.path.length 
>= 3` property arm for both the input and the output side of the `isInput` 
ternaries, and the **final `else` at 408** — `throw new Error("undefined port 
operation on shared type: …")` — which is reachable by an event whose path 
neither includes `displayName` nor has length ≥ 3; assert with `expect(() => 
…).toThrow()`.
   - `onPortRemoved` (458) — `if (lastPort)`. Remove a port from an operator 
that has none left as well as from one that still has ports.
   
   Determinism constraints:
   - `vi.restoreAllMocks()` in `afterEach`, and `fixture.destroy()` for the 
component so no `@UntilDestroy` subscription leaks between tests.
   - Clone any shared fixture a method mutates in place, so tests do not depend 
on order.
   - No layout or geometry assertions — `getBoundingClientRect` / 
`scrollHeight` return zeros under jsdom. The position maths above uses plain 
numbers, not measured geometry.
   - Stub HTTP with `HttpClientTestingModule` and flush synchronously, or 
`of(...)`; never a real backend.
   
   ### 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