4 Commits

Author SHA1 Message Date
Misaka
abad61758c refactor(audit): type-safe enums, expanded coverage, and crash-safe logging
Replace magic strings with AuditAction/AuditStatus enums across all consumers,
add logAuditWithCurrentUser() convenience wrapper, extend audit coverage to
data import, result export, app update, and ERP credentials operations, and
harden crash handlers with try/catch to prevent audit failures from cascading.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 17:40:30 +08:00
Misaka
4150a13175 fix(test): improve test isolation and reduce noise in unit tests
- Add logger/error-utils mocks to cleaner-handler test to suppress IPC error log noise
- Move setupServiceMocks into beforeEach for consistent default mocking in cleaner tests
- Replace vi.waitFor (2s timeout) with setImmediate microtask flush in extractor test
- Remove dead activeType assignments in validation-database test
- Align TestUser.id type with UserInfo.id (string → number) and use deterministic counter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-05 21:38:20 +08:00
Misaka
7473f34485 test: complete Wave 2 - all entity factories + documentation
- tests/fixtures/factory.ts: Config/Database + 6 additional factories (547 lines total)
  - UserFactory (3 methods: createAdmin, createUserDefault, createGuest)
  - OrderFactory (2 methods: createOrder, createOrders)
  - MaterialFactory (2 methods: createMaterial, createMaterials)
  - ConfigFactory (1 method: createErpConfig)
  - DatabaseFactory (1 method: createDatabaseConfig)
  - ExtractResultFactory (2 methods)
  - CleanerResultFactory (2 methods)
  - AuditLogFactory (1 method)
  - UpdateReleaseFactory (1 method)
  - ProductionInputFactory (1 method)
  - ValidationErrorFactory (1 method)
  Total: 17 factory methods across 10 factory classes

- Test coverage:
  - user-factory.test.ts: 3 tests
  - order-material-factory.test.ts: 4 tests
  - config-factory.test.ts: 5 tests
  - other-factories.test.ts: 15 tests
  Total: 27 factory tests

- docs/TEST_FACTORY_USAGE.md: User guide with examples (152 lines)

All factories support overrides customization and follow the <=100 lines per factory constraint.
2026-04-04 20:23:45 +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