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

   ### Task Summary
   
   `ListItemComponent` renders every kind of dashboard entry — workflow, 
dataset, file — and dispatches on `entry.type` in half a dozen places, but the 
spec only ever feeds it one kind. The result is **26 uncovered lines and 23 
half-taken branches at 71.83 %**. Every one is an ordinary data-driven branch: 
give the component an entry of a different type, or one missing a field, and 
the arm runs.
   
   Vitest/jsdom; see `frontend/TESTING.md` and `frontend/AGENTS.md`. Use the 
local coverage report to confirm each arm flipped — the lines below are where 
the report points today, not a fence.
   
   ### Behavior to add
   
   **`ListItemComponent`** 
(`frontend/src/app/dashboard/component/user/list-item/list-item.component.ts`, 
codecov 71.83 % — EXTEND `list-item.component.spec.ts`)
   
   Parameterise the existing setup so a test can hand the component any entry 
type, then cover:
   
   - **The required-input guard** (121–122) — `if (!this._entry) throw new 
Error("entry property must be provided.")`. Assert the throw when the component 
is created without an `entry`.
   - **Icon dispatch** (149–179) — the chain that picks `iconType` from 
`entry.type`, including the `dataset` branch and its nested `typeof 
this.entry.id === "number"` check, the `file` branch that sets `"folder-open"`, 
and the trailing `throw new Error("Unexpected type in DashboardEntry.")` for a 
type the chain does not know. Cover each type and the unknown-type throw with 
`expect(() => …).toThrow()`.
   - **`renderMarkdownPreview`** (187–190) — `const trimmed = (text ?? 
"").trim()` then the early return that sets `renderedDescription = ""`. Cover 
an undefined description, a whitespace-only one, and a real one so both the 
`??` fallback and the empty-guard arms are taken.
   - **Detail-modal creation** (215–247) — `modalService.create` is called with 
different configuration for `workflow` and for `dataset`; then `if (modal)` 
guards subscribing to `modal.componentInstance?.refresh`, which re-emits 
`this.refresh`. Stub the modal service to return a handle with a `refresh` 
subject, assert the right configuration per type, emit on the subject and 
assert `refresh` fires. Also cover the case where the service returns nothing 
so the `if (modal)` false arm runs.
   - **Download dispatch** (253–261) — the `if (!this.entry.id) return` early 
exit, then `downloadService.downloadWorkflow` versus 
`downloadService.downloadDataset` per type. Stub the download service with 
`of(...)` and assert which method was called with which arguments.
   - **Rename / description editing** — `confirmUpdateCustomName` (342), 
`confirmUpdateCustomDescription` (372) and the `if (this.nameInput)` focus path 
around 269. Cover both the present and absent `nameInput` view child.
   - **`openDetailModal`** (398).
   
   Determinism notes:
   - `fixture.detectChanges()` after each state change, and `fixture.destroy()` 
in `afterEach` so the `untilDestroyed` subscriptions on the modal-refresh and 
download streams do not outlive their test.
   - **Clone the entry fixture per test** — several of these handlers mutate 
the entry in place (a rename leaks into a later "unchanged" assertion if a 
single shared object is reused).
   - Stub `modalService` and `downloadService`; never open a real modal or hit 
a backend. Use `of(...)` so streams emit synchronously.
   - No layout or geometry assertions — `nativeElement.focus()` may be spied 
on, but `getBoundingClientRect` and friends return zeros under jsdom.
   - `vi.restoreAllMocks()` in `afterEach`.
   
   Note #7463 is open and removes the deprecated project feature, which touches 
this component — rebase before finishing and do not build assertions around 
project-type entries.
   
   ### 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