test(frontend): add unit tests for WorkspaceComponent#4969
Conversation
aglinxinyuan
left a comment
There was a problem hiding this comment.
The fixture overrides the component's template to a minimal
<div #codeEditor>
Do we have to overrides the component's template to a minimal <div #codeEditor>? If we don't load children, the test cannot verify the side effects after loading them.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4969 +/- ##
============================================
- Coverage 43.37% 42.48% -0.89%
Complexity 2186 2186
============================================
Files 1035 1045 +10
Lines 38818 39878 +1060
Branches 4061 4205 +144
============================================
+ Hits 16837 16942 +105
- Misses 20928 21877 +949
- Partials 1053 1059 +6
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR replaces the placeholder WorkspaceComponent spec with a real Vitest-based unit test suite and re-enables that spec in the frontend test build configuration, improving confidence in the workspace route’s initialization and workflow-loading behaviors.
Changes:
- Implemented unit tests covering key
WorkspaceComponentbehaviors (ngOnInit,ngAfterViewInit,loadWorkflowWithId,triggerCenter,registerAutoPersistWorkflow,copilotEnabled) with service stubs and a minimal overridden template. - Updated frontend test configurations to stop excluding
workspace.component.spec.tsso it is compiled and executed as part ofng test.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/src/app/workspace/component/workspace.component.spec.ts | Adds a real unit test suite for WorkspaceComponent with mocked dependencies and a minimal template override. |
| frontend/src/tsconfig.spec.json | Removes the workspace spec from the TypeScript spec exclude list so it compiles in test builds. |
| frontend/angular.json | Removes the workspace spec from the Angular test exclude list so it runs under the unit-test builder. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes apache#4967. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…cess, destroy paths in WorkspaceComponent Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per review on PR apache#4969, tracking the deferred work (drop the template override and let real children — CodeEditorComponent etc. — render) under apache#5015. Added a TODO comment at the `overrideComponent` call so the deferral is discoverable from the spec. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
234573e to
f40376a
Compare
What changes were proposed in this PR?
Replace the license-only placeholder spec with 19 unit tests covering
WorkspaceComponent's public surface — pid parsing, cold/warm start, workflow loading (success / 403 / broken / URL fragment), view-count wiring, write-access from metadata, auto-persist idempotency, destroy-time persist + cleanup, and the copilot getter.The fixture overrides the template to
<div #codeEditor>so the heavyweight children don't compile in the test build, and stubs all 14 injected services.Drop the spec from the exclude lists in
tsconfig.spec.jsonandangular.json.Any related issues, documentation, discussions?
Closes #4967.
How was this PR tested?
yarn ng test --watch=false: 267 pass, 8 skip, 2 todo.yarn format:ciclean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.7 (1M context)