Skip to content

test(frontend): cover HubWorkflowDetailComponent#5236

Open
Ma77Ball wants to merge 4 commits into
apache:mainfrom
Ma77Ball:test/hubWorkflowDetailSpec
Open

test(frontend): cover HubWorkflowDetailComponent#5236
Ma77Ball wants to merge 4 commits into
apache:mainfrom
Ma77Ball:test/hubWorkflowDetailSpec

Conversation

@Ma77Ball
Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Add hub-workflow-detail.component.spec.ts covering constructor wid resolution (NZ_MODAL_DATA vs route), role-based isActivatedUser, and the disableWorkflowModification call.
  • Exercise ngOnInit count/view/isLiked branches including default-to-0, current-user fallback, and the empty-isLiked response case.
  • Cover loadWorkflowWithId (hub vs non-hub fork, success reloads + center event, error path leaves graph untouched), ngOnDestroy → clearWorkflow, goBack success and error, cloneWorkflow early-return and success, toggleLike (short-circuits, like/unlike, refresh, no-op when service returns false), formatCount, and changeViewDisplayStyle.
  • Use Recipe F (overrideComponent remove/add) to swap WorkflowEditorComponent, MiniMapComponent, and MarkdownDescriptionComponent for selector-equivalent stubs so the real template still renders under jsdom.

Any related issues, documentation, or discussions?

Closes: #5227

How was this PR tested?

  • yarn ng test --watch=false --include=src/app/hub/component/workflow/detail/hub-workflow-detail.component.spec.ts (32 passed).

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

Co-authored with Claude Opus 4.7 in compliance with ASF

@github-actions github-actions Bot requested a review from Xiao-zhen-Liu May 26, 2026 21:47
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label May 27, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.06%. Comparing base (d8c254c) to head (eda279a).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5236      +/-   ##
============================================
- Coverage     48.95%   46.06%   -2.89%     
+ Complexity     2377     2214     -163     
============================================
  Files          1048     1049       +1     
  Lines         40270    40655     +385     
  Branches       4272     4332      +60     
============================================
- Hits          19714    18729     -985     
- Misses        19402    20789    +1387     
+ Partials       1154     1137      -17     
Flag Coverage Δ *Carryforward flag
access-control-service 39.53% <ø> (ø) Carriedforward from 0bce181
agent-service 33.74% <ø> (-0.03%) ⬇️ Carriedforward from 0bce181
amber 44.07% <ø> (-7.50%) ⬇️ Carriedforward from 0bce181
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 0bce181
config-service 0.00% <ø> (ø) Carriedforward from 0bce181
file-service 32.09% <ø> (-5.90%) ⬇️ Carriedforward from 0bce181
frontend 41.12% <ø> (+0.47%) ⬆️
python 90.45% <ø> (-0.35%) ⬇️ Carriedforward from 0bce181
workflow-compiling-service 56.81% <ø> (ø) Carriedforward from 0bce181

*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:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ma77Ball
Copy link
Copy Markdown
Contributor Author

/request-review @aglinxinyuan

@github-actions github-actions Bot requested review from aglinxinyuan and removed request for Xiao-zhen-Liu May 27, 2026 04:33
@aglinxinyuan aglinxinyuan requested a review from Copilot May 27, 2026 04:47
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 adds focused frontend unit coverage for HubWorkflowDetailComponent, addressing the Hub workflow detail coverage gap described in #5227.

Changes:

  • Adds a new Vitest spec for constructor state, lifecycle behavior, workflow loading, navigation, cloning, likes, and formatting helpers.
  • Uses standalone child-component stubs with overrideComponent remove/add so the real parent template still renders under jsdom.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +116 to +117
provide: ActivatedRoute,
useValue: { snapshot: { params: opts.routeId !== undefined ? { id: opts.routeId } : {} } },
Comment on lines +278 to +285
build({ modalData: { wid: 5 } });
expect(workflowActionServiceMock.reloadWorkflow).not.toHaveBeenCalled();
expect(stubGraph.triggerCenterEvent).not.toHaveBeenCalled();
});

it("does not reload or trigger center event when retrievePublicWorkflow errors", () => {
workflowPersistServiceMock.retrievePublicWorkflow.mockReturnValue(throwError(() => new Error("boom")));
build({ modalData: undefined, routeId: 9 });
Comment on lines +277 to +285
workflowPersistServiceMock.retrieveWorkflow.mockReturnValue(throwError(() => new Error("boom")));
build({ modalData: { wid: 5 } });
expect(workflowActionServiceMock.reloadWorkflow).not.toHaveBeenCalled();
expect(stubGraph.triggerCenterEvent).not.toHaveBeenCalled();
});

it("does not reload or trigger center event when retrievePublicWorkflow errors", () => {
workflowPersistServiceMock.retrievePublicWorkflow.mockReturnValue(throwError(() => new Error("boom")));
build({ modalData: undefined, routeId: 9 });
@aglinxinyuan aglinxinyuan enabled auto-merge May 27, 2026 04:53
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 spec coverage for hub-workflow-detail.component.ts

4 participants