Skip to content

Add spec coverage for hub-workflow-detail.component.ts #5227

@Ma77Ball

Description

@Ma77Ball

Task Summary

Create hub-workflow-detail.component.spec.ts for frontend/src/app/hub/component/workflow/detail/hub-workflow-detail.component.ts.

Behavior to cover:

  • Constructor / wid resolution — when NZ_MODAL_DATA provides { wid }, uses that and leaves isHub = false; otherwise reads wid from route.snapshot.params.id and sets isHub = true. Sets isActivatedUser true for Role.ADMIN or Role.REGULAR. Always calls WorkflowActionService.disableWorkflowModification().
  • ngOnInit — early-returns when wid undefined. Otherwise:
    • HubService.getCounts([Workflow], [wid], [Like, Clone]) → assigns likeCount, cloneCount (defaulting to 0).
    • HubService.postView(wid, currentUid ?? 0, Workflow) is debounced via throttleTime(THROTTLE_TIME_MS) (1000ms) → assigns viewCount.
    • When a currentUser is defined, calls HubService.isLiked([wid], [Workflow]) and sets isLiked from result[0].isLiked (false if empty).
  • ngAfterViewInit / loadWorkflowWithId — when isHub calls retrievePublicWorkflow, otherwise retrieveWorkflow; on success reloads via WorkflowActionService.reloadWorkflow and triggers center event; on error throws.
  • ngOnDestroy (bound to window:beforeunload) — calls WorkflowActionService.clearWorkflow.
  • goBack — navigates to DASHBOARD_HUB_WORKFLOW_RESULT; on failure calls NotificationService.error("Go back failed. Please try again.").
  • cloneWorkflow — early-returns when wid undefined; otherwise calls HubService.cloneWorkflow(wid), navigates to ${DASHBOARD_USER_WORKSPACE}/${newWid}, and shows "Clone Successful" success notification.
  • toggleLike — short-circuits without userId or wid; calls postUnlike when already liked, postLike otherwise; on success flips isLiked and refreshes likeCount via getCounts.
  • formatCount — returns "1.0k" for 1000, raw string for <1000.
  • changeViewDisplayStyle — toggles displayPreciseViewCount.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions