@sparkleideas/testing 3.0.0-alpha.10
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/README.md +547 -0
- package/__tests__/framework.test.ts +21 -0
- package/package.json +61 -0
- package/src/fixtures/agent-fixtures.ts +793 -0
- package/src/fixtures/agents.ts +212 -0
- package/src/fixtures/configurations.ts +491 -0
- package/src/fixtures/index.ts +21 -0
- package/src/fixtures/mcp-fixtures.ts +1030 -0
- package/src/fixtures/memory-entries.ts +328 -0
- package/src/fixtures/memory-fixtures.ts +750 -0
- package/src/fixtures/swarm-fixtures.ts +837 -0
- package/src/fixtures/tasks.ts +309 -0
- package/src/helpers/assertion-helpers.ts +616 -0
- package/src/helpers/assertions.ts +286 -0
- package/src/helpers/create-mock.ts +200 -0
- package/src/helpers/index.ts +182 -0
- package/src/helpers/mock-factory.ts +711 -0
- package/src/helpers/setup-teardown.ts +678 -0
- package/src/helpers/swarm-instance.ts +326 -0
- package/src/helpers/test-application.ts +310 -0
- package/src/helpers/test-utils.ts +670 -0
- package/src/index.ts +232 -0
- package/src/mocks/index.ts +29 -0
- package/src/mocks/mock-mcp-client.ts +723 -0
- package/src/mocks/mock-services.ts +793 -0
- package/src/regression/api-contract.ts +473 -0
- package/src/regression/index.ts +46 -0
- package/src/regression/integration-regression.ts +416 -0
- package/src/regression/performance-baseline.ts +356 -0
- package/src/regression/regression-runner.ts +339 -0
- package/src/regression/security-regression.ts +331 -0
- package/src/setup.ts +127 -0
- package/src/v2-compat/api-compat.test.ts +590 -0
- package/src/v2-compat/cli-compat.test.ts +484 -0
- package/src/v2-compat/compatibility-validator.ts +1072 -0
- package/src/v2-compat/hooks-compat.test.ts +602 -0
- package/src/v2-compat/index.ts +58 -0
- package/src/v2-compat/mcp-compat.test.ts +557 -0
- package/src/v2-compat/report-generator.ts +441 -0
- package/tmp.json +0 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Claude-Flow Task Fixtures
|
|
3
|
+
*
|
|
4
|
+
* Test data for task-related testing
|
|
5
|
+
* Following London School principle of explicit test data
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Task definition interface
|
|
10
|
+
*/
|
|
11
|
+
export interface TaskDefinition {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
payload: unknown;
|
|
15
|
+
priority?: number;
|
|
16
|
+
metadata?: Record<string, unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Task instance interface
|
|
21
|
+
*/
|
|
22
|
+
export interface TaskInstance {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
status: TaskStatus;
|
|
27
|
+
payload: unknown;
|
|
28
|
+
priority: number;
|
|
29
|
+
createdAt: Date;
|
|
30
|
+
startedAt?: Date;
|
|
31
|
+
completedAt?: Date;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type TaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'cancelled';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Task result interface
|
|
39
|
+
*/
|
|
40
|
+
export interface TaskResult {
|
|
41
|
+
taskId: string;
|
|
42
|
+
success: boolean;
|
|
43
|
+
output?: unknown;
|
|
44
|
+
error?: Error;
|
|
45
|
+
duration: number;
|
|
46
|
+
metrics?: TaskMetrics;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Task metrics interface
|
|
51
|
+
*/
|
|
52
|
+
export interface TaskMetrics {
|
|
53
|
+
cpuTime: number;
|
|
54
|
+
memoryUsage: number;
|
|
55
|
+
ioOperations: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Pre-defined task definitions for testing
|
|
60
|
+
*/
|
|
61
|
+
export const taskDefinitions: Record<string, TaskDefinition> = {
|
|
62
|
+
securityScan: {
|
|
63
|
+
name: 'Security Scan',
|
|
64
|
+
type: 'security',
|
|
65
|
+
payload: {
|
|
66
|
+
target: './src',
|
|
67
|
+
scanType: 'full',
|
|
68
|
+
severity: 'high',
|
|
69
|
+
},
|
|
70
|
+
priority: 100,
|
|
71
|
+
metadata: { cve: ['CVE-1', 'CVE-2', 'CVE-3'] },
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
codeReview: {
|
|
75
|
+
name: 'Code Review',
|
|
76
|
+
type: 'review',
|
|
77
|
+
payload: {
|
|
78
|
+
files: ['src/main.ts', 'src/utils.ts'],
|
|
79
|
+
rules: ['security', 'performance', 'style'],
|
|
80
|
+
},
|
|
81
|
+
priority: 80,
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
memoryOptimization: {
|
|
85
|
+
name: 'Memory Optimization',
|
|
86
|
+
type: 'optimization',
|
|
87
|
+
payload: {
|
|
88
|
+
targetReduction: 0.50,
|
|
89
|
+
backend: 'agentdb',
|
|
90
|
+
},
|
|
91
|
+
priority: 70,
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
swarmCoordination: {
|
|
95
|
+
name: 'Swarm Coordination',
|
|
96
|
+
type: 'coordination',
|
|
97
|
+
payload: {
|
|
98
|
+
topology: 'hierarchical-mesh',
|
|
99
|
+
agents: 15,
|
|
100
|
+
task: 'implementation',
|
|
101
|
+
},
|
|
102
|
+
priority: 90,
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
unitTesting: {
|
|
106
|
+
name: 'Unit Testing',
|
|
107
|
+
type: 'testing',
|
|
108
|
+
payload: {
|
|
109
|
+
framework: 'vitest',
|
|
110
|
+
coverage: 0.90,
|
|
111
|
+
patterns: ['**/*.test.ts'],
|
|
112
|
+
},
|
|
113
|
+
priority: 75,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
implementation: {
|
|
117
|
+
name: 'Implementation Task',
|
|
118
|
+
type: 'coding',
|
|
119
|
+
payload: {
|
|
120
|
+
module: 'security',
|
|
121
|
+
feature: 'path-validation',
|
|
122
|
+
},
|
|
123
|
+
priority: 60,
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Pre-defined task instances for testing
|
|
129
|
+
*/
|
|
130
|
+
export const taskInstances: Record<string, TaskInstance> = {
|
|
131
|
+
pendingSecurityScan: {
|
|
132
|
+
id: 'task-security-001',
|
|
133
|
+
name: 'Security Scan',
|
|
134
|
+
type: 'security',
|
|
135
|
+
status: 'pending',
|
|
136
|
+
payload: taskDefinitions.securityScan.payload,
|
|
137
|
+
priority: 100,
|
|
138
|
+
createdAt: new Date('2024-01-15T10:00:00Z'),
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
runningCodeReview: {
|
|
142
|
+
id: 'task-review-001',
|
|
143
|
+
name: 'Code Review',
|
|
144
|
+
type: 'review',
|
|
145
|
+
status: 'running',
|
|
146
|
+
payload: taskDefinitions.codeReview.payload,
|
|
147
|
+
priority: 80,
|
|
148
|
+
createdAt: new Date('2024-01-15T09:00:00Z'),
|
|
149
|
+
startedAt: new Date('2024-01-15T09:05:00Z'),
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
completedUnitTesting: {
|
|
153
|
+
id: 'task-testing-001',
|
|
154
|
+
name: 'Unit Testing',
|
|
155
|
+
type: 'testing',
|
|
156
|
+
status: 'completed',
|
|
157
|
+
payload: taskDefinitions.unitTesting.payload,
|
|
158
|
+
priority: 75,
|
|
159
|
+
createdAt: new Date('2024-01-15T08:00:00Z'),
|
|
160
|
+
startedAt: new Date('2024-01-15T08:05:00Z'),
|
|
161
|
+
completedAt: new Date('2024-01-15T08:30:00Z'),
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
failedImplementation: {
|
|
165
|
+
id: 'task-impl-001',
|
|
166
|
+
name: 'Implementation Task',
|
|
167
|
+
type: 'coding',
|
|
168
|
+
status: 'failed',
|
|
169
|
+
payload: taskDefinitions.implementation.payload,
|
|
170
|
+
priority: 60,
|
|
171
|
+
createdAt: new Date('2024-01-15T07:00:00Z'),
|
|
172
|
+
startedAt: new Date('2024-01-15T07:05:00Z'),
|
|
173
|
+
completedAt: new Date('2024-01-15T07:20:00Z'),
|
|
174
|
+
error: 'Compilation error: missing dependency',
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
cancelledSwarmCoordination: {
|
|
178
|
+
id: 'task-swarm-001',
|
|
179
|
+
name: 'Swarm Coordination',
|
|
180
|
+
type: 'coordination',
|
|
181
|
+
status: 'cancelled',
|
|
182
|
+
payload: taskDefinitions.swarmCoordination.payload,
|
|
183
|
+
priority: 90,
|
|
184
|
+
createdAt: new Date('2024-01-15T06:00:00Z'),
|
|
185
|
+
startedAt: new Date('2024-01-15T06:05:00Z'),
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Pre-defined task results for testing
|
|
191
|
+
*/
|
|
192
|
+
export const taskResults: Record<string, TaskResult> = {
|
|
193
|
+
successfulSecurityScan: {
|
|
194
|
+
taskId: 'task-security-001',
|
|
195
|
+
success: true,
|
|
196
|
+
output: {
|
|
197
|
+
vulnerabilities: 0,
|
|
198
|
+
scannedFiles: 150,
|
|
199
|
+
duration: 5000,
|
|
200
|
+
},
|
|
201
|
+
duration: 5000,
|
|
202
|
+
metrics: {
|
|
203
|
+
cpuTime: 4500,
|
|
204
|
+
memoryUsage: 128 * 1024 * 1024,
|
|
205
|
+
ioOperations: 300,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
failedSecurityScan: {
|
|
210
|
+
taskId: 'task-security-002',
|
|
211
|
+
success: false,
|
|
212
|
+
error: new Error('Critical vulnerability found: CVE-2024-001'),
|
|
213
|
+
duration: 2500,
|
|
214
|
+
},
|
|
215
|
+
|
|
216
|
+
successfulCodeReview: {
|
|
217
|
+
taskId: 'task-review-001',
|
|
218
|
+
success: true,
|
|
219
|
+
output: {
|
|
220
|
+
issues: 3,
|
|
221
|
+
suggestions: 10,
|
|
222
|
+
approved: true,
|
|
223
|
+
},
|
|
224
|
+
duration: 15000,
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Factory function to create task definition with overrides
|
|
230
|
+
*/
|
|
231
|
+
export function createTaskDefinition(
|
|
232
|
+
base: keyof typeof taskDefinitions,
|
|
233
|
+
overrides?: Partial<TaskDefinition>
|
|
234
|
+
): TaskDefinition {
|
|
235
|
+
return {
|
|
236
|
+
...taskDefinitions[base],
|
|
237
|
+
...overrides,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Factory function to create task instance with overrides
|
|
243
|
+
*/
|
|
244
|
+
export function createTaskInstance(
|
|
245
|
+
base: keyof typeof taskInstances,
|
|
246
|
+
overrides?: Partial<TaskInstance>
|
|
247
|
+
): TaskInstance {
|
|
248
|
+
return {
|
|
249
|
+
...taskInstances[base],
|
|
250
|
+
...overrides,
|
|
251
|
+
id: overrides?.id ?? `task-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
252
|
+
createdAt: overrides?.createdAt ?? new Date(),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Factory function to create task result with overrides
|
|
258
|
+
*/
|
|
259
|
+
export function createTaskResult(
|
|
260
|
+
base: keyof typeof taskResults,
|
|
261
|
+
overrides?: Partial<TaskResult>
|
|
262
|
+
): TaskResult {
|
|
263
|
+
return {
|
|
264
|
+
...taskResults[base],
|
|
265
|
+
...overrides,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Invalid task definitions for error testing
|
|
271
|
+
*/
|
|
272
|
+
export const invalidTaskDefinitions = {
|
|
273
|
+
emptyName: {
|
|
274
|
+
name: '',
|
|
275
|
+
type: 'coding',
|
|
276
|
+
payload: {},
|
|
277
|
+
},
|
|
278
|
+
|
|
279
|
+
emptyType: {
|
|
280
|
+
name: 'Valid Name',
|
|
281
|
+
type: '',
|
|
282
|
+
payload: {},
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
nullPayload: {
|
|
286
|
+
name: 'Valid Name',
|
|
287
|
+
type: 'coding',
|
|
288
|
+
payload: null,
|
|
289
|
+
},
|
|
290
|
+
|
|
291
|
+
invalidPriority: {
|
|
292
|
+
name: 'Valid Name',
|
|
293
|
+
type: 'coding',
|
|
294
|
+
payload: {},
|
|
295
|
+
priority: -100,
|
|
296
|
+
},
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Task batch for swarm testing
|
|
301
|
+
*/
|
|
302
|
+
export function createTaskBatch(count: number, type: string = 'coding'): TaskDefinition[] {
|
|
303
|
+
return Array.from({ length: count }, (_, i) => ({
|
|
304
|
+
name: `Batch Task ${i + 1}`,
|
|
305
|
+
type,
|
|
306
|
+
payload: { index: i },
|
|
307
|
+
priority: Math.floor(Math.random() * 100),
|
|
308
|
+
}));
|
|
309
|
+
}
|