Skip to content

A fast, helpful, and open-source document parser

test: add screenshot integration tests for conversion paths

AdemBoukhris457cb2f2effb461
diff --git a/crates/liteparse/tests/integration_test.rs b/crates/liteparse/tests/integration_test.rs
index 50a2702..a05a558 100644
--- a/crates/liteparse/tests/integration_test.rs
+++ b/crates/liteparse/tests/integration_test.rs
@@ -5,6 +5,52 @@ use liteparse::types::PdfInput;
use liteparse::{LiteParse, LiteParseConfig};
use serial_test::serial;
+#[tokio::test]
+#[serial]
+async fn test_screenshot_image_integration() {
+ let env_var = std::env::var("SKIP_INTEGRATION_TESTS");
+ if let Ok(v) = env_var
+ && v == "yes"
+ {
+ return;
+ }
+ let lit = LiteParse::new(LiteParseConfig::default());
+ let results = lit
+ .screenshot("../../integration_tests_data/receipt.png", None)
+ .await
+ .expect("Should be able to screenshot converted image");
+ assert_eq!(results.len(), 1);
+ assert!(results[0].width > 0);
+ assert!(results[0].height > 0);
+ assert!(!results[0].image_bytes.is_empty());
+}
+
+#[tokio::test]
+#[serial]
+async fn test_screenshot_pdf_integration() {
+ let lit = LiteParse::new(LiteParseConfig::default());
+ let results = lit
+ .screenshot("../../integration_tests_data/sample.pdf", None)
+ .await
+ .expect("Should be able to screenshot PDF");
+ assert_eq!(results.len(), 1);
+ assert!(!results[0].image_bytes.is_empty());
+}
+
+#[tokio::test]
+async fn test_screenshot_rejects_text_file() {
+ let dir = tempfile::tempdir().unwrap();
+ let txt_path = dir.path().join("notes.txt");
+ std::fs::write(&txt_path, "hello").unwrap();
+ let lit = LiteParse::new(LiteParseConfig::default());
+ let err = lit
+ .screenshot(txt_path.to_str().unwrap(), None)
+ .await
+ .unwrap_err()
+ .to_string();
+ assert!(err.contains("Cannot screenshot text-based format"));
+}
+
#[tokio::test]
#[serial]
async fn test_convert_data_to_pdf_integration() {