test(frontend): extend DownloadService coverage; fix jszip default import#6817
test(frontend): extend DownloadService coverage; fix jszip default import#6817aglinxinyuan wants to merge 1 commit into
Conversation
…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).
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
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.tsto a JSZip default import sonew JSZip()works under esbuild/Vitest (unblocking ZIP-path tests). - Extend
download.service.spec.tswith additional tests covering workflow ZIP assembly, filename de-duplication, multi-file operator-result ZIP behavior,flat()merge routing, and the empty-token fallback inexportWorkflowResultToLocal.
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 Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Closing as it doesn't increase coverage |
What changes were proposed in this PR?
Extends
download.service.spec.tswith 4 tests (19 -> 23) and un-skips the previously-skipped zip tests, reaching 100% coverage ofdownload.service.ts. New/strengthened tests cover the multi-file operators-result zip branch (loads the produced blob back and asserts entries), theflat()merge routing,createWorkflowsZipassembly (one JSON per workflow),nameWorkflowcollision de-duplication, and theexportWorkflowResultToLocalempty-token fallback.Source change:
import * as JSZip->import JSZip from "jszip"indownload.service.ts. The namespace import makesnew 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 inuser-workflow.component.ts(already shipped in the prod build) and is safe for the webpack prod build — jszip is CommonJS (module.exports = JSZip) andallowSyntheticDefaultImportsis 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:cipasses. The default-import pattern is already used and shipped inuser-workflow.component.ts.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8 [1M context])