Skip to content

test(frontend): add unit tests for WorkspaceComponent#4969

Merged
Yicong-Huang merged 3 commits into
apache:mainfrom
Yicong-Huang:test/workspace-component-spec
May 10, 2026
Merged

test(frontend): add unit tests for WorkspaceComponent#4969
Yicong-Huang merged 3 commits into
apache:mainfrom
Yicong-Huang:test/workspace-component-spec

Conversation

@Yicong-Huang
Copy link
Copy Markdown
Contributor

@Yicong-Huang Yicong-Huang commented May 6, 2026

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.json and angular.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:ci clean.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.7 (1M context)

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label May 6, 2026
Copy link
Copy Markdown
Contributor

@aglinxinyuan aglinxinyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-commenter
Copy link
Copy Markdown

codecov-commenter commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 42.48%. Comparing base (23969c7) to head (f40376a).

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     
Flag Coverage Δ *Carryforward flag
access-control-service 39.88% <ø> (ø) Carriedforward from 23969c7
agent-service 33.72% <ø> (ø) Carriedforward from 23969c7
amber 43.26% <ø> (ø) Carriedforward from 23969c7
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 23969c7
config-service 0.00% <ø> (ø) Carriedforward from 23969c7
file-service 32.10% <ø> (ø) Carriedforward from 23969c7
frontend 33.50% <ø> (-1.67%) ⬇️
python 88.84% <ø> (ø) Carriedforward from 23969c7
workflow-compiling-service 47.72% <ø> (ø) Carriedforward from 23969c7

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 WorkspaceComponent behaviors (ngOnInit, ngAfterViewInit, loadWorkflowWithId, triggerCenter, registerAutoPersistWorkflow, copilotEnabled) with service stubs and a minimal overridden template.
  • Updated frontend test configurations to stop excluding workspace.component.spec.ts so it is compiled and executed as part of ng 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.

Comment thread frontend/src/app/workspace/component/workspace.component.spec.ts
Yicong-Huang and others added 2 commits May 10, 2026 16:17
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>
@Yicong-Huang Yicong-Huang force-pushed the test/workspace-component-spec branch from 234573e to f40376a Compare May 10, 2026 23:22
@Yicong-Huang Yicong-Huang merged commit bd445b5 into apache:main May 10, 2026
16 checks passed
@Yicong-Huang Yicong-Huang deleted the test/workspace-component-spec branch May 10, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add unit tests for WorkspaceComponent

4 participants