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>
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { Factory } from 'fishery';
|
|
import { faker } from '@faker-js/faker';
|
|
import { ParsedNode } from '../../src/parsers/node-parser';
|
|
|
|
/**
|
|
* Factory for generating ParsedNode test data using Fishery.
|
|
* Creates realistic node configurations with random but valid data.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* // Create a single node with defaults
|
|
* const node = NodeFactory.build();
|
|
*
|
|
* // Create a node with specific properties
|
|
* const slackNode = NodeFactory.build({
|
|
* nodeType: 'nodes-base.slack',
|
|
* displayName: 'Slack',
|
|
* isAITool: true
|
|
* });
|
|
*
|
|
* // Create multiple nodes
|
|
* const nodes = NodeFactory.buildList(5);
|
|
*
|
|
* // Create with custom sequence
|
|
* const sequencedNodes = NodeFactory.buildList(3, {
|
|
* displayName: (i) => `Node ${i}`
|
|
* });
|
|
* ```
|
|
*/
|
|
export const NodeFactory = Factory.define<ParsedNode>(() => ({
|
|
nodeType: faker.helpers.arrayElement(['nodes-base.', 'nodes-langchain.']) + faker.word.noun(),
|
|
displayName: faker.helpers.arrayElement(['HTTP', 'Slack', 'Google', 'AWS']) + ' ' + faker.word.noun(),
|
|
description: faker.lorem.sentence(),
|
|
packageName: faker.helpers.arrayElement(['n8n-nodes-base', '@n8n/n8n-nodes-langchain']),
|
|
category: faker.helpers.arrayElement(['transform', 'trigger', 'output', 'input']),
|
|
style: faker.helpers.arrayElement(['declarative', 'programmatic']),
|
|
isAITool: faker.datatype.boolean(),
|
|
isTrigger: faker.datatype.boolean(),
|
|
isWebhook: faker.datatype.boolean(),
|
|
isVersioned: faker.datatype.boolean(),
|
|
version: faker.helpers.arrayElement(['1.0', '2.0', '3.0', '4.2']),
|
|
documentation: faker.datatype.boolean() ? faker.lorem.paragraphs(3) : undefined,
|
|
properties: [],
|
|
operations: [],
|
|
credentials: []
|
|
})); |