mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-09-19 09:59:22 +00:00

🔄 Dynamic Processing Strategies - Adaptive routing: Same tool uses different backend endpoints based on file analysis - Combined vs separate processing: Intelligently chooses between merge operations and individual file processing - Cross-format workflows: Enable complex conversions like "mixed files → PDF" that other tools can't handle ⚙️ Format-Specific Intelligence Each conversion type gets tailored options: - HTML/ZIP → PDF: Zoom controls (0.1-3.0 increments) with live preview - Email → PDF: Attachment handling, size limits, recipient control - PDF → PDF/A: Digital signature detection with warnings - Images → PDF: Smart combining vs individual file options File Architecture Core Implementation: ├── Convert.tsx # Main stepped workflow UI ├── ConvertSettings.tsx # Centralized settings with smart detection ├── GroupedFormatDropdown.tsx # Enhanced format selector with grouping ├── useConvertParameters.ts # Smart detection & parameter management ├── useConvertOperation.ts # Multi-strategy processing logic └── Settings Components: ├── ConvertFromWebSettings.tsx # HTML zoom controls ├── ConvertFromEmailSettings.tsx # Email attachment options ├── ConvertToPdfaSettings.tsx # PDF/A with signature detection ├── ConvertFromImageSettings.tsx # Image PDF options └── ConvertToImageSettings.tsx # PDF to image options Utility Layer Utils & Services: ├── convertUtils.ts # Format detection & endpoint routing ├── fileResponseUtils.ts # Generic API response handling └── setupTests.ts # Enhanced test environment with crypto mocks Testing & Quality Comprehensive Test Coverage Test Suite: ├── useConvertParameters.test.ts # Parameter logic & smart detection ├── useConvertParametersAutoDetection.test.ts # File type analysis ├── ConvertIntegration.test.tsx # End-to-end conversion workflows ├── ConvertSmartDetectionIntegration.test.tsx # Mixed file scenarios ├── ConvertE2E.spec.ts # Playwright browser tests ├── convertUtils.test.ts # Utility function validation └── fileResponseUtils.test.ts # API response handling Advanced Test Features - Crypto API mocking: Proper test environment for file hashing - File.arrayBuffer() polyfills: Complete browser API simulation - Multi-file scenario testing: Complex batch processing validation - CI/CD integration: Vitest runs in GitHub Actions with proper artifacts --------- Co-authored-by: Connor Yoh <connor@stirlingpdf.com> Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
Test Fixtures for Convert Tool Testing
This directory contains sample files for testing the convert tool functionality.
Required Test Files
To run the full test suite, please add the following test files to this directory:
1. sample.pdf
- A small PDF document (1-2 pages)
- Should contain text and ideally a simple table for CSV conversion testing
- Should be under 1MB for fast testing
2. sample.docx
- A Microsoft Word document with basic formatting
- Should contain headers, paragraphs, and possibly a table
- Should be under 500KB
3. sample.png
- A small PNG image (e.g., 500x500 pixels)
- Should be a real image, not just a test pattern
- Should be under 100KB
3b. sample.jpg
- A small JPG image (same image as PNG, different format)
- Should be under 100KB
- Can be created by converting sample.png to JPG
4. sample.md
- A Markdown file with various formatting elements:
# Test Document This is a **test** markdown file. ## Features - Lists - **Bold text** - *Italic text* - [Links](https://example.com) ### Code Block ```javascript console.log('Hello, world!');
Column 1 Column 2 Data 1 Data 2
5. sample.eml (Optional)
- An email file with headers and body
- Can be exported from any email client
- Should contain some attachments for testing
6. sample.html (Optional)
- A simple HTML file with various elements
- Should include text, headings, and basic styling
File Creation Tips
Creating a test PDF:
- Create a document in LibreOffice Writer or Google Docs
- Add some text, headers, and a simple table
- Export/Save as PDF
Creating a test DOCX:
- Create a document in Microsoft Word or LibreOffice Writer
- Add formatted content (headers, bold, italic, lists)
- Save as DOCX format
Creating a test PNG:
- Use any image editor or screenshot tool
- Create a simple image with text or shapes
- Save as PNG format
Creating a test EML:
- In your email client, save an email as .eml format
- Or create manually with proper headers:
From: test@example.com To: recipient@example.com Subject: Test Email Date: Mon, 1 Jan 2024 12:00:00 +0000 This is a test email for conversion testing.
Test File Structure
frontend/src/tests/test-fixtures/
├── README.md (this file)
├── sample.pdf
├── sample.docx
├── sample.png
├── sample.jpg
├── sample.md
├── sample.eml (optional)
└── sample.html (optional)
Usage in Tests
These files are referenced in the test files:
ConvertE2E.spec.ts
- Uses all files for E2E testingConvertIntegration.test.ts
- Uses files for integration testing- Manual testing scenarios
Security Note
These are test files only and should not contain any sensitive information. They will be committed to the repository and used in automated testing.
File Size Guidelines
- Keep test files small for fast CI/CD pipelines and frontend testing
- PDF files: < 1MB (preferably 100-500KB)
- Image files: < 100KB
- Text files: < 50KB
- Focus on frontend functionality, not backend performance
Maintenance
When updating the convert tool with new formats:
- Add corresponding test files to this directory
- Update the test files list above
- Update the test cases to include the new formats