@auto-engineer/pipeline 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +7 -7
- package/.turbo/turbo-type-check.log +1 -1
- package/CHANGELOG.md +15 -0
- package/dist/src/builder/define.specs.d.ts +2 -0
- package/dist/src/builder/define.specs.d.ts.map +1 -0
- package/dist/src/builder/define.specs.js +435 -0
- package/dist/src/builder/define.specs.js.map +1 -0
- package/dist/src/core/descriptors.specs.d.ts +2 -0
- package/dist/src/core/descriptors.specs.d.ts.map +1 -0
- package/dist/src/core/descriptors.specs.js +24 -0
- package/dist/src/core/descriptors.specs.js.map +1 -0
- package/dist/src/core/types.specs.d.ts +2 -0
- package/dist/src/core/types.specs.d.ts.map +1 -0
- package/dist/src/core/types.specs.js +40 -0
- package/dist/src/core/types.specs.js.map +1 -0
- package/dist/src/graph/filter-graph.specs.d.ts +2 -0
- package/dist/src/graph/filter-graph.specs.d.ts.map +1 -0
- package/dist/src/graph/filter-graph.specs.js +204 -0
- package/dist/src/graph/filter-graph.specs.js.map +1 -0
- package/dist/src/graph/types.specs.d.ts +2 -0
- package/dist/src/graph/types.specs.d.ts.map +1 -0
- package/dist/src/graph/types.specs.js +148 -0
- package/dist/src/graph/types.specs.js.map +1 -0
- package/dist/src/logging/event-logger.specs.d.ts +2 -0
- package/dist/src/logging/event-logger.specs.d.ts.map +1 -0
- package/dist/src/logging/event-logger.specs.js +81 -0
- package/dist/src/logging/event-logger.specs.js.map +1 -0
- package/dist/src/plugins/handler-adapter.specs.d.ts +2 -0
- package/dist/src/plugins/handler-adapter.specs.d.ts.map +1 -0
- package/dist/src/plugins/handler-adapter.specs.js +129 -0
- package/dist/src/plugins/handler-adapter.specs.js.map +1 -0
- package/dist/src/plugins/plugin-loader.specs.d.ts +2 -0
- package/dist/src/plugins/plugin-loader.specs.d.ts.map +1 -0
- package/dist/src/plugins/plugin-loader.specs.js +246 -0
- package/dist/src/plugins/plugin-loader.specs.js.map +1 -0
- package/dist/src/projections/item-status-projection.specs.d.ts +2 -0
- package/dist/src/projections/item-status-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/item-status-projection.specs.js +119 -0
- package/dist/src/projections/item-status-projection.specs.js.map +1 -0
- package/dist/src/projections/latest-run-projection.specs.d.ts +2 -0
- package/dist/src/projections/latest-run-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/latest-run-projection.specs.js +33 -0
- package/dist/src/projections/latest-run-projection.specs.js.map +1 -0
- package/dist/src/projections/message-log-projection.specs.d.ts +2 -0
- package/dist/src/projections/message-log-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/message-log-projection.specs.js +101 -0
- package/dist/src/projections/message-log-projection.specs.js.map +1 -0
- package/dist/src/projections/node-status-projection.specs.d.ts +2 -0
- package/dist/src/projections/node-status-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/node-status-projection.specs.js +116 -0
- package/dist/src/projections/node-status-projection.specs.js.map +1 -0
- package/dist/src/projections/phased-execution-projection.specs.d.ts +2 -0
- package/dist/src/projections/phased-execution-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/phased-execution-projection.specs.js +171 -0
- package/dist/src/projections/phased-execution-projection.specs.js.map +1 -0
- package/dist/src/projections/settled-instance-projection.specs.d.ts +2 -0
- package/dist/src/projections/settled-instance-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/settled-instance-projection.specs.js +217 -0
- package/dist/src/projections/settled-instance-projection.specs.js.map +1 -0
- package/dist/src/projections/stats-projection.specs.d.ts +2 -0
- package/dist/src/projections/stats-projection.specs.d.ts.map +1 -0
- package/dist/src/projections/stats-projection.specs.js +91 -0
- package/dist/src/projections/stats-projection.specs.js.map +1 -0
- package/dist/src/runtime/await-tracker.specs.d.ts +2 -0
- package/dist/src/runtime/await-tracker.specs.d.ts.map +1 -0
- package/dist/src/runtime/await-tracker.specs.js +64 -0
- package/dist/src/runtime/await-tracker.specs.js.map +1 -0
- package/dist/src/runtime/context.specs.d.ts +2 -0
- package/dist/src/runtime/context.specs.d.ts.map +1 -0
- package/dist/src/runtime/context.specs.js +26 -0
- package/dist/src/runtime/context.specs.js.map +1 -0
- package/dist/src/runtime/event-command-map.specs.d.ts +2 -0
- package/dist/src/runtime/event-command-map.specs.d.ts.map +1 -0
- package/dist/src/runtime/event-command-map.specs.js +108 -0
- package/dist/src/runtime/event-command-map.specs.js.map +1 -0
- package/dist/src/runtime/phased-executor.specs.d.ts +2 -0
- package/dist/src/runtime/phased-executor.specs.d.ts.map +1 -0
- package/dist/src/runtime/phased-executor.specs.js +418 -0
- package/dist/src/runtime/phased-executor.specs.js.map +1 -0
- package/dist/src/runtime/pipeline-runtime.specs.d.ts +2 -0
- package/dist/src/runtime/pipeline-runtime.specs.d.ts.map +1 -0
- package/dist/src/runtime/pipeline-runtime.specs.js +227 -0
- package/dist/src/runtime/pipeline-runtime.specs.js.map +1 -0
- package/dist/src/runtime/settled-tracker.specs.d.ts +2 -0
- package/dist/src/runtime/settled-tracker.specs.d.ts.map +1 -0
- package/dist/src/runtime/settled-tracker.specs.js +811 -0
- package/dist/src/runtime/settled-tracker.specs.js.map +1 -0
- package/dist/src/server/full-orchestration.e2e.specs.d.ts +2 -0
- package/dist/src/server/full-orchestration.e2e.specs.d.ts.map +1 -0
- package/dist/src/server/full-orchestration.e2e.specs.js +561 -0
- package/dist/src/server/full-orchestration.e2e.specs.js.map +1 -0
- package/dist/src/server/pipeline-server.e2e.specs.d.ts +2 -0
- package/dist/src/server/pipeline-server.e2e.specs.d.ts.map +1 -0
- package/dist/src/server/pipeline-server.e2e.specs.js +373 -0
- package/dist/src/server/pipeline-server.e2e.specs.js.map +1 -0
- package/dist/src/server/pipeline-server.specs.d.ts +2 -0
- package/dist/src/server/pipeline-server.specs.d.ts.map +1 -0
- package/dist/src/server/pipeline-server.specs.js +1407 -0
- package/dist/src/server/pipeline-server.specs.js.map +1 -0
- package/dist/src/server/sse-manager.specs.d.ts +2 -0
- package/dist/src/server/sse-manager.specs.d.ts.map +1 -0
- package/dist/src/server/sse-manager.specs.js +178 -0
- package/dist/src/server/sse-manager.specs.js.map +1 -0
- package/dist/src/store/pipeline-event-store.specs.d.ts +2 -0
- package/dist/src/store/pipeline-event-store.specs.d.ts.map +1 -0
- package/dist/src/store/pipeline-event-store.specs.js +287 -0
- package/dist/src/store/pipeline-event-store.specs.js.map +1 -0
- package/dist/src/store/pipeline-read-model.specs.d.ts +2 -0
- package/dist/src/store/pipeline-read-model.specs.d.ts.map +1 -0
- package/dist/src/store/pipeline-read-model.specs.js +830 -0
- package/dist/src/store/pipeline-read-model.specs.js.map +1 -0
- package/dist/src/testing/event-capture.specs.d.ts +2 -0
- package/dist/src/testing/event-capture.specs.d.ts.map +1 -0
- package/dist/src/testing/event-capture.specs.js +114 -0
- package/dist/src/testing/event-capture.specs.js.map +1 -0
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts +2 -0
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.d.ts.map +1 -0
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js +263 -0
- package/dist/src/testing/fixtures/kanban-full.pipeline.specs.js.map +1 -0
- package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts +2 -0
- package/dist/src/testing/fixtures/kanban.pipeline.specs.d.ts.map +1 -0
- package/dist/src/testing/fixtures/kanban.pipeline.specs.js +29 -0
- package/dist/src/testing/fixtures/kanban.pipeline.specs.js.map +1 -0
- package/dist/src/testing/kanban-todo.e2e.specs.d.ts +2 -0
- package/dist/src/testing/kanban-todo.e2e.specs.d.ts.map +1 -0
- package/dist/src/testing/kanban-todo.e2e.specs.js +160 -0
- package/dist/src/testing/kanban-todo.e2e.specs.js.map +1 -0
- package/dist/src/testing/mock-handlers.specs.d.ts +2 -0
- package/dist/src/testing/mock-handlers.specs.d.ts.map +1 -0
- package/dist/src/testing/mock-handlers.specs.js +193 -0
- package/dist/src/testing/mock-handlers.specs.js.map +1 -0
- package/dist/src/testing/real-execution.e2e.specs.d.ts +2 -0
- package/dist/src/testing/real-execution.e2e.specs.d.ts.map +1 -0
- package/dist/src/testing/real-execution.e2e.specs.js +140 -0
- package/dist/src/testing/real-execution.e2e.specs.js.map +1 -0
- package/dist/src/testing/real-plugin.e2e.specs.d.ts +2 -0
- package/dist/src/testing/real-plugin.e2e.specs.d.ts.map +1 -0
- package/dist/src/testing/real-plugin.e2e.specs.js +65 -0
- package/dist/src/testing/real-plugin.e2e.specs.js.map +1 -0
- package/dist/src/testing/server-startup.e2e.specs.d.ts +2 -0
- package/dist/src/testing/server-startup.e2e.specs.d.ts.map +1 -0
- package/dist/src/testing/server-startup.e2e.specs.js +104 -0
- package/dist/src/testing/server-startup.e2e.specs.js.map +1 -0
- package/dist/src/testing/snapshot-compare.specs.d.ts +2 -0
- package/dist/src/testing/snapshot-compare.specs.d.ts.map +1 -0
- package/dist/src/testing/snapshot-compare.specs.js +112 -0
- package/dist/src/testing/snapshot-compare.specs.js.map +1 -0
- package/dist/src/testing/snapshot-sanitize.specs.d.ts +2 -0
- package/dist/src/testing/snapshot-sanitize.specs.d.ts.map +1 -0
- package/dist/src/testing/snapshot-sanitize.specs.js +104 -0
- package/dist/src/testing/snapshot-sanitize.specs.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +15 -14
- package/LICENSE +0 -10
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { loadPipelineConfig } from '../config/pipeline-config.js';
|
|
6
|
+
import { PipelineServer } from '../server/pipeline-server.js';
|
|
7
|
+
import { EventCapture } from './event-capture.js';
|
|
8
|
+
import { resetKanbanState } from './fixtures/kanban-full.pipeline.js';
|
|
9
|
+
import kanbanTodoConfig from './fixtures/kanban-todo.config.js';
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const PACKAGES_DIR = path.resolve(__dirname, '../../..');
|
|
12
|
+
const CLI_SNAPSHOTS_DIR = path.join(PACKAGES_DIR, 'cli/src/__tests__/e2e/__snapshots__/kanban-todo');
|
|
13
|
+
function loadCliSnapshot(filename) {
|
|
14
|
+
const snapshotPath = path.join(CLI_SNAPSHOTS_DIR, filename);
|
|
15
|
+
if (!existsSync(snapshotPath)) {
|
|
16
|
+
console.log(`Snapshot not found: ${snapshotPath}`);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const content = readFileSync(snapshotPath, 'utf-8');
|
|
20
|
+
return JSON.parse(content);
|
|
21
|
+
}
|
|
22
|
+
describe('Kanban-Todo Pipeline E2E Comparison', () => {
|
|
23
|
+
let server;
|
|
24
|
+
let eventCapture;
|
|
25
|
+
beforeAll(async () => {
|
|
26
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
27
|
+
server = new PipelineServer({ port: 0 });
|
|
28
|
+
server.registerCommandHandlers(loaded.handlers);
|
|
29
|
+
server.registerPipeline(loaded.pipeline);
|
|
30
|
+
await server.start();
|
|
31
|
+
eventCapture = new EventCapture();
|
|
32
|
+
}, 30000);
|
|
33
|
+
afterAll(async () => {
|
|
34
|
+
await server.stop();
|
|
35
|
+
});
|
|
36
|
+
beforeEach(() => {
|
|
37
|
+
resetKanbanState();
|
|
38
|
+
eventCapture.clear();
|
|
39
|
+
});
|
|
40
|
+
describe('Registry Comparison', () => {
|
|
41
|
+
it('should have matching command handlers', async () => {
|
|
42
|
+
const response = await fetch(`http://localhost:${server.port}/registry`);
|
|
43
|
+
const registry = (await response.json());
|
|
44
|
+
const cliRegistry = loadCliSnapshot('registry.snapshot.json');
|
|
45
|
+
console.log('=== Pipeline Registry ===');
|
|
46
|
+
console.log('Command handlers:', registry.commandHandlers.sort().join(', '));
|
|
47
|
+
if (cliRegistry !== null) {
|
|
48
|
+
console.log('\n=== CLI Registry ===');
|
|
49
|
+
console.log('Command handlers:', cliRegistry.commandHandlers.sort().join(', '));
|
|
50
|
+
const pipelineCommands = new Set(registry.commandHandlers);
|
|
51
|
+
const cliCommands = new Set(cliRegistry.commandHandlers);
|
|
52
|
+
const missingInPipeline = cliRegistry.commandHandlers.filter((c) => !pipelineCommands.has(c));
|
|
53
|
+
const extraInPipeline = registry.commandHandlers.filter((c) => !cliCommands.has(c));
|
|
54
|
+
console.log('\n=== Differences ===');
|
|
55
|
+
console.log('Missing in pipeline:', missingInPipeline.join(', ') || 'none');
|
|
56
|
+
console.log('Extra in pipeline:', extraInPipeline.join(', ') || 'none');
|
|
57
|
+
expect(missingInPipeline.length).toBeLessThanOrEqual(3);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
expect(registry.commandHandlers.length).toBeGreaterThan(10);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
it('should have matching event handlers', async () => {
|
|
64
|
+
const response = await fetch(`http://localhost:${server.port}/registry`);
|
|
65
|
+
const registry = (await response.json());
|
|
66
|
+
const cliRegistry = loadCliSnapshot('registry.snapshot.json');
|
|
67
|
+
console.log('=== Pipeline Event Handlers ===');
|
|
68
|
+
console.log(registry.eventHandlers.sort().join(', '));
|
|
69
|
+
if (cliRegistry !== null) {
|
|
70
|
+
console.log('\n=== CLI Event Handlers ===');
|
|
71
|
+
console.log(cliRegistry.eventHandlers.sort().join(', '));
|
|
72
|
+
const pipelineEvents = new Set(registry.eventHandlers);
|
|
73
|
+
const cliEvents = new Set(cliRegistry.eventHandlers);
|
|
74
|
+
const missingInPipeline = cliRegistry.eventHandlers.filter((e) => !pipelineEvents.has(e));
|
|
75
|
+
const extraInPipeline = registry.eventHandlers.filter((e) => !cliEvents.has(e));
|
|
76
|
+
console.log('\n=== Differences ===');
|
|
77
|
+
console.log('Missing in pipeline:', missingInPipeline.join(', ') || 'none');
|
|
78
|
+
console.log('Extra in pipeline:', extraInPipeline.join(', ') || 'none');
|
|
79
|
+
}
|
|
80
|
+
expect(registry.eventHandlers.length).toBeGreaterThan(0);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe('Pipeline Graph Comparison', () => {
|
|
84
|
+
it('should have similar edge structure to CLI', async () => {
|
|
85
|
+
const response = await fetch(`http://localhost:${server.port}/pipeline`);
|
|
86
|
+
const graph = (await response.json());
|
|
87
|
+
const cliGraph = loadCliSnapshot('pipeline-graph.snapshot.json');
|
|
88
|
+
console.log('=== Pipeline Graph ===');
|
|
89
|
+
console.log(`Nodes: ${graph.nodes.length}`);
|
|
90
|
+
console.log(`Edges: ${graph.edges.length}`);
|
|
91
|
+
if (cliGraph !== null) {
|
|
92
|
+
console.log('\n=== CLI Graph ===');
|
|
93
|
+
console.log(`Nodes: ${cliGraph.nodes.length}`);
|
|
94
|
+
console.log(`Edges: ${cliGraph.edges.length}`);
|
|
95
|
+
console.log('\n=== CLI Edges (by command name) ===');
|
|
96
|
+
cliGraph.edges.forEach((e) => {
|
|
97
|
+
const fromNode = cliGraph.nodes.find((n) => n.id === e.from);
|
|
98
|
+
const toNode = cliGraph.nodes.find((n) => n.id === e.to);
|
|
99
|
+
console.log(` ${fromNode?.name ?? e.from} → ${toNode?.name ?? e.to}`);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
console.log('\n=== Pipeline Edges ===');
|
|
103
|
+
graph.edges.forEach((e) => console.log(` ${e.from} → ${e.to}`));
|
|
104
|
+
expect(graph.edges.length).toBeGreaterThan(5);
|
|
105
|
+
});
|
|
106
|
+
it('should have commandToEvents mapping', async () => {
|
|
107
|
+
const response = await fetch(`http://localhost:${server.port}/pipeline`);
|
|
108
|
+
const graph = (await response.json());
|
|
109
|
+
const cliGraph = loadCliSnapshot('pipeline-graph.snapshot.json');
|
|
110
|
+
console.log('=== Pipeline commandToEvents ===');
|
|
111
|
+
Object.entries(graph.commandToEvents).forEach(([cmd, events]) => {
|
|
112
|
+
console.log(` ${cmd}: [${events.join(', ')}]`);
|
|
113
|
+
});
|
|
114
|
+
if (cliGraph !== null) {
|
|
115
|
+
console.log('\n=== CLI commandToEvents ===');
|
|
116
|
+
Object.entries(cliGraph.commandToEvents).forEach(([cmd, events]) => {
|
|
117
|
+
console.log(` ${cmd}: [${events.join(', ')}]`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
expect(Object.keys(graph.commandToEvents).length).toBeGreaterThan(0);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
describe('Workflow Sequence Validation', () => {
|
|
124
|
+
it('should have correct causal dependencies in pipeline definition', () => {
|
|
125
|
+
const expectedDependencies = [
|
|
126
|
+
['SchemaExported', 'GenerateServer'],
|
|
127
|
+
['SliceGenerated', 'ImplementSlice'],
|
|
128
|
+
['SliceImplemented', 'CheckTests'],
|
|
129
|
+
['SliceImplemented', 'CheckTypes'],
|
|
130
|
+
['SliceImplemented', 'CheckLint'],
|
|
131
|
+
['ServerGenerated', 'GenerateIA'],
|
|
132
|
+
['ServerGenerated', 'StartServer'],
|
|
133
|
+
['IAGenerated', 'GenerateClient'],
|
|
134
|
+
['ClientGenerated', 'ImplementComponent'],
|
|
135
|
+
['ClientGenerated', 'StartClient'],
|
|
136
|
+
];
|
|
137
|
+
const pipelineHandlers = kanbanTodoConfig.pipeline.descriptor.handlers;
|
|
138
|
+
console.log('=== Pipeline Handler Event Types ===');
|
|
139
|
+
pipelineHandlers.forEach((h) => {
|
|
140
|
+
if (h.type === 'emit') {
|
|
141
|
+
const commands = h.commands.map((c) => c.commandType).join(', ');
|
|
142
|
+
console.log(` ${h.eventType} → [${commands}]`);
|
|
143
|
+
}
|
|
144
|
+
else if (h.type === 'settled') {
|
|
145
|
+
console.log(` settled(${h.commandTypes.join(', ')}) → dispatch handler`);
|
|
146
|
+
}
|
|
147
|
+
else if (h.type === 'foreach-phased') {
|
|
148
|
+
console.log(` ${h.eventType} → forEach/phased → ${h.emitFactory({}, '', { type: '', data: {} }).commandType}`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
console.log('\n=== Expected Dependencies ===');
|
|
152
|
+
expectedDependencies.forEach(([from, to]) => {
|
|
153
|
+
console.log(` ${from} → ${to}`);
|
|
154
|
+
});
|
|
155
|
+
const emitHandlers = pipelineHandlers.filter((h) => h.type === 'emit');
|
|
156
|
+
expect(emitHandlers.length).toBeGreaterThan(5);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
//# sourceMappingURL=kanban-todo.e2e.specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kanban-todo.e2e.specs.js","sourceRoot":"","sources":["../../../src/testing/kanban-todo.e2e.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAE7D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACzD,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EA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C,WAAW,EAAE,CACnG,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;YAC/C,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;gBAC1C,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;YAEH,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;YACvE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-handlers.specs.d.ts","sourceRoot":"","sources":["../../../src/testing/mock-handlers.specs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { createMockHandlers, createStatefulHandler, getHandlerCallCount, resetCallCounts } from './mock-handlers.js';
|
|
3
|
+
describe('mock-handlers', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
resetCallCounts();
|
|
6
|
+
});
|
|
7
|
+
describe('createMockHandlers', () => {
|
|
8
|
+
it('should create handlers with correct names', () => {
|
|
9
|
+
const handlers = createMockHandlers([
|
|
10
|
+
{
|
|
11
|
+
name: 'CheckTests',
|
|
12
|
+
events: ['TestsCheckPassed'],
|
|
13
|
+
fn: () => ({ type: 'TestsCheckPassed', data: {} }),
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: 'CheckTypes',
|
|
17
|
+
events: ['TypeCheckPassed'],
|
|
18
|
+
fn: () => ({ type: 'TypeCheckPassed', data: {} }),
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
expect(handlers).toHaveLength(2);
|
|
22
|
+
expect(handlers[0].name).toBe('CheckTests');
|
|
23
|
+
expect(handlers[1].name).toBe('CheckTypes');
|
|
24
|
+
});
|
|
25
|
+
it('should create handlers with correct events', () => {
|
|
26
|
+
const handlers = createMockHandlers([
|
|
27
|
+
{
|
|
28
|
+
name: 'CheckTests',
|
|
29
|
+
events: ['TestsCheckPassed', 'TestsCheckFailed'],
|
|
30
|
+
fn: () => ({ type: 'TestsCheckPassed', data: {} }),
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
expect(handlers[0].events).toEqual(['TestsCheckPassed', 'TestsCheckFailed']);
|
|
34
|
+
});
|
|
35
|
+
it('should call handler function with command', async () => {
|
|
36
|
+
let receivedCommand = null;
|
|
37
|
+
const handlers = createMockHandlers([
|
|
38
|
+
{
|
|
39
|
+
name: 'TestHandler',
|
|
40
|
+
events: ['Done'],
|
|
41
|
+
fn: (cmd) => {
|
|
42
|
+
receivedCommand = cmd;
|
|
43
|
+
return { type: 'Done', data: {} };
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
const command = { type: 'TestHandler', data: { foo: 'bar' } };
|
|
48
|
+
await handlers[0].handle(command);
|
|
49
|
+
expect(receivedCommand).toEqual(command);
|
|
50
|
+
});
|
|
51
|
+
it('should return event from handler function', async () => {
|
|
52
|
+
const handlers = createMockHandlers([
|
|
53
|
+
{
|
|
54
|
+
name: 'TestHandler',
|
|
55
|
+
events: ['Result'],
|
|
56
|
+
fn: () => ({ type: 'Result', data: { value: 42 } }),
|
|
57
|
+
},
|
|
58
|
+
]);
|
|
59
|
+
const result = await handlers[0].handle({ type: 'TestHandler', data: {} });
|
|
60
|
+
expect(result).toEqual({ type: 'Result', data: { value: 42 } });
|
|
61
|
+
});
|
|
62
|
+
it('should return array of events from handler function', async () => {
|
|
63
|
+
const handlers = createMockHandlers([
|
|
64
|
+
{
|
|
65
|
+
name: 'MultiEventHandler',
|
|
66
|
+
events: ['First', 'Second'],
|
|
67
|
+
fn: () => [
|
|
68
|
+
{ type: 'First', data: {} },
|
|
69
|
+
{ type: 'Second', data: {} },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
const result = await handlers[0].handle({ type: 'MultiEventHandler', data: {} });
|
|
74
|
+
expect(result).toEqual([
|
|
75
|
+
{ type: 'First', data: {} },
|
|
76
|
+
{ type: 'Second', data: {} },
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
it('should pass attempt number to handler function', async () => {
|
|
80
|
+
const receivedAttempts = [];
|
|
81
|
+
const handlers = createMockHandlers([
|
|
82
|
+
{
|
|
83
|
+
name: 'TrackingHandler',
|
|
84
|
+
events: ['Done'],
|
|
85
|
+
fn: (_, attempt) => {
|
|
86
|
+
receivedAttempts.push(attempt);
|
|
87
|
+
return { type: 'Done', data: {} };
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
]);
|
|
91
|
+
await handlers[0].handle({ type: 'TrackingHandler', data: {} });
|
|
92
|
+
await handlers[0].handle({ type: 'TrackingHandler', data: {} });
|
|
93
|
+
await handlers[0].handle({ type: 'TrackingHandler', data: {} });
|
|
94
|
+
expect(receivedAttempts).toEqual([1, 2, 3]);
|
|
95
|
+
});
|
|
96
|
+
it('should reset call counts when creating new handlers', () => {
|
|
97
|
+
createMockHandlers([
|
|
98
|
+
{
|
|
99
|
+
name: 'First',
|
|
100
|
+
events: ['Done'],
|
|
101
|
+
fn: () => ({ type: 'Done', data: {} }),
|
|
102
|
+
},
|
|
103
|
+
]);
|
|
104
|
+
expect(getHandlerCallCount('First')).toBe(0);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe('getHandlerCallCount', () => {
|
|
108
|
+
it('should return 0 for uncalled handler', () => {
|
|
109
|
+
createMockHandlers([
|
|
110
|
+
{
|
|
111
|
+
name: 'Uncalled',
|
|
112
|
+
events: ['Done'],
|
|
113
|
+
fn: () => ({ type: 'Done', data: {} }),
|
|
114
|
+
},
|
|
115
|
+
]);
|
|
116
|
+
expect(getHandlerCallCount('Uncalled')).toBe(0);
|
|
117
|
+
});
|
|
118
|
+
it('should track call count for handler', async () => {
|
|
119
|
+
const handlers = createMockHandlers([
|
|
120
|
+
{
|
|
121
|
+
name: 'Called',
|
|
122
|
+
events: ['Done'],
|
|
123
|
+
fn: () => ({ type: 'Done', data: {} }),
|
|
124
|
+
},
|
|
125
|
+
]);
|
|
126
|
+
await handlers[0].handle({ type: 'Called', data: {} });
|
|
127
|
+
await handlers[0].handle({ type: 'Called', data: {} });
|
|
128
|
+
expect(getHandlerCallCount('Called')).toBe(2);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
describe('resetCallCounts', () => {
|
|
132
|
+
it('should clear all call counts', async () => {
|
|
133
|
+
const handlers = createMockHandlers([
|
|
134
|
+
{
|
|
135
|
+
name: 'Handler1',
|
|
136
|
+
events: ['Done'],
|
|
137
|
+
fn: () => ({ type: 'Done', data: {} }),
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'Handler2',
|
|
141
|
+
events: ['Done'],
|
|
142
|
+
fn: () => ({ type: 'Done', data: {} }),
|
|
143
|
+
},
|
|
144
|
+
]);
|
|
145
|
+
await handlers[0].handle({ type: 'Handler1', data: {} });
|
|
146
|
+
await handlers[1].handle({ type: 'Handler2', data: {} });
|
|
147
|
+
resetCallCounts();
|
|
148
|
+
expect(getHandlerCallCount('Handler1')).toBe(0);
|
|
149
|
+
expect(getHandlerCallCount('Handler2')).toBe(0);
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
describe('createStatefulHandler', () => {
|
|
153
|
+
it('should fail for initial attempts', async () => {
|
|
154
|
+
const handler = createStatefulHandler({
|
|
155
|
+
name: 'CheckTests',
|
|
156
|
+
events: ['TestsCheckPassed', 'TestsCheckFailed'],
|
|
157
|
+
initialFails: 2,
|
|
158
|
+
failEvent: (cmd) => ({ type: 'TestsCheckFailed', data: { target: cmd.data } }),
|
|
159
|
+
successEvent: (cmd) => ({ type: 'TestsCheckPassed', data: { target: cmd.data } }),
|
|
160
|
+
});
|
|
161
|
+
const command = { type: 'CheckTests', data: { dir: './src' } };
|
|
162
|
+
const result1 = await handler.handle(command);
|
|
163
|
+
expect(Array.isArray(result1) ? result1[0].type : result1.type).toBe('TestsCheckFailed');
|
|
164
|
+
const result2 = await handler.handle(command);
|
|
165
|
+
expect(Array.isArray(result2) ? result2[0].type : result2.type).toBe('TestsCheckFailed');
|
|
166
|
+
const result3 = await handler.handle(command);
|
|
167
|
+
expect(Array.isArray(result3) ? result3[0].type : result3.type).toBe('TestsCheckPassed');
|
|
168
|
+
});
|
|
169
|
+
it('should preserve handler metadata', () => {
|
|
170
|
+
const handler = createStatefulHandler({
|
|
171
|
+
name: 'CheckTypes',
|
|
172
|
+
events: ['TypeCheckPassed', 'TypeCheckFailed'],
|
|
173
|
+
initialFails: 1,
|
|
174
|
+
failEvent: () => ({ type: 'TypeCheckFailed', data: {} }),
|
|
175
|
+
successEvent: () => ({ type: 'TypeCheckPassed', data: {} }),
|
|
176
|
+
});
|
|
177
|
+
expect(handler.name).toBe('CheckTypes');
|
|
178
|
+
expect(handler.events).toEqual(['TypeCheckPassed', 'TypeCheckFailed']);
|
|
179
|
+
});
|
|
180
|
+
it('should succeed immediately when initialFails is 0', async () => {
|
|
181
|
+
const handler = createStatefulHandler({
|
|
182
|
+
name: 'AlwaysPass',
|
|
183
|
+
events: ['Passed'],
|
|
184
|
+
initialFails: 0,
|
|
185
|
+
failEvent: () => ({ type: 'Failed', data: {} }),
|
|
186
|
+
successEvent: () => ({ type: 'Passed', data: {} }),
|
|
187
|
+
});
|
|
188
|
+
const result = await handler.handle({ type: 'AlwaysPass', data: {} });
|
|
189
|
+
expect(Array.isArray(result) ? result[0].type : result.type).toBe('Passed');
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=mock-handlers.specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-handlers.specs.js","sourceRoot":"","sources":["../../../src/testing/mock-handlers.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,UAAU,CAAC,GAAG,EAAE;QACd,eAAe,EAAE,CAAC;IACpB,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;QAClC,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACnD,MAAM,QAAQ,GAAG,kBAAkB,CAAC;gBAClC;oBACE,IAAI,EAAE,YAAY;oBAClB,MAAM,EAAE,CAAC,kBAAkB,CAAC;oBAC5B,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;iBACnD;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,MAAM,EAAE,CAAC,iBAAiB,CAAC;oBAC3B,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;iBAClD;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC5C,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAA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M,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-execution.e2e.specs.d.ts","sourceRoot":"","sources":["../../../src/testing/real-execution.e2e.specs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { config } from 'dotenv';
|
|
5
|
+
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';
|
|
6
|
+
import { loadPipelineConfig } from '../config/pipeline-config.js';
|
|
7
|
+
import { PipelineServer } from '../server/pipeline-server.js';
|
|
8
|
+
import { resetKanbanState } from './fixtures/kanban-full.pipeline.js';
|
|
9
|
+
import kanbanTodoConfig from './fixtures/kanban-todo.config.js';
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const PIPELINE_ROOT = path.resolve(__dirname, '../..');
|
|
12
|
+
const PACKAGES_DIR = path.resolve(__dirname, '../../..');
|
|
13
|
+
const EXAMPLE_DIR = path.resolve(PACKAGES_DIR, '../examples/kanban-todo');
|
|
14
|
+
const CLI_SNAPSHOTS_DIR = path.join(PACKAGES_DIR, 'cli/src/__tests__/e2e/__snapshots__/kanban-todo');
|
|
15
|
+
config({ path: path.join(PIPELINE_ROOT, '.env') });
|
|
16
|
+
function loadCliEventStream() {
|
|
17
|
+
const snapshotPath = path.join(CLI_SNAPSHOTS_DIR, 'event-stream.snapshot.json');
|
|
18
|
+
if (!existsSync(snapshotPath)) {
|
|
19
|
+
console.log(`Event stream snapshot not found: ${snapshotPath}`);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const content = readFileSync(snapshotPath, 'utf-8');
|
|
23
|
+
return JSON.parse(content);
|
|
24
|
+
}
|
|
25
|
+
async function waitForPipelineCompletion(server, timeoutMs, pollIntervalMs) {
|
|
26
|
+
const startTime = Date.now();
|
|
27
|
+
let lastMessageCount = 0;
|
|
28
|
+
let stableCount = 0;
|
|
29
|
+
const stableThreshold = 15;
|
|
30
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
31
|
+
const response = await fetch(`http://localhost:${server.port}/messages`);
|
|
32
|
+
const messages = (await response.json());
|
|
33
|
+
if (messages.length === lastMessageCount) {
|
|
34
|
+
stableCount++;
|
|
35
|
+
if (stableCount >= stableThreshold) {
|
|
36
|
+
console.log(` Pipeline stable after ${stableThreshold} polls`);
|
|
37
|
+
return messages;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (stableCount > 0) {
|
|
42
|
+
console.log(` New activity after ${stableCount} stable polls`);
|
|
43
|
+
}
|
|
44
|
+
stableCount = 0;
|
|
45
|
+
lastMessageCount = messages.length;
|
|
46
|
+
console.log(` Messages: ${messages.length}`);
|
|
47
|
+
}
|
|
48
|
+
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));
|
|
49
|
+
}
|
|
50
|
+
console.log(` Timeout reached after ${timeoutMs}ms`);
|
|
51
|
+
const response = await fetch(`http://localhost:${server.port}/messages`);
|
|
52
|
+
return (await response.json());
|
|
53
|
+
}
|
|
54
|
+
describe('Real Execution E2E', () => {
|
|
55
|
+
let server;
|
|
56
|
+
beforeAll(async () => {
|
|
57
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
58
|
+
console.log('=== Environment Check ===');
|
|
59
|
+
console.log(`ANTHROPIC_API_KEY set: ${process.env.ANTHROPIC_API_KEY !== undefined}`);
|
|
60
|
+
console.log(`Example directory: ${EXAMPLE_DIR}`);
|
|
61
|
+
console.log(`Example exists: ${existsSync(EXAMPLE_DIR)}`);
|
|
62
|
+
console.log(`Handlers loaded: ${loaded.handlers.length}`);
|
|
63
|
+
console.log(`Handler names: ${loaded.handlers.map((h) => h.name).join(', ')}`);
|
|
64
|
+
server = new PipelineServer({ port: 0 });
|
|
65
|
+
server.registerCommandHandlers(loaded.handlers);
|
|
66
|
+
server.registerPipeline(loaded.pipeline);
|
|
67
|
+
await server.start();
|
|
68
|
+
console.log(`Server started on port ${server.port}`);
|
|
69
|
+
}, 60000);
|
|
70
|
+
afterAll(async () => {
|
|
71
|
+
await server.stop();
|
|
72
|
+
});
|
|
73
|
+
beforeEach(() => {
|
|
74
|
+
resetKanbanState();
|
|
75
|
+
});
|
|
76
|
+
describe('Full Pipeline Execution', () => {
|
|
77
|
+
it('should execute ExportSchema and trigger full pipeline chain', async () => {
|
|
78
|
+
console.log('\n=== Dispatching ExportSchema ===');
|
|
79
|
+
console.log(`Target directory: ${EXAMPLE_DIR}`);
|
|
80
|
+
const dispatchResponse = await fetch(`http://localhost:${server.port}/command`, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: { 'Content-Type': 'application/json' },
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
type: 'ExportSchema',
|
|
85
|
+
data: {
|
|
86
|
+
directory: EXAMPLE_DIR,
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
89
|
+
});
|
|
90
|
+
const dispatchResult = (await dispatchResponse.json());
|
|
91
|
+
console.log(`Dispatch response: ${JSON.stringify(dispatchResult)}`);
|
|
92
|
+
expect(dispatchResult.status).toBe('ack');
|
|
93
|
+
console.log('\n=== Waiting for pipeline completion (5 minute timeout) ===');
|
|
94
|
+
const messages = await waitForPipelineCompletion(server, 5 * 60 * 1000, 2000);
|
|
95
|
+
console.log(`\n=== Pipeline Results ===`);
|
|
96
|
+
console.log(`Total messages: ${messages.length}`);
|
|
97
|
+
const events = messages.filter((m) => m.messageType === 'event');
|
|
98
|
+
const commands = messages.filter((m) => m.messageType === 'command');
|
|
99
|
+
console.log(`Events: ${events.length}`);
|
|
100
|
+
console.log(`Commands: ${commands.length}`);
|
|
101
|
+
console.log('\n=== Event Types (in order) ===');
|
|
102
|
+
events.forEach((e, i) => {
|
|
103
|
+
console.log(` ${i + 1}. ${e.message.type}`);
|
|
104
|
+
if (e.message.type.includes('Failed')) {
|
|
105
|
+
console.log(` Error: ${JSON.stringify(e.message.data)}`);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
console.log('\n=== Command Types (in order) ===');
|
|
109
|
+
commands.forEach((c, i) => {
|
|
110
|
+
console.log(` ${i + 1}. ${c.message.type}`);
|
|
111
|
+
});
|
|
112
|
+
const cliEvents = loadCliEventStream();
|
|
113
|
+
if (cliEvents !== null) {
|
|
114
|
+
console.log('\n=== CLI Event Types (for comparison) ===');
|
|
115
|
+
const cliEventTypes = [...new Set(cliEvents.map((e) => e.type))];
|
|
116
|
+
cliEventTypes.forEach((t) => {
|
|
117
|
+
const count = cliEvents.filter((e) => e.type === t).length;
|
|
118
|
+
console.log(` ${t}: ${count}`);
|
|
119
|
+
});
|
|
120
|
+
console.log('\n=== Pipeline Event Types (for comparison) ===');
|
|
121
|
+
const pipelineEventTypes = [...new Set(events.map((e) => e.message.type))];
|
|
122
|
+
pipelineEventTypes.forEach((t) => {
|
|
123
|
+
const count = events.filter((e) => e.message.type === t).length;
|
|
124
|
+
console.log(` ${t}: ${count}`);
|
|
125
|
+
});
|
|
126
|
+
console.log('\n=== Event Type Comparison ===');
|
|
127
|
+
const cliTypeSet = new Set(cliEventTypes);
|
|
128
|
+
const pipelineTypeSet = new Set(pipelineEventTypes);
|
|
129
|
+
const missingFromPipeline = cliEventTypes.filter((t) => !pipelineTypeSet.has(t));
|
|
130
|
+
const extraInPipeline = pipelineEventTypes.filter((t) => !cliTypeSet.has(t));
|
|
131
|
+
console.log(`Missing from pipeline: ${missingFromPipeline.join(', ') || 'none'}`);
|
|
132
|
+
console.log(`Extra in pipeline: ${extraInPipeline.join(', ') || 'none'}`);
|
|
133
|
+
}
|
|
134
|
+
expect(events.length).toBeGreaterThan(0);
|
|
135
|
+
const hasSchemaExported = events.some((e) => e.message.type === 'SchemaExported');
|
|
136
|
+
expect(hasSchemaExported).toBe(true);
|
|
137
|
+
}, 10 * 60 * 1000);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
//# sourceMappingURL=real-execution.e2e.specs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-execution.e2e.specs.js","sourceRoot":"","sources":["../../../src/testing/real-execution.e2e.specs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAE7D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACvD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACzD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,yBAAyB,CAAC,CAAC;AAC1E,MAAM,iBAAiB,GAAG,I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IAAI,CAAC,CAAC;QACvC,CAAC,EACD,EAAE,GAAG,EAAE,GAAG,IAAI,CACf,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"real-plugin.e2e.specs.d.ts","sourceRoot":"","sources":["../../../src/testing/real-plugin.e2e.specs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { loadPipelineConfig } from '../config/pipeline-config.js';
|
|
3
|
+
import { PipelineServer } from '../server/pipeline-server.js';
|
|
4
|
+
import { resetKanbanState } from './fixtures/kanban-full.pipeline.js';
|
|
5
|
+
import kanbanTodoConfig from './fixtures/kanban-todo.config.js';
|
|
6
|
+
describe('Real Plugin E2E', () => {
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
resetKanbanState();
|
|
9
|
+
});
|
|
10
|
+
describe('Load and Run Pipeline Config', () => {
|
|
11
|
+
it('should load handlers from config and register them', async () => {
|
|
12
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
13
|
+
console.log('=== Loaded Handlers ===');
|
|
14
|
+
console.log(`Total handlers loaded: ${loaded.handlers.length}`);
|
|
15
|
+
console.log('Handler names:', loaded.handlers.map((h) => h.name).join(', '));
|
|
16
|
+
expect(loaded.handlers.length).toBeGreaterThan(0);
|
|
17
|
+
expect(loaded.pipeline.descriptor.name).toBe('kanban-full');
|
|
18
|
+
});
|
|
19
|
+
it('should start server with real config', async () => {
|
|
20
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
21
|
+
const server = new PipelineServer({ port: 0 });
|
|
22
|
+
server.registerCommandHandlers(loaded.handlers);
|
|
23
|
+
server.registerPipeline(loaded.pipeline);
|
|
24
|
+
await server.start();
|
|
25
|
+
const registeredCommands = server.getRegisteredCommands();
|
|
26
|
+
console.log('=== Registered Commands ===');
|
|
27
|
+
registeredCommands.forEach((cmd) => console.log(` - ${cmd}`));
|
|
28
|
+
expect(registeredCommands.length).toBe(loaded.handlers.length);
|
|
29
|
+
await server.stop();
|
|
30
|
+
});
|
|
31
|
+
it('should serve pipeline graph via API', async () => {
|
|
32
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
33
|
+
const server = new PipelineServer({ port: 0 });
|
|
34
|
+
server.registerCommandHandlers(loaded.handlers);
|
|
35
|
+
server.registerPipeline(loaded.pipeline);
|
|
36
|
+
await server.start();
|
|
37
|
+
const response = await fetch(`http://localhost:${server.port}/pipeline`);
|
|
38
|
+
const text = await response.text();
|
|
39
|
+
expect(response.status).toBe(200);
|
|
40
|
+
expect(response.headers.get('content-type')).toContain('application/json');
|
|
41
|
+
const graph = JSON.parse(text);
|
|
42
|
+
console.log('=== Pipeline Graph ===');
|
|
43
|
+
console.log(`Nodes: ${graph.nodes.length}`);
|
|
44
|
+
console.log(`Edges: ${graph.edges.length}`);
|
|
45
|
+
expect(graph.nodes.length).toBeGreaterThan(0);
|
|
46
|
+
expect(graph.edges.length).toBeGreaterThan(0);
|
|
47
|
+
await server.stop();
|
|
48
|
+
});
|
|
49
|
+
it('should serve registry via API', async () => {
|
|
50
|
+
const loaded = await loadPipelineConfig(kanbanTodoConfig);
|
|
51
|
+
const server = new PipelineServer({ port: 0 });
|
|
52
|
+
server.registerCommandHandlers(loaded.handlers);
|
|
53
|
+
server.registerPipeline(loaded.pipeline);
|
|
54
|
+
await server.start();
|
|
55
|
+
const response = await fetch(`http://localhost:${server.port}/registry`);
|
|
56
|
+
const registry = (await response.json());
|
|
57
|
+
console.log('=== Registry ===');
|
|
58
|
+
console.log('Event handlers:', registry.eventHandlers.join(', '));
|
|
59
|
+
console.log('Command handlers:', registry.commandHandlers.join(', '));
|
|
60
|
+
expect(registry.commandHandlers.length).toBeGreaterThan(0);
|
|
61
|
+
await server.stop();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=real-plugin.e2e.specs.js.map
|