Skip to content

test(frontend): extend DownloadService coverage; fix jszip default import#6817

Open
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-fe-download-service
Open

test(frontend): extend DownloadService coverage; fix jszip default import#6817
aglinxinyuan wants to merge 1 commit into
apache:mainfrom
aglinxinyuan:test-fe-download-service

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Extends download.service.spec.ts with 4 tests (19 -> 23) and un-skips the previously-skipped zip tests, reaching 100% coverage of download.service.ts. New/strengthened tests cover the multi-file operators-result zip branch (loads the produced blob back and asserts entries), the flat() merge routing, createWorkflowsZip assembly (one JSON per workflow), nameWorkflow collision de-duplication, and the exportWorkflowResultToLocal empty-token fallback.

Source change: import * as JSZip -> import JSZip from "jszip" in download.service.ts. The namespace import makes new JSZip() throw "not a constructor" under esbuild/Vitest (and esbuild warns it will crash at runtime), which had forced every zip path to be skipped. The default import matches the existing usage in user-workflow.component.ts (already shipped in the prod build) and is safe for the webpack prod build — jszip is CommonJS (module.exports = JSZip) and allowSyntheticDefaultImports is set.

Any related issues, documentation, discussions?

Closes #6813.

How was this PR tested?

ng test --include='**/download.service.spec.ts' -> 23/23 passing (0 skipped). yarn format:ci passes. The default-import pattern is already used and shipped in user-workflow.component.ts.

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

Generated-by: Claude Code (Opus 4.8 [1M context])

…port

Add tests covering the multi-file zip branch, createWorkflowsZip assembly,
nameWorkflow collision de-dup, and the empty-token fallback. Reaches 100%.

Also change `import * as JSZip` to `import JSZip from 'jszip'` in the source:
the namespace import throws "not a constructor" under esbuild/Vitest (and esbuild
warns it will crash at runtime), which had forced the zip paths to be skipped. The
default import matches the existing usage in user-workflow.component.ts and is safe
for the webpack prod build (jszip is CJS; allowSyntheticDefaultImports is set).
Copilot AI review requested due to automatic review settings July 23, 2026 05:03
@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @mengw15, @gracecluvohio
    You can notify them by mentioning @mengw15, @gracecluvohio in a comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 improves the frontend DownloadService reliability and testability by fixing JSZip interop in the service implementation and expanding unit test coverage to fully exercise ZIP-related branches (closing #6813).

Changes:

  • Switch download.service.ts to a JSZip default import so new JSZip() works under esbuild/Vitest (unblocking ZIP-path tests).
  • Extend download.service.spec.ts with additional tests covering workflow ZIP assembly, filename de-duplication, multi-file operator-result ZIP behavior, flat() merge routing, and the empty-token fallback in exportWorkflowResultToLocal.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
frontend/src/app/dashboard/service/user/download/download.service.ts Fix JSZip import style so ZIP construction works correctly in the test/build toolchain.
frontend/src/app/dashboard/service/user/download/download.service.spec.ts Add/enable tests to exercise real ZIP generation/loading and remaining edge cases to reach full coverage.

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

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.27%. Comparing base (110a54c) to head (f36e41c).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #6817   +/-   ##
=========================================
  Coverage     76.27%   76.27%           
  Complexity     3452     3452           
=========================================
  Files          1161     1161           
  Lines         45919    45919           
  Branches       5100     5100           
=========================================
  Hits          35025    35025           
  Misses         9329     9329           
  Partials       1565     1565           
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 110a54c
agent-service 76.76% <ø> (ø) Carriedforward from 110a54c
amber 67.33% <ø> (ø) Carriedforward from 110a54c
computing-unit-managing-service 20.49% <ø> (ø) Carriedforward from 110a54c
config-service 66.66% <ø> (ø) Carriedforward from 110a54c
file-service 67.21% <ø> (ø) Carriedforward from 110a54c
frontend 81.71% <ø> (ø) Carriedforward from 110a54c
notebook-migration-service 78.94% <ø> (ø) Carriedforward from 110a54c
pyamber 92.15% <ø> (ø) Carriedforward from 110a54c
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 110a54c

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

☔ View full report in Codecov by Harness.
📢 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.

@aglinxinyuan

Copy link
Copy Markdown
Contributor Author

Closing as it doesn't increase coverage

@aglinxinyuan
aglinxinyuan requested a review from mengw15 July 23, 2026 23:50
@aglinxinyuan aglinxinyuan reopened this Jul 23, 2026
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.

Extend DownloadService unit test coverage

3 participants