Repository navigation
Description
Task Summary
ComputingUnitSelectionComponent is at 80.21 % with 51 uncovered lines and 24 half-taken branches, and the bulk of that is its Python-virtual-environment management: creating an environment, reconciling saved packages against the database, installing user packages, and streaming pip output over a websocket. The validation guards in that area — duplicate environment name, missing package version, package already present as a system package — are never triggered.
Pure EXTEND of computing-unit-selection.component.spec.ts (98 it() blocks already). Vitest/jsdom; see frontend/TESTING.md and frontend/AGENTS.md.
Behavior to add
ComputingUnitSelectionComponent — PVE management (frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts, codecov 80.21 % — EXTEND)
createVirtualEnvironment(948–952) —duplicateExistsscans the other environments for a name clash; when it hits,notificationService.error("An environment with this name already exists…")fires and the method returns without creating. Cover the duplicate case (and confirm nothing was created) and the unique case.installUserPackages(966–987) — three separate paths:missingVersionPackage(966–971): a package with a name but no operator or no version triggers "Please specify an operator and version…" and returns. Cover a package missing the operator, one missing the version, and a fully-specified one.- the filter at 981–984 that keeps only packages with a non-empty trimmed name;
- the system-package skip (986–987): when the lower-cased package name is already in
systemPackageNames, it reports "Skipped : already installed as a system package" and does not install it. Cover a name that collides (including a case-differing one, since the check lower-cases) and one that does not.
applySavedPveAsUpdate(709–717) — the reconciliation between the current environment and what the database holds. Theelse if ((cur.version ?? "").trim() !== (db.version ?? "").trim())arm pushes the current package ontotoDelete, as does the later branch at 717. Cover: a package whose version matches (no deletion), one whose version differs (deletion), and one whose version is absent on either side so the?? ""fallback is taken.parseDbPackages(689) andgetPVEs(776) — thematch ? match[2] : raw ?? ""and(version ?? "").trim()fallbacks; feed rows with and without a parseable version.togglePackageDelete(607) — thepkg.version ?? ""fallback for a package with no version.runPveWebSocket(889, 904) — the message path appendsevent.datatocurrentEnv.pipOutput ?? "", and the error path appends"\n[WebSocket error]\n". Cover both starting from an environment with no prior output so the?? ""fallback runs. Drive the socket by invoking the double'sonmessage/onerrordirectly.updatePrettyPipOutput(819) — theenv.pipOutput ?? ""fallback.refreshUserPackages(925–928) — the success path assigningparsePackageRows(pkgs)and theerror:handler.confirmUpdateUnitName(443–447) — theif (unit)guard and theif (this.selectedComputingUnit?.computingUnit.cuid === cuid)branch that also updates the selected unit. Cover renaming the selected unit and a different one.startEditingUnitName(415–417) — theif (input)guard aroundfocus()/select(); cover with the input present and absent. Spy onfocus/select; do not assert on caret position or geometry.registerWorkflowMetadataSubscription(281) — theif (runningUnit)branch.
Determinism notes:
- Stub the websocket with a fake whose handlers you invoke synchronously; never open a real connection and never wait on a timer.
- Stub
notificationService, the PVE service and the computing-unit service; useof(...)/throwError(...)orHttpClientTestingModulewith synchronous flushes. vi.restoreAllMocks()inafterEach,fixture.destroy()so pollers stop, and clone environment/package fixtures per test — these handlers mutate them in place.- Do not assert on
console.erroralone; assert on the notification message and the resulting state.
Out of scope: the resource-formatting getters (getCpuValue, getMemoryValue, getCpuUnit, getMemoryUnit and friends) — #6745 proposed exactly those and was closed as not planned, so leave them alone here.
Note #7752 is open and touches this component — rebase before finishing.
Task Type
- Refactor / Cleanup
- DevOps / Deployment / CI
- Testing / QA
- Documentation
- Performance
- Other
Activity
test(frontend): cover the virtual-environment package management guar…