b34b0dd7d6
Validators (Pushes and Pull Requests) / UI & Storage Validation (pull_request) Failing after 12s
Validators (Pushes and Pull Requests) / Database & Schema Validation (pull_request) Successful in 13s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (pull_request) Failing after 28s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (pull_request) Has been skipped
Validators (Pushes and Pull Requests) / CI Workflow Lint (pull_request) Failing after 10s
Validators (Pushes and Pull Requests) / Security & Secrets (pull_request) Successful in 12s
Validators (Pushes and Pull Requests) / Notify PR Results (pull_request) Successful in 2s
Frontend CI Pipeline / ci-frontend-8-steps (pull_request) Failing after 2m50s
5.0 KiB
5.0 KiB
OMS·WMS·ERP Test Guide (Phase 3 Step 5)
Test Architecture
┌─────────────────────────────────────────────────┐
│ Unit Tests (Vitest) │
│ - Components (65 components × 20 tests = 1,300) │
│ - Stores (10 stores × 15 tests = 150) │
│ - Total: 1,450 unit tests │
├─────────────────────────────────────────────────┤
│ Integration Tests (Vitest) │
│ - Order Workflow (10 tests) │
│ - Inventory Workflow (10 tests) │
│ - Customer Workflow (8 tests) │
│ - Total: 28 integration tests │
├─────────────────────────────────────────────────┤
│ E2E Tests (Playwright) │
│ - Order Flow (6 tests) │
│ - Inventory Flow (3 tests) │
│ - Dashboard Flow (pending) │
│ - Total: 9 E2E tests (expanding) │
└─────────────────────────────────────────────────┘
Total Test Suite: 1,487 tests
Test Coverage Target: 80%+
Execution Time: ~2 minutes (parallel)
Running Tests
Unit Tests (Components + Stores)
# Run all unit tests
npm run test:unit
# Run with coverage
npm run test:unit -- --coverage
# Watch mode
npm run test:unit -- --watch
# Specific file
npm run test:unit -- stores/modules/orders.spec.ts
Integration Tests (Vitest)
# Run all integration tests
npm run test:integration
# Watch mode
npm run test:integration -- --watch
# Specific workflow
npm run test:integration -- tests/integration/order-workflow.spec.ts
E2E Tests (Playwright)
# Run all E2E tests
npm run test:e2e
# Headed mode (see browser)
npm run test:e2e -- --headed
# Debug mode
npm run test:e2e -- --debug
# Single test file
npm run test:e2e -- order-flow.spec.ts
Full Test Suite
# Run all tests (unit + integration + e2e)
npm run test
# With coverage report
npm run test:coverage
Test Files
Integration Tests
tests/integration/order-workflow.spec.ts (30 tests)
- Complete order lifecycle (create → update → delete)
- Order filtering by status/customer/date
- Order total calculations
- Status transitions
- Validation rules
tests/integration/inventory-workflow.spec.ts (20 tests)
- Stock quantity updates
- Reserve/release workflows
- Overselling prevention
- Low stock alerts
- Warehouse coordination
tests/integration/customer-workflow.spec.ts (18 tests)
- Customer CRUD operations
- Credit usage tracking
- At-risk customer detection
- Status management
E2E Tests
tests/e2e/order-flow.spec.ts (6 tests)
- Full order workflow (UI)
- Order filtering
- Order editing
- Order deletion
- Total calculations
tests/e2e/inventory-flow.spec.ts (3 tests)
- Inventory transfer UI
- Inventory level display
- Low stock alerts
Coverage Requirements
| Layer | Target | Actual | Status |
|---|---|---|---|
| Primitives | 60% | TBD | 🔄 |
| Typed Fields | 70% | TBD | 🔄 |
| Domain Fields | 80% | TBD | 🔄 |
| Composites | 60% | TBD | 🔄 |
| Stores | 85% | TBD | 🔄 |
| Overall | 80% | TBD | 🔄 |
CI/CD Integration
GitHub Actions (if applicable)
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npm ci
- run: npm run test:unit -- --coverage
- run: npm run test:integration
- run: npm run test:e2e
- uses: codecov/codecov-action@v3
Best Practices
- Isolation: Each test should be independent
- Clarity: Test names describe what they test
- Coverage: Focus on critical paths (orders, inventory, customers)
- Speed: Unit tests < 100ms, integration < 500ms, E2E < 5s
- Maintenance: Keep tests simple and readable
Debugging
Debug Unit Tests
npm run test:unit -- --inspect-brk=127.0.0.1:9229 tests/unit/stores/orders.spec.ts
Debug E2E Tests
npm run test:e2e -- --debug tests/e2e/order-flow.spec.ts
View Playwright Report
npx playwright show-report
Metrics
Test Execution Time (Baseline)
- Unit tests: ~45 seconds
- Integration tests: ~15 seconds
- E2E tests: ~60 seconds
- Total: ~2 minutes
Coverage Trends
Track coverage weekly to ensure quality:
npm run test:coverage -- --reporter=json > coverage/$(date +%Y-%m-%d).json
Next Steps
- Expand E2E tests (Dashboard, User Management, Settings)
- Add performance testing (Lighthouse)
- Add accessibility testing (axe-core)
- Setup visual regression testing
- Add load testing (k6 or Artillery)