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

@@ -1,6 +1,10 @@
import { Factory } from 'fishery';
import { faker } from '@faker-js/faker';
/**
* Interface for n8n node property definitions.
* Represents the structure of properties that configure node behavior.
*/
interface PropertyDefinition {
name: string;
displayName: string;
@@ -11,6 +15,37 @@ interface PropertyDefinition {
options?: any[];
}
/**
* Factory for generating PropertyDefinition test data.
* Creates realistic property configurations for testing node validation and processing.
*
* @example
* ```typescript
* // Create a single property
* const prop = PropertyDefinitionFactory.build();
*
* // Create a required string property
* const urlProp = PropertyDefinitionFactory.build({
* name: 'url',
* displayName: 'URL',
* type: 'string',
* required: true
* });
*
* // Create an options property with choices
* const methodProp = PropertyDefinitionFactory.build({
* name: 'method',
* type: 'options',
* options: [
* { name: 'GET', value: 'GET' },
* { name: 'POST', value: 'POST' }
* ]
* });
*
* // Create multiple properties for a node
* const nodeProperties = PropertyDefinitionFactory.buildList(5);
* ```
*/
export const PropertyDefinitionFactory = Factory.define<PropertyDefinition>(() => ({
name: faker.word.noun() + faker.word.adjective().charAt(0).toUpperCase() + faker.word.adjective().slice(1),
displayName: faker.helpers.arrayElement(['URL', 'Method', 'Headers', 'Body', 'Authentication']),