Refactor File Download Logic and Streamline Test Suite (#9281)

Closes #9277 

## Summary of Changes
- Updated the file-download functionality to use the `saveAs` method
from the `file-saver` library, ensuring a more reliable and consistent
implementation.
- Removed redundant tests to streamline the test suite and reduce
maintenance overhead.

## Testing Performed
- [x] Verified that exporting the view to a CSV file works as expected.
This commit is contained in:
Samyak Piya
2024-12-31 08:08:22 -05:00
committed by GitHub
parent cdc2dfe709
commit 2b82347fdc
3 changed files with 5 additions and 68 deletions

View File

@ -1,3 +1,4 @@
import { saveAs } from 'file-saver';
import { getFileAbsoluteURI } from '~/utils/file/getFileAbsoluteURI';
export const downloadFile = (fullPath: string, fileName: string) => {
@ -8,13 +9,6 @@ export const downloadFile = (fullPath: string, fileName: string) => {
: Promise.reject('Failed downloading file'),
)
.then((blob) => {
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.style.display = 'none';
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
saveAs(blob, fileName);
});
};