Fix the zip file related tests (#1602)

This commit is contained in:
Abhinav Kumar 2024-02-08 10:08:30 +05:30 committed by GitHub
commit a88c7212a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,11 +1,15 @@
import { DataStream } from 'types/upload';
import ImportService from 'services/importService';
import ElectronAPIs from '@ente/shared/electron';
import { FILE_READER_CHUNK_SIZE, PICKED_UPLOAD_TYPE } from 'constants/upload';
import { getFileStream, getElectronFileStream } from 'services/readerService';
import { getFileNameSize } from '@ente/shared/logging/web';
import isElectron from 'is-electron';
import { getImportSuggestion } from 'utils/upload';
// This was for used to verify that converting from the browser readable stream
// to the node readable stream correctly handles files that align on the 4 MB
// data boundary. This expects a zip file containing random files of various
// sizes starting from 1M to 20M.
export const testZipFileReading = async () => {
try {
if (!isElectron()) {
@ -17,12 +21,12 @@ export const testZipFileReading = async () => {
'upload test failed NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH missing'
);
}
const files = await ImportService.getElectronFilesFromGoogleZip(
const files = await ElectronAPIs.getElectronFilesFromGoogleZip(
process.env.NEXT_PUBLIC_FILE_READING_TEST_ZIP_PATH
);
if (!files?.length) {
throw Error(
`testZipFileReading Check failed ❌
`testZipFileReading Check failed ❌
No files selected`
);
}
@ -73,6 +77,8 @@ export const testZipFileReading = async () => {
}
};
// This was used when fixing a bug around handling a zip file that has a photo
// at the root.
export const testZipWithRootFileReadingTest = async () => {
try {
if (!isElectron()) {
@ -84,7 +90,7 @@ export const testZipWithRootFileReadingTest = async () => {
'upload test failed NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH missing'
);
}
const files = await ImportService.getElectronFilesFromGoogleZip(
const files = await ElectronAPIs.getElectronFilesFromGoogleZip(
process.env.NEXT_PUBLIC_ZIP_WITH_ROOT_FILE_PATH
);