test: Phase 2 - Create test infrastructure

- Create comprehensive test directory structure
- Implement better-sqlite3 mock for Vitest
- Add node factory using fishery for test data generation
- Create workflow builder with fluent API
- Add infrastructure validation tests
- Update testing checklist to reflect progress

All Phase 2 tasks completed successfully with 7 tests passing.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-28 13:21:56 +02:00
parent aa3b2a8460
commit 17013d8a25
7 changed files with 893 additions and 7 deletions

121
tests/fixtures/factories/node.factory.ts vendored Normal file
View File

@@ -0,0 +1,121 @@
import { Factory } from 'fishery';
import { faker } from '@faker-js/faker';
interface NodeDefinition {
name: string;
displayName: string;
description: string;
version: number;
defaults: { name: string };
inputs: string[];
outputs: string[];
properties: any[];
credentials?: any[];
group?: string[];
}
export const nodeFactory = Factory.define<NodeDefinition>(() => ({
name: faker.helpers.slugify(faker.word.noun()),
displayName: faker.company.name(),
description: faker.lorem.sentence(),
version: faker.number.int({ min: 1, max: 5 }),
defaults: {
name: faker.word.noun()
},
inputs: ['main'],
outputs: ['main'],
group: [faker.helpers.arrayElement(['transform', 'trigger', 'output'])],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
default: 'user',
options: [
{ name: 'User', value: 'user' },
{ name: 'Post', value: 'post' }
]
}
],
credentials: []
}));
// Specific node factories
export const webhookNodeFactory = nodeFactory.params({
name: 'webhook',
displayName: 'Webhook',
description: 'Starts the workflow when a webhook is called',
group: ['trigger'],
properties: [
{
displayName: 'Path',
name: 'path',
type: 'string',
default: 'webhook',
required: true
},
{
displayName: 'Method',
name: 'method',
type: 'options',
default: 'GET',
options: [
{ name: 'GET', value: 'GET' },
{ name: 'POST', value: 'POST' }
]
}
]
});
export const slackNodeFactory = nodeFactory.params({
name: 'slack',
displayName: 'Slack',
description: 'Send messages to Slack',
group: ['output'],
credentials: [
{
name: 'slackApi',
required: true
}
],
properties: [
{
displayName: 'Resource',
name: 'resource',
type: 'options',
default: 'message',
options: [
{ name: 'Message', value: 'message' },
{ name: 'Channel', value: 'channel' }
]
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: ['message']
}
},
default: 'post',
options: [
{ name: 'Post', value: 'post' },
{ name: 'Update', value: 'update' }
]
},
{
displayName: 'Channel',
name: 'channel',
type: 'string',
required: true,
displayOptions: {
show: {
resource: ['message'],
operation: ['post']
}
},
default: ''
}
]
});