Repository navigation
test(frontend): cover the missing branches in SharedModel, staged objects, UDF parameters and landing page - #7687
Conversation
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
Pull request overview
Adds Vitest unit tests to exercise previously unhit conditional branches in a few small frontend modules, improving per-file branch/line coverage without changing production code.
Changes:
- Added a new
SharedModelspec that mocksy-websocketto avoid real sockets/timers while covering constructor/awareness/transaction/destroy branches. - Extended
UiUdfParametersComponentspec to cover parse-error handling, fieldArray factory handling, missing-column guards, and trackBy fallbacks. - Extended
LandingPageComponentandUserDatasetStagedObjectsListComponentspecs to cover remaining conditional fallbacks and failure paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/app/workspace/service/workflow-graph/model/shared-model.spec.ts | New unit tests for SharedModel using a mocked websocket provider to cover branch cases safely. |
| frontend/src/app/workspace/component/ui-udf-parameters/ui-udf-parameters.component.spec.ts | Adds tests to hit missing error-handling and template/column-guard branches. |
| frontend/src/app/hub/component/landing-page/landing-page.component.spec.ts | Adds tests for no-user construction and empty-bucket hub responses; includes a case that currently violates a real service contract. |
| frontend/src/app/dashboard/component/user/user-dataset/user-dataset-explorer/user-dataset-staged-objects-list/user-dataset-staged-objects-list.component.spec.ts | Adds tests for missing-input guards, revert failure notification, and upload-time fallbacks. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7687 +/- ##
============================================
+ Coverage 90.44% 90.49% +0.05%
Complexity 4426 4426
============================================
Files 1175 1175
Lines 47131 47131
Branches 5285 5285
============================================
+ Hits 42626 42653 +27
+ Misses 2746 2740 -6
+ Partials 1759 1738 -21
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
fa9194a to
4ef73ad
Compare
`vi.mock("y-websocket")` is silently ignored when the whole suite is built at
once: the builder bundles the dependency into a shared chunk, so the module
specifier no longer matches and SharedModel keeps its real provider. The spec
passed on its own and failed the five double-dependent cases in CI.
Read the real provider instead — `roomname` for the room suffix and a spy on
`disconnect` for the teardown branches. No socket is opened either way; the
suite already installs an inert `WebSocket` global.
What changes were proposed in this PR?
Takes the untaken branch on each conditional in four small files (15 new tests):
user-dataset-staged-objects-list.component.tsshared-model.tsui-udf-parameters.component.tslanding-page.component.tsuserMakeChangesEvent, revertingwith no dataset id, the delete-failure notification, and the three
getFileUploadTimeguards (no map, a path whose last segment is empty so the|| filePathfallback runs, and a filename absent from the map).suffix with and without a workflow id, the local
CoeditorStatepublished fora signed-in user versus an anonymous one,
updateAwarenessin both modes,transact, and each combination ofshouldConnect/wsconnectedindestroy.The spec substitutes a
WebsocketProviderdouble — the real one opens a socketand schedules reconnects, which would put the network and a leaked timer inside
the test.
an unrelated error that must be rethrown, a
fieldArraysupplied as a factoryfunction, a generated row that declares none of the expected columns (both
if (!field) returnguards), a repeat populate that re-applies the disabledstate instead of re-wrapping the hook, and
trackByParameterName's?? index.enrichment that yields nothing, so all four
|| []fallbacks run, and aconstruction with no signed-in user.
landing-page.component.tsends at 20/21: the remaining entry is a syntheticbranch the compiler/instrumenter attributes to the class-declaration line. The
behaviour behind it is covered — the new test drives the no-user path and asserts
currentUidstays undefined — but neither stubbinggetCurrentUsernor clearingthe stub's user moves that counter.
No production code was changed.
Any related issues, documentation, discussions?
Closes #7684.
How was this PR tested?
ng test --watch=falseover the four specs — 47 passed; the per-file line/branch numbers above come from the local lcov report.eslintandprettier --checkclean. Failure path verified by breaking one new assertion in each of the four files: 4 failed / 43 passed, non-zero exit, then restored to green.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)