mengw15 opened a new pull request, #7420:
URL: https://github.com/apache/texera/pull/7420

   ### What changes were proposed in this PR?
   
   Extends `UserComputingUnitListItemComponent`'s spec to exercise the row 
through
   the DOM. The class file is already at 100%, but the existing tests call the
   handlers directly and never click the row's buttons, so
   `user-computing-unit-list-item.component.html` sat at ~52%.
   
   10 added tests render the row and drive it via
   `fixture.debugElement.query(By.css(...))`:
   
   - **Buttons** — the rename button starts inline editing; clicking the unit 
name opens the metadata modal (`NzModalService.create` spied); the delete 
button emits the `deleted` output.
   - **Inline rename** — `Escape` cancels and `Enter` confirms with the typed 
value (both fired as real `KeyboardEvent`s), and a click inside the input does 
not bubble to the row.
   - **Sharing** — the share button is omitted while 
`sharingComputingUnitEnabled` is off, and opens the share-access modal when it 
is on.
   - **Metrics popover** — the CPU/RAM rows render, and the GPU / JVM-memory / 
shared-memory rows appear only when those limits are set (covering both arms of 
their `*ngIf`s).
   
   This lifts the template from **~52% to 100%** (statements *and* branches); 
the
   class stays at 100%.
   
   Two things worth noting, both found by checking rather than assuming:
   
   - The `Escape`/`Enter` tests dispatch **real** `KeyboardEvent`s. With 
`triggerEventHandler("keydown.escape", …)` the handler does fire (verified with 
a spy), but it bypasses Angular's key-filtering, so the real dispatch is both 
more representative and what the coverage reflects.
   - The last uncovered line was reported as html:79, but reading the coverage 
`statementMap` showed the uncovered statement actually spans to **line 84** — 
the input's `(click)="$event.stopPropagation()"`. That is what the added "click 
does not bubble" test covers.
   
   **Determinism:** no `vi.useFakeTimers()` (the component's `setTimeout` never 
runs
   in a synchronous test body, and layering fake timers over zone.js's patched
   timers is Node-version dependent); no layout/geometry assertions. The 
popover is
   opened synchronously via `.injector.get(NzPopoverDirective).show()` +
   `detectChanges()` — the pattern already used in
   `user-dataset-staged-objects-list.component.spec.ts` — and hidden again
   afterwards. The sharing flag is flipped through 
`TestBed.inject(GuiConfigService)`
   (the same DI instance the component holds, whose config object is 
per-instance),
   so nothing leaks between tests. No production code was changed.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7411
   
   ### How was this PR tested?
   
   Extended unit tests, run locally in `frontend/`:
   
   ```
   ng test --watch=false --include 
src/app/dashboard/component/user/user-computing-unit/user-computing-unit-list-item/user-computing-unit-list-item.component.spec.ts
   # Test Files 1 passed (1) | Tests 45 passed (45)   — 3 consecutive runs, 0 
flakes
   # user-computing-unit-list-item.component.html: ~52% -> 100% (statements & 
branches)
   prettier --write <spec>   # formatted
   eslint  <spec>            # clean
   ```
   
   The failure path was verified by deliberately breaking a new assertion and
   confirming the suite exits non-zero.
   
   ### 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]

Reply via email to