fix(tests): resolve issue in languageselector component for frontend tests

This commit is contained in:
perf3ct 2025-07-18 20:39:41 +00:00
parent 77db933b58
commit 7d89a711cb
2 changed files with 20 additions and 15 deletions

View File

@ -81,11 +81,8 @@ describe('LanguageSelector Component', () => {
// Open dropdown // Open dropdown
await user.click(screen.getByText('Select OCR languages...')); await user.click(screen.getByText('Select OCR languages...'));
// Select English from the dropdown // Select English from the dropdown - click on the language text directly
const englishButton = screen.getByText('English').closest('button'); await user.click(screen.getByText('English'));
if (englishButton) {
await user.click(englishButton);
}
expect(mockOnChange).toHaveBeenCalledWith(['eng'], 'eng'); expect(mockOnChange).toHaveBeenCalledWith(['eng'], 'eng');
}); });
@ -216,10 +213,7 @@ describe('LanguageSelector Component', () => {
// Open dropdown and select English // Open dropdown and select English
await user.click(screen.getByText('Select OCR languages...')); await user.click(screen.getByText('Select OCR languages...'));
const englishButton = screen.getByText('English').closest('button'); await user.click(screen.getByText('English'));
if (englishButton) {
await user.click(englishButton);
}
expect(mockOnChange).toHaveBeenCalledWith(['eng'], 'eng'); expect(mockOnChange).toHaveBeenCalledWith(['eng'], 'eng');
}); });

View File

@ -459,7 +459,9 @@ startxref
error_msg.contains("extraction") || error_msg.contains("extraction") ||
error_msg.contains("InputFileError") || error_msg.contains("InputFileError") ||
error_msg.contains("Failed to extract") || error_msg.contains("Failed to extract") ||
error_msg.contains("All PDF extraction strategies failed") error_msg.contains("All PDF extraction strategies failed") ||
error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available")
); );
} }
} }
@ -528,7 +530,9 @@ startxref
error_msg.contains("extract") || error_msg.contains("extract") ||
error_msg.contains("PDF") || error_msg.contains("PDF") ||
error_msg.contains("Failed to extract") || error_msg.contains("Failed to extract") ||
error_msg.contains("All PDF extraction strategies failed") error_msg.contains("All PDF extraction strategies failed") ||
error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available")
); );
} }
} }
@ -557,7 +561,9 @@ startxref
error_msg.contains("font") || error_msg.contains("font") ||
error_msg.contains("encoding") || error_msg.contains("encoding") ||
error_msg.contains("extract") || error_msg.contains("extract") ||
error_msg.contains("All PDF extraction strategies failed") error_msg.contains("All PDF extraction strategies failed") ||
error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available")
); );
} }
} }
@ -594,7 +600,9 @@ This tests the error handling for files that aren't actually PDFs.";
error_msg.contains("PDF") || error_msg.contains("PDF") ||
error_msg.contains("format") || error_msg.contains("format") ||
error_msg.contains("Failed to extract") || error_msg.contains("Failed to extract") ||
error_msg.contains("All PDF extraction strategies failed") error_msg.contains("All PDF extraction strategies failed") ||
error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available")
); );
} }
} }
@ -621,7 +629,9 @@ This tests the error handling for files that aren't actually PDFs.";
error_msg.contains("ocrmypdf") || error_msg.contains("ocrmypdf") ||
error_msg.contains("extraction") || error_msg.contains("extraction") ||
error_msg.contains("strategies") || error_msg.contains("strategies") ||
error_msg.contains("Failed to extract") error_msg.contains("Failed to extract") ||
error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available")
); );
} }
} }
@ -724,7 +734,8 @@ This tests the error handling for files that aren't actually PDFs.";
error_msg.contains("corrupted") || error_msg.contains("corrupted") ||
error_msg.contains("encoding") || error_msg.contains("encoding") ||
error_msg.contains("All PDF extraction strategies failed") || error_msg.contains("All PDF extraction strategies failed") ||
error_msg.contains("No such file or directory"), error_msg.contains("No such file or directory") ||
error_msg.contains("ocrmypdf is not available"),
"Error message should be descriptive for {}: {}", test_file_owned, error_msg "Error message should be descriptive for {}: {}", test_file_owned, error_msg
); );
} }