test: implement comprehensive testing improvements from PR #104 review

Major improvements based on comprehensive test suite review:

Test Fixes:
- Fix all 78 failing tests across logger, MSW, and validator tests
- Fix console spy management in logger tests with proper DEBUG env handling
- Fix MSW test environment restoration in session-management.test.ts
- Fix workflow validator tests by adding proper node connections
- Fix mock setup issues in edge case tests

Test Organization:
- Split large config-validator.test.ts (1,075 lines) into 4 focused files
- Rename 63+ tests to follow "should X when Y" naming convention
- Add comprehensive edge case test files for all major validators
- Create tests/README.md with testing guidelines and best practices

New Features:
- Add ConfigValidator.validateBatch() method for bulk validation
- Add edge case coverage for null/undefined, boundaries, invalid data
- Add CI-aware performance test timeouts
- Add JSDoc comments to test utilities and factories
- Add workflow duplicate node name validation tests

Results:
- All tests passing: 1,356 passed, 19 skipped
- Test coverage: 85.34% statements, 85.3% branches
- From 78 failures to 0 failures

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-30 13:44:35 +02:00
parent bd208e71f8
commit 6699a1d34c
30 changed files with 4688 additions and 1237 deletions

View File

@@ -12,7 +12,7 @@ vi.mock('../../../src/utils/logger', () => ({
describe('Database Adapter - Unit Tests', () => {
describe('DatabaseAdapter Interface', () => {
it('should define the correct interface', () => {
it('should define interface when adapter is created', () => {
// This is a type test - ensuring the interface is correctly defined
type DatabaseAdapter = {
prepare: (sql: string) => any;
@@ -46,7 +46,7 @@ describe('Database Adapter - Unit Tests', () => {
});
describe('PreparedStatement Interface', () => {
it('should define the correct interface', () => {
it('should define interface when statement is prepared', () => {
// Type test for PreparedStatement
type PreparedStatement = {
run: (...params: any[]) => { changes: number; lastInsertRowid: number | bigint };
@@ -86,7 +86,7 @@ describe('Database Adapter - Unit Tests', () => {
});
describe('FTS5 Support Detection', () => {
it('should detect FTS5 support correctly', () => {
it('should detect support when FTS5 module is available', () => {
const mockDb = {
exec: vi.fn()
};
@@ -118,7 +118,7 @@ describe('Database Adapter - Unit Tests', () => {
});
describe('Transaction Handling', () => {
it('should handle transactions correctly', () => {
it('should handle commit and rollback when transaction is executed', () => {
// Test transaction wrapper logic
const mockDb = {
exec: vi.fn(),
@@ -164,7 +164,7 @@ describe('Database Adapter - Unit Tests', () => {
});
describe('Pragma Handling', () => {
it('should handle pragma commands', () => {
it('should return values when pragma commands are executed', () => {
const mockDb = {
pragma: vi.fn((key: string, value?: any) => {
if (key === 'journal_mode' && value === 'WAL') {