//! Integration test: import a real Excel (.xls) file into the spreadsheet engine. use spreadsheet_engine::import_workbook_from_path; /// This test reads the real "Old_Mutual_Finance_Budget_Tool.xls" file /// from the repository's `ui/` directory and verifies that the import /// produces sheets with cell data. #[test] fn import_old_mutual_budget_tool_xls() { let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) .ancestors() .nth(4) .unwrap() .join("ui/Old_Mutual_Finance_Budget_Tool.xls"); if !path.exists() { eprintln!("Skipping: {} not found", path.display()); return; } let result = import_workbook_from_path(&path); assert!(result.is_ok(), "Import should succeed: {:?}", result.err()); let (sheets, active) = result.unwrap(); assert!(!sheets.is_empty(), "Should have at least one sheet"); assert_eq!(active, 0, "Active sheet should be index 0"); // The first sheet should be named "monthly budget planner". assert_eq!(sheets[0].name, "monthly budget planner"); // Verify there is at least some cell content. let mut has_cells = false; for sheet in &sheets { for (_id, cell) in &sheet.data.cells { if !cell.value.is_empty() { has_cells = true; break; } } if has_cells { break; } } assert!(has_cells, "Imported workbook should have cell data"); }