Skip to content

test(frontend): add unit tests for FileSaverService#6460

Open
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/file-saver-service-spec
Open

test(frontend): add unit tests for FileSaverService#6460
Ma77Ball wants to merge 2 commits into
apache:mainfrom
Ma77Ball:test/file-saver-service-spec

Conversation

@Ma77Ball

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

  • Adds file-saver.service.spec.ts covering FileSaverService; no production code changed.
  • Verifies delegation to FileSaver.saveAs for Blob and string payloads.
  • Covers the case where filename and options are omitted (undefined is passed through).

Any related issues, documentation, discussions?

Closes: #6448

How was this PR tested?

  • Run cd frontend && npx nx test gui --include="**/file-saver.service.spec.ts", expect 4 passed.
  • Full frontend suite runs in CI via yarn test:ci, selected by the auto-applied frontend label.

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

Co-authored with Claude Opus 4.8 in compliance with ASF

@github-actions github-actions Bot added the frontend Changes related to the frontend GUI label Jul 16, 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:

  • No candidates found from git blame history.

@codecov-commenter

codecov-commenter commented Jul 16, 2026

Copy link
Copy Markdown

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
2291 3 2288 3
View the top 3 failed test(s) by shortest run time
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > passes undefined through when filename and options are omitted
Stack Traces | 0.00654s run time
AssertionError: expected "vi.fn()" to be called with arguments: [ Blob{ …(1) }, undefined, undefined ]

Number of calls: 0

 ❯ .../user/file/file-saver.service.spec.ts:62:20
 ❯ src/test-zone-setup.ts:53:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > delegates a Blob payload to saveAs with filename and options
Stack Traces | 0.00693s run time
AssertionError: expected "vi.fn()" to be called 1 times, but got 0 times
 ❯ .../user/file/file-saver.service.spec.ts:47:20
 ❯ src/test-zone-setup.ts:53:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
src/app/dashboard/service/user/file/file-saver.service.spec.ts > FileSaverService > forwards a string payload (e.g. a URL) unchanged
Stack Traces | 0.00825s run time
AssertionError: expected "vi.fn()" to be called with arguments: [ Array(3) ]

Number of calls: 0

 ❯ .../user/file/file-saver.service.spec.ts:54:20
 ❯ src/test-zone-setup.ts:53:33
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:398:28
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34
 ❯ ProxyZoneSpec.onInvoke node_modules/zone.js/fesm2015/zone-testing.js:2132:39
 ❯ _ZoneDelegate.invoke node_modules/zone.js/fesm2015/zone.js:397:34

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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 adds Vitest unit coverage for the frontend FileSaverService (a thin wrapper around file-saver), improving confidence that the service correctly delegates payloads and optional arguments.

Changes:

  • Adds file-saver.service.spec.ts to verify delegation to file-saver’s saveAs for Blob and string inputs.
  • Adds assertions for pass-through behavior when filename and options are omitted.

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

Comment on lines +51 to +55
it("forwards a string payload (e.g. a URL) unchanged", () => {
service.saveAs("https://example.com/file.csv", "file.csv");

expect(saveAs).toHaveBeenCalledWith("https://example.com/file.csv", "file.csv", undefined);
});
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 frontend unit tests for FileSaverService

3 participants