Repository navigation
Description
Task Summary
menu.component.html has 75 uncovered template lines at 66.81%, while its component class sits at 86.27%. The spec is mature — 62 it() blocks — but calls detectChanges() only 6 times, so it exercises the handlers directly and almost never renders the markup that invokes them. Goal: bring the template toward full coverage by driving it through the DOM.
Vitest/jsdom; see frontend/TESTING.md and frontend/AGENTS.md.
Behavior to add
MenuComponent template (frontend/src/app/workspace/component/menu/menu.component.html, codecov 66.81 %, EXTEND menu.component.spec.ts)
The mechanics that apply throughout: call fixture.detectChanges() after every state change, query with fixture.debugElement.query(By.css(...)) and fire .triggerEventHandler("click", null) rather than calling the method on the instance, and seed the inputs/service state each *ngIf needs so its arm renders. Run the local coverage report to catch whatever is left after the clusters below — treat this list as a map of where the red lines are, not as a fence.
The uncovered lines fall into five groups:
- Version-display bar (lines 25–79) — the whole
displayParticularWorkflowVersionbranch never renders: the close button,revertToVersion()/cloneVersion()with their[disabled]="!workflowVersionService.canRestoreVersion"guard, theCurrent Version: {{ … }}label, and the*ngForover coeditor icons. Set the version service'sdisplayParticularWorkflowVersionandselectedDisplayedVersionId, render, then assert both the enabled and disabled states of the restore button. - Toolbar click bindings (98, 106, 116, 125, 133) —
onClickCreateNewWorkflow(),persistWorkflow(),onClickDeleteAllOperators(),onClickExportWorkflow(),onClickEditDescription()are only ever called directly. Spy on each and fire the click from the rendered button. - View-toggle switches (169–194) —
showGrid/showRegion/showNumWorkers/showStatusand their(ngModelChange)handlerstoggleGrid()/toggleRegion()/toggleNumWorkers()/toggleStatus(). Drive them through the switch element so both the binding and the handler run. - Operator context menu (253–333) —
onClickExportExecutionResult(),operatorMenu.disableHighlightedOperators(),viewResultHighlightedOperators(),reuseResultHighlightedOperator(), andundoRedoService.undoAction()/redoAction(). Each has a[disabled]guard (isDisableOperatorClickable,isToViewResultClickable,isReuseResultClickable); cover both sides by highlighting an operator and by leaving the selection empty. - Execution settings popover and status footer (375–448) —
handleCheckpoint()with[disabled]="executionState !== ExecutionState.Paused", thecurrentExecutionNameinput gated onisWorkflowModifiable, the email-notification switch bound toconfig.env.workflowEmailNotificationEnabled, and the connected/disconnected footer including the*ngIf="workflowWebsocketService.isConnected"block that shows the computing-unit status and worker count. Toggle the websocket service'sisConnectedand the computing-unit state so both arms render.
Determinism constraints for this file:
- Do not assert on layout or geometry —
getBoundingClientRect/scrollHeightreturn zeros under jsdom. - Do not assert on
DatePipe-rendered text; a fixed epoch renders a different day under a UTC runner. Rendering it is fine, asserting the string is not. fixture.destroy()inafterEachso any@UntilDestroysubscription stops between tests, andvi.restoreAllMocks()so spies do not leak.
Out of scope: anything requiring a real backend — use HttpClientTestingModule and flush synchronously, or stub the services with of(...).
Note there are open PRs touching this component (#7463 removes the deprecated project feature, #6213 and #4270 add toolbar entries), so rebase before finishing and do not build assertions around project-specific menu items.
Task Type
- Refactor / Cleanup
- DevOps / Deployment / CI
- Testing / QA
- Documentation
- Performance
- Other
Activity
test(frontend): drive the workspace menu template through the DOM (ap…