Commit Graph

8 Commits

Author SHA1 Message Date
ERPAuto Bot
5d8563a4c9 docs: add P0 summary report and update README with test docs
- Add comprehensive P0 summary report (.sisyphus/evidence/p0-summary.md)
- Update README.md with test infrastructure links and examples
- Add coverage thresholds to vitest.config.ts (global 70%, core 80%)
- Document 41.5% performance improvement (7.65s → 4.49s)

Related: test-optimization-p0 task-18
2026-04-04 20:46:46 +08:00
Misaka
fb3dd43164 test: add Wave 1 infrastructure (types, mocks, vitest config) + User/Order/Material factories
- tests/fixtures/types.ts: Test fixture type definitions
- tests/fixtures/factory.ts: User/Order/Material factories
- tests/mocks/types.ts: Mock type definitions (549 lines)
- tests/mocks/index.ts: Mock factory functions
- vitest.config.ts: Performance optimizations (isolate:false, pool:threads)
- User/Order/Material factory tests (7 tests total)

Performance: 7.65s → 4.94s (35% improvement)
2026-04-04 20:15:54 +08:00
Misaka
fe02e37848 test(P0): fix critical test infrastructure issues
- Add complete Electron mock with all required APIs (getVersion, getName, etc.) - fixes 20 failing suites
- Fix Winston format mock to support chainable calls - fixes logger test errors
- Add comprehensive TypeORM mock for repository tests - fixes 4 failing tests
- Fix bootstrap-runtime test path assertions
- Update Excel parser tests to skip file I/O (moved to integration)
- Add test review report and improvement plan documentation

## Test Results:
- Failed test suites: 20 → 6 (-70%)
- Failed tests: 48 → 16 (-67%)
- Pass rate: 67% → 94% (+27%)

## Remaining (P1/P2 - not blocking):
- logger.test.ts: 11 failures (config-manager circular dependency, needs refactoring)
- manual tests: 2 failures (should be moved to integration)
- Minor assertion fixes in update-service tests

Fixes: P0 test infrastructure issues
2026-04-04 18:36:38 +08:00
Misaka
484ca31d79 test: add E2E test for Extractor workflow using Playwright
- Create tests/e2e/extractor-workflow.test.ts with full workflow tests
- Add playwright.config.ts for E2E test configuration
- Add npm scripts: test:e2e, test:e2e:ui, test:e2e:report
- Update vitest.config.ts to exclude E2E tests
2026-03-01 15:53:03 +08:00
Misaka
5760b56f70 feat: implement IPC handlers, database services and Extractor UI
- Add SqlServerService and MySqlService for database persistence
- Implement IPC handlers for file, extractor, cleaner, and database operations
- Define IPC API types and update preload script
- Create ExtractorPage UI with OrderNumberInput component
- Add unit and integration tests for MySQL and SQL Server
- Update vitest config with path aliases
2026-03-01 15:46:01 +08:00
Misaka
c39e1504aa style: apply prettier formatting
Apply consistent formatting across all files (line endings, spacing)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-01 14:57:38 +08:00
Misaka
b22f4995ba feat: implement ERP authentication, data extraction, and Excel parsing
This commit completes the core ERP automation functionality, migrating
from Python Playwright to TypeScript while maintaining full compatibility
with the original implementation.

**ERP Authentication Service (erp-auth.ts):**
- Implement login() with role-based locators for form elements
- Add SSL certificate bypass for internal VPN network
- Handle force login confirmation dialogs
- Return session with mainFrame reference for subsequent operations
- Add session lifecycle management (close, getSession, isActive)

**Data Extractor Service (extractor.ts):**
- Implement precise nested iframe navigation (#forwardFrame → #mainiframe)
- Add batch processing support for multiple order numbers
- Implement order number filling with comma separation
- Handle material selection and download workflows
- Successfully tested with 300 orders in 5 batches

**Excel Parser Service (excel-parser.ts):**
- Fix ExcelJS 1-indexed array access (row[1] for 序号, row[2] for 材料编码)
- Add dynamic table header search to handle empty row skipping
- Add field mapping: "来源单号" → "productionOrder"
- Implement saveAsExcel() method compatible with Python format
- Validate compatibility: 527 rows, 69 orders matching Python output

**Type Definitions (erp.types.ts):**
- Add headless property to ErpConfig for browser mode control
- Add mainFrame reference to ErpSession for frame reuse

**Integration Tests (extractor.test.ts):**
- Modify tests to use independent auth services for isolation
- Add test with 300 orders and batch size 70
- All tests passing with real ERP data

**Test Configuration (vitest.config.ts):**
- Add setupFiles configuration for environment variable loading

**Testing Results:**
-  Successfully logs in to ERP system
-  Processes 300 orders in 5 batches (43.59 seconds)
-  Downloads 5 Excel files (347.62 KB total)
-  Parses 2,131 material plans from 280 unique orders
-  Excel output matches Python format exactly

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-01 14:22:14 +08:00
Misaka
9ac8707921 feat: configure Vitest testing framework
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-01 12:12:33 +08:00