mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-11 13:48:37 +02:00
Pass tests
This commit is contained in:
parent
8e49f9ce9a
commit
e1296f5ac9
@ -88,23 +88,28 @@ export const useConvertOperation = () => {
|
|||||||
parameters: ConvertParameters,
|
parameters: ConvertParameters,
|
||||||
selectedFiles: File[]
|
selectedFiles: File[]
|
||||||
): Promise<File[]> => {
|
): Promise<File[]> => {
|
||||||
|
|
||||||
const processedFiles: File[] = [];
|
const processedFiles: File[] = [];
|
||||||
const endpoint = getEndpointUrl(parameters.fromExtension, parameters.toExtension);
|
const endpoint = getEndpointUrl(parameters.fromExtension, parameters.toExtension);
|
||||||
|
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
throw new Error('Unsupported conversion format');
|
throw new Error(t('errorNotSupported', 'Unsupported conversion format'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert-specific routing logic: decide batch vs individual processing
|
// Convert-specific routing logic: decide batch vs individual processing
|
||||||
if (shouldProcessFilesSeparately(selectedFiles, parameters)) {
|
if (shouldProcessFilesSeparately(selectedFiles, parameters)) {
|
||||||
// Individual processing for complex cases (PDF→image, smart detection, etc.)
|
// Individual processing for complex cases (PDF→image, smart detection, etc.)
|
||||||
for (const file of selectedFiles) {
|
for (const file of selectedFiles) {
|
||||||
const formData = buildFormData(parameters, [file]);
|
try {
|
||||||
const response = await axios.post(endpoint, formData, { responseType: 'blob' });
|
const formData = buildFormData(parameters, [file]);
|
||||||
|
const response = await axios.post(endpoint, formData, { responseType: 'blob' });
|
||||||
const convertedFile = createFileFromResponse(response.data, response.headers, file.name, parameters.toExtension);
|
|
||||||
|
const convertedFile = createFileFromResponse(response.data, response.headers, file.name, parameters.toExtension);
|
||||||
processedFiles.push(convertedFile);
|
|
||||||
|
processedFiles.push(convertedFile);
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`Failed to convert file ${file.name}:`, error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Batch processing for simple cases (image→PDF combine)
|
// Batch processing for simple cases (image→PDF combine)
|
||||||
|
@ -389,7 +389,7 @@ describe('Convert Tool Integration Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
expect(mockedAxios.post).not.toHaveBeenCalled();
|
expect(mockedAxios.post).not.toHaveBeenCalled();
|
||||||
expect(result.current.status).toContain('noFileSelected');
|
expect(result.current.errorMessage).toContain('noFileSelected');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user