@vibescope/mcp-server 0.0.1 → 0.1.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/README.md +113 -98
- package/dist/api-client.d.ts +1114 -0
- package/dist/api-client.js +698 -0
- package/dist/cli.d.ts +1 -6
- package/dist/cli.js +39 -240
- package/dist/config/tool-categories.d.ts +31 -0
- package/dist/config/tool-categories.js +253 -0
- package/dist/handlers/blockers.js +57 -58
- package/dist/handlers/bodies-of-work.d.ts +2 -0
- package/dist/handlers/bodies-of-work.js +106 -476
- package/dist/handlers/cost.d.ts +1 -0
- package/dist/handlers/cost.js +35 -113
- package/dist/handlers/decisions.d.ts +2 -0
- package/dist/handlers/decisions.js +28 -27
- package/dist/handlers/deployment.js +112 -828
- package/dist/handlers/discovery.js +31 -0
- package/dist/handlers/fallback.d.ts +2 -0
- package/dist/handlers/fallback.js +39 -134
- package/dist/handlers/findings.js +43 -67
- package/dist/handlers/git-issues.d.ts +9 -13
- package/dist/handlers/git-issues.js +80 -225
- package/dist/handlers/ideas.d.ts +3 -0
- package/dist/handlers/ideas.js +53 -134
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +6 -0
- package/dist/handlers/milestones.d.ts +2 -0
- package/dist/handlers/milestones.js +51 -98
- package/dist/handlers/organizations.js +79 -275
- package/dist/handlers/progress.d.ts +2 -0
- package/dist/handlers/progress.js +25 -123
- package/dist/handlers/project.js +42 -221
- package/dist/handlers/requests.d.ts +2 -0
- package/dist/handlers/requests.js +23 -83
- package/dist/handlers/session.js +99 -585
- package/dist/handlers/sprints.d.ts +32 -0
- package/dist/handlers/sprints.js +274 -0
- package/dist/handlers/tasks.d.ts +7 -10
- package/dist/handlers/tasks.js +230 -900
- package/dist/handlers/tool-docs.d.ts +8 -0
- package/dist/handlers/tool-docs.js +657 -0
- package/dist/handlers/types.d.ts +11 -3
- package/dist/handlers/validation.d.ts +1 -1
- package/dist/handlers/validation.js +26 -153
- package/dist/index.js +473 -160
- package/dist/knowledge.js +106 -9
- package/dist/tools.js +4 -0
- package/dist/validators.d.ts +21 -0
- package/dist/validators.js +91 -0
- package/package.json +2 -3
- package/src/api-client.ts +1752 -0
- package/src/cli.test.ts +128 -302
- package/src/cli.ts +41 -285
- package/src/handlers/__test-setup__.ts +210 -0
- package/src/handlers/__test-utils__.ts +4 -134
- package/src/handlers/blockers.test.ts +114 -124
- package/src/handlers/blockers.ts +68 -70
- package/src/handlers/bodies-of-work.test.ts +236 -831
- package/src/handlers/bodies-of-work.ts +194 -525
- package/src/handlers/cost.test.ts +149 -113
- package/src/handlers/cost.ts +44 -132
- package/src/handlers/decisions.test.ts +111 -209
- package/src/handlers/decisions.ts +35 -27
- package/src/handlers/deployment.test.ts +193 -239
- package/src/handlers/deployment.ts +140 -895
- package/src/handlers/discovery.test.ts +20 -67
- package/src/handlers/discovery.ts +32 -0
- package/src/handlers/fallback.test.ts +128 -361
- package/src/handlers/fallback.ts +62 -148
- package/src/handlers/findings.test.ts +127 -345
- package/src/handlers/findings.ts +49 -66
- package/src/handlers/git-issues.test.ts +623 -0
- package/src/handlers/git-issues.ts +174 -0
- package/src/handlers/ideas.test.ts +229 -343
- package/src/handlers/ideas.ts +69 -143
- package/src/handlers/index.ts +6 -0
- package/src/handlers/milestones.test.ts +167 -281
- package/src/handlers/milestones.ts +54 -93
- package/src/handlers/organizations.test.ts +275 -467
- package/src/handlers/organizations.ts +84 -294
- package/src/handlers/progress.test.ts +112 -218
- package/src/handlers/progress.ts +29 -142
- package/src/handlers/project.test.ts +203 -226
- package/src/handlers/project.ts +48 -238
- package/src/handlers/requests.test.ts +74 -342
- package/src/handlers/requests.ts +25 -83
- package/src/handlers/session.test.ts +241 -206
- package/src/handlers/session.ts +110 -657
- package/src/handlers/sprints.test.ts +711 -0
- package/src/handlers/sprints.ts +497 -0
- package/src/handlers/tasks.test.ts +608 -353
- package/src/handlers/tasks.ts +248 -1025
- package/src/handlers/types.ts +12 -4
- package/src/handlers/validation.test.ts +189 -572
- package/src/handlers/validation.ts +29 -166
- package/src/index.ts +473 -184
- package/src/knowledge.ts +107 -9
- package/src/tools.ts +2506 -0
- package/src/validators.test.ts +223 -223
- package/src/validators.ts +127 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +14 -13
- package/dist/cli.test.d.ts +0 -1
- package/dist/cli.test.js +0 -367
- package/dist/handlers/__test-utils__.d.ts +0 -72
- package/dist/handlers/__test-utils__.js +0 -176
- package/dist/handlers/checkouts.d.ts +0 -37
- package/dist/handlers/checkouts.js +0 -377
- package/dist/handlers/knowledge-query.d.ts +0 -22
- package/dist/handlers/knowledge-query.js +0 -253
- package/dist/handlers/knowledge.d.ts +0 -12
- package/dist/handlers/knowledge.js +0 -108
- package/dist/handlers/roles.d.ts +0 -30
- package/dist/handlers/roles.js +0 -281
- package/dist/handlers/tasks.test.d.ts +0 -1
- package/dist/handlers/tasks.test.js +0 -431
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -532
- package/dist/validators.test.d.ts +0 -1
- package/dist/validators.test.js +0 -176
- package/src/tmpclaude-0078-cwd +0 -1
- package/src/tmpclaude-0ee1-cwd +0 -1
- package/src/tmpclaude-2dd5-cwd +0 -1
- package/src/tmpclaude-344c-cwd +0 -1
- package/src/tmpclaude-3860-cwd +0 -1
- package/src/tmpclaude-4b63-cwd +0 -1
- package/src/tmpclaude-5c73-cwd +0 -1
- package/src/tmpclaude-5ee3-cwd +0 -1
- package/src/tmpclaude-6795-cwd +0 -1
- package/src/tmpclaude-709e-cwd +0 -1
- package/src/tmpclaude-9839-cwd +0 -1
- package/src/tmpclaude-d829-cwd +0 -1
- package/src/tmpclaude-e072-cwd +0 -1
- package/src/tmpclaude-f6ee-cwd +0 -1
- package/tmpclaude-0439-cwd +0 -1
- package/tmpclaude-132f-cwd +0 -1
- package/tmpclaude-15bb-cwd +0 -1
- package/tmpclaude-165a-cwd +0 -1
- package/tmpclaude-1ba9-cwd +0 -1
- package/tmpclaude-21a3-cwd +0 -1
- package/tmpclaude-2a38-cwd +0 -1
- package/tmpclaude-2adf-cwd +0 -1
- package/tmpclaude-2f56-cwd +0 -1
- package/tmpclaude-3626-cwd +0 -1
- package/tmpclaude-3727-cwd +0 -1
- package/tmpclaude-40bc-cwd +0 -1
- package/tmpclaude-436f-cwd +0 -1
- package/tmpclaude-4783-cwd +0 -1
- package/tmpclaude-4b6d-cwd +0 -1
- package/tmpclaude-4ba4-cwd +0 -1
- package/tmpclaude-51e6-cwd +0 -1
- package/tmpclaude-5ecf-cwd +0 -1
- package/tmpclaude-6f97-cwd +0 -1
- package/tmpclaude-7fb2-cwd +0 -1
- package/tmpclaude-825c-cwd +0 -1
- package/tmpclaude-8baf-cwd +0 -1
- package/tmpclaude-8d9f-cwd +0 -1
- package/tmpclaude-975c-cwd +0 -1
- package/tmpclaude-9983-cwd +0 -1
- package/tmpclaude-a045-cwd +0 -1
- package/tmpclaude-ac4a-cwd +0 -1
- package/tmpclaude-b593-cwd +0 -1
- package/tmpclaude-b891-cwd +0 -1
- package/tmpclaude-c032-cwd +0 -1
- package/tmpclaude-cf43-cwd +0 -1
- package/tmpclaude-d040-cwd +0 -1
- package/tmpclaude-dcdd-cwd +0 -1
- package/tmpclaude-dcee-cwd +0 -1
- package/tmpclaude-e16b-cwd +0 -1
- package/tmpclaude-ecd2-cwd +0 -1
- package/tmpclaude-f48d-cwd +0 -1
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import type { HandlerContext, TokenUsage } from './types.js';
|
|
3
|
+
import {
|
|
4
|
+
createSprint,
|
|
5
|
+
updateSprint,
|
|
6
|
+
getSprint,
|
|
7
|
+
getSprints,
|
|
8
|
+
deleteSprint,
|
|
9
|
+
startSprint,
|
|
10
|
+
completeSprint,
|
|
11
|
+
addTaskToSprint,
|
|
12
|
+
removeTaskFromSprint,
|
|
13
|
+
getSprintBacklog,
|
|
14
|
+
getSprintVelocity,
|
|
15
|
+
} from './sprints.js';
|
|
16
|
+
import { ValidationError } from '../validators.js';
|
|
17
|
+
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Mock API Client
|
|
20
|
+
// ============================================================================
|
|
21
|
+
|
|
22
|
+
const mockApiClient = {
|
|
23
|
+
proxy: vi.fn(),
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
vi.mock('../api-client.js', () => ({
|
|
27
|
+
getApiClient: () => mockApiClient,
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// Test Utilities
|
|
32
|
+
// ============================================================================
|
|
33
|
+
|
|
34
|
+
function createMockContext(
|
|
35
|
+
options: { sessionId?: string | null } = {}
|
|
36
|
+
): HandlerContext {
|
|
37
|
+
const defaultTokenUsage: TokenUsage = {
|
|
38
|
+
callCount: 5,
|
|
39
|
+
totalTokens: 2500,
|
|
40
|
+
byTool: {},
|
|
41
|
+
byModel: {},
|
|
42
|
+
currentModel: null,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const sessionId = 'sessionId' in options ? options.sessionId : 'session-123';
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
auth: { userId: 'user-123', apiKeyId: 'api-key-123', scope: 'personal' as const },
|
|
49
|
+
session: {
|
|
50
|
+
instanceId: 'instance-abc',
|
|
51
|
+
currentSessionId: sessionId,
|
|
52
|
+
currentPersona: 'Wave',
|
|
53
|
+
currentRole: null,
|
|
54
|
+
tokenUsage: defaultTokenUsage,
|
|
55
|
+
},
|
|
56
|
+
updateSession: vi.fn(),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const VALID_UUID = '123e4567-e89b-12d3-a456-426614174000';
|
|
61
|
+
const VALID_UUID_2 = '223e4567-e89b-12d3-a456-426614174001';
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// createSprint Tests
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
describe('createSprint', () => {
|
|
68
|
+
beforeEach(() => vi.clearAllMocks());
|
|
69
|
+
|
|
70
|
+
it('should throw error for missing project_id', async () => {
|
|
71
|
+
const ctx = createMockContext();
|
|
72
|
+
|
|
73
|
+
await expect(
|
|
74
|
+
createSprint({ title: 'Sprint 1', start_date: '2025-01-01', end_date: '2025-01-14' }, ctx)
|
|
75
|
+
).rejects.toThrow(ValidationError);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should throw error for missing title', async () => {
|
|
79
|
+
const ctx = createMockContext();
|
|
80
|
+
|
|
81
|
+
await expect(
|
|
82
|
+
createSprint({ project_id: VALID_UUID, start_date: '2025-01-01', end_date: '2025-01-14' }, ctx)
|
|
83
|
+
).rejects.toThrow(ValidationError);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should throw error for missing start_date', async () => {
|
|
87
|
+
const ctx = createMockContext();
|
|
88
|
+
|
|
89
|
+
await expect(
|
|
90
|
+
createSprint({ project_id: VALID_UUID, title: 'Sprint 1', end_date: '2025-01-14' }, ctx)
|
|
91
|
+
).rejects.toThrow(ValidationError);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should throw error for missing end_date', async () => {
|
|
95
|
+
const ctx = createMockContext();
|
|
96
|
+
|
|
97
|
+
await expect(
|
|
98
|
+
createSprint({ project_id: VALID_UUID, title: 'Sprint 1', start_date: '2025-01-01' }, ctx)
|
|
99
|
+
).rejects.toThrow(ValidationError);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should throw error for invalid start_date format', async () => {
|
|
103
|
+
const ctx = createMockContext();
|
|
104
|
+
|
|
105
|
+
await expect(
|
|
106
|
+
createSprint({
|
|
107
|
+
project_id: VALID_UUID,
|
|
108
|
+
title: 'Sprint 1',
|
|
109
|
+
start_date: 'invalid',
|
|
110
|
+
end_date: '2025-01-14'
|
|
111
|
+
}, ctx)
|
|
112
|
+
).rejects.toThrow('Invalid start_date format');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should throw error when end_date is before start_date', async () => {
|
|
116
|
+
const ctx = createMockContext();
|
|
117
|
+
|
|
118
|
+
await expect(
|
|
119
|
+
createSprint({
|
|
120
|
+
project_id: VALID_UUID,
|
|
121
|
+
title: 'Sprint 1',
|
|
122
|
+
start_date: '2025-01-14',
|
|
123
|
+
end_date: '2025-01-01'
|
|
124
|
+
}, ctx)
|
|
125
|
+
).rejects.toThrow('end_date must be on or after start_date');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should create sprint successfully', async () => {
|
|
129
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
130
|
+
ok: true,
|
|
131
|
+
data: { success: true, sprint_id: VALID_UUID, sprint_number: 1 },
|
|
132
|
+
});
|
|
133
|
+
const ctx = createMockContext();
|
|
134
|
+
|
|
135
|
+
const result = await createSprint({
|
|
136
|
+
project_id: VALID_UUID,
|
|
137
|
+
title: 'Sprint 1',
|
|
138
|
+
start_date: '2025-01-01',
|
|
139
|
+
end_date: '2025-01-14',
|
|
140
|
+
}, ctx);
|
|
141
|
+
|
|
142
|
+
expect(result.result).toMatchObject({
|
|
143
|
+
success: true,
|
|
144
|
+
sprint_id: VALID_UUID,
|
|
145
|
+
sprint_number: 1,
|
|
146
|
+
status: 'planning',
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should create sprint with optional fields', async () => {
|
|
151
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
152
|
+
ok: true,
|
|
153
|
+
data: { success: true, sprint_id: VALID_UUID, sprint_number: 2 },
|
|
154
|
+
});
|
|
155
|
+
const ctx = createMockContext();
|
|
156
|
+
|
|
157
|
+
const result = await createSprint({
|
|
158
|
+
project_id: VALID_UUID,
|
|
159
|
+
title: 'Sprint 2',
|
|
160
|
+
goal: 'Complete feature X',
|
|
161
|
+
start_date: '2025-01-15',
|
|
162
|
+
end_date: '2025-01-28',
|
|
163
|
+
auto_deploy_on_completion: true,
|
|
164
|
+
deploy_environment: 'staging',
|
|
165
|
+
deploy_version_bump: 'minor',
|
|
166
|
+
}, ctx);
|
|
167
|
+
|
|
168
|
+
expect(result.result).toMatchObject({
|
|
169
|
+
success: true,
|
|
170
|
+
sprint_number: 2,
|
|
171
|
+
});
|
|
172
|
+
expect(mockApiClient.proxy).toHaveBeenCalledWith(
|
|
173
|
+
'create_sprint',
|
|
174
|
+
expect.objectContaining({
|
|
175
|
+
goal: 'Complete feature X',
|
|
176
|
+
auto_deploy_on_completion: true,
|
|
177
|
+
deploy_environment: 'staging',
|
|
178
|
+
}),
|
|
179
|
+
expect.any(Object)
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('should throw error when API call fails', async () => {
|
|
184
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
185
|
+
ok: false,
|
|
186
|
+
error: 'Database error',
|
|
187
|
+
});
|
|
188
|
+
const ctx = createMockContext();
|
|
189
|
+
|
|
190
|
+
await expect(
|
|
191
|
+
createSprint({
|
|
192
|
+
project_id: VALID_UUID,
|
|
193
|
+
title: 'Sprint 1',
|
|
194
|
+
start_date: '2025-01-01',
|
|
195
|
+
end_date: '2025-01-14',
|
|
196
|
+
}, ctx)
|
|
197
|
+
).rejects.toThrow('Failed to create sprint: Database error');
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// ============================================================================
|
|
202
|
+
// updateSprint Tests
|
|
203
|
+
// ============================================================================
|
|
204
|
+
|
|
205
|
+
describe('updateSprint', () => {
|
|
206
|
+
beforeEach(() => vi.clearAllMocks());
|
|
207
|
+
|
|
208
|
+
it('should throw error for missing sprint_id', async () => {
|
|
209
|
+
const ctx = createMockContext();
|
|
210
|
+
|
|
211
|
+
await expect(updateSprint({}, ctx)).rejects.toThrow(ValidationError);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('should throw error for invalid sprint_id UUID', async () => {
|
|
215
|
+
const ctx = createMockContext();
|
|
216
|
+
|
|
217
|
+
await expect(
|
|
218
|
+
updateSprint({ sprint_id: 'invalid' }, ctx)
|
|
219
|
+
).rejects.toThrow(ValidationError);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should update sprint successfully', async () => {
|
|
223
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
224
|
+
ok: true,
|
|
225
|
+
data: { success: true },
|
|
226
|
+
});
|
|
227
|
+
const ctx = createMockContext();
|
|
228
|
+
|
|
229
|
+
const result = await updateSprint({
|
|
230
|
+
sprint_id: VALID_UUID,
|
|
231
|
+
title: 'Updated Sprint',
|
|
232
|
+
goal: 'New goal',
|
|
233
|
+
}, ctx);
|
|
234
|
+
|
|
235
|
+
expect(result.result).toMatchObject({
|
|
236
|
+
success: true,
|
|
237
|
+
sprint_id: VALID_UUID,
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('should throw error when API call fails', async () => {
|
|
242
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
243
|
+
ok: false,
|
|
244
|
+
error: 'Sprint not found',
|
|
245
|
+
});
|
|
246
|
+
const ctx = createMockContext();
|
|
247
|
+
|
|
248
|
+
await expect(
|
|
249
|
+
updateSprint({ sprint_id: VALID_UUID, title: 'Test' }, ctx)
|
|
250
|
+
).rejects.toThrow('Failed to update sprint: Sprint not found');
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// ============================================================================
|
|
255
|
+
// getSprint Tests
|
|
256
|
+
// ============================================================================
|
|
257
|
+
|
|
258
|
+
describe('getSprint', () => {
|
|
259
|
+
beforeEach(() => vi.clearAllMocks());
|
|
260
|
+
|
|
261
|
+
it('should throw error for missing sprint_id', async () => {
|
|
262
|
+
const ctx = createMockContext();
|
|
263
|
+
|
|
264
|
+
await expect(getSprint({}, ctx)).rejects.toThrow(ValidationError);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it('should return sprint with tasks', async () => {
|
|
268
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
269
|
+
ok: true,
|
|
270
|
+
data: {
|
|
271
|
+
id: VALID_UUID,
|
|
272
|
+
title: 'Sprint 1',
|
|
273
|
+
sprint_number: 1,
|
|
274
|
+
sprint_status: 'active',
|
|
275
|
+
progress_percentage: 50,
|
|
276
|
+
velocity_points: 8,
|
|
277
|
+
committed_points: 13,
|
|
278
|
+
pre_tasks: [],
|
|
279
|
+
core_tasks: [{ id: 'task-1', title: 'Task 1' }],
|
|
280
|
+
post_tasks: [],
|
|
281
|
+
total_tasks: 1,
|
|
282
|
+
},
|
|
283
|
+
});
|
|
284
|
+
const ctx = createMockContext();
|
|
285
|
+
|
|
286
|
+
const result = await getSprint({ sprint_id: VALID_UUID }, ctx);
|
|
287
|
+
|
|
288
|
+
expect(result.result).toMatchObject({
|
|
289
|
+
id: VALID_UUID,
|
|
290
|
+
sprint_status: 'active',
|
|
291
|
+
velocity_points: 8,
|
|
292
|
+
committed_points: 13,
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// ============================================================================
|
|
298
|
+
// getSprints Tests
|
|
299
|
+
// ============================================================================
|
|
300
|
+
|
|
301
|
+
describe('getSprints', () => {
|
|
302
|
+
beforeEach(() => vi.clearAllMocks());
|
|
303
|
+
|
|
304
|
+
it('should throw error for missing project_id', async () => {
|
|
305
|
+
const ctx = createMockContext();
|
|
306
|
+
|
|
307
|
+
await expect(getSprints({}, ctx)).rejects.toThrow(ValidationError);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('should return empty list when no sprints', async () => {
|
|
311
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
312
|
+
ok: true,
|
|
313
|
+
data: { sprints: [], total_count: 0, has_more: false },
|
|
314
|
+
});
|
|
315
|
+
const ctx = createMockContext();
|
|
316
|
+
|
|
317
|
+
const result = await getSprints({ project_id: VALID_UUID }, ctx);
|
|
318
|
+
|
|
319
|
+
expect(result.result).toMatchObject({
|
|
320
|
+
sprints: [],
|
|
321
|
+
total_count: 0,
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('should return sprints filtered by status', async () => {
|
|
326
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
327
|
+
ok: true,
|
|
328
|
+
data: {
|
|
329
|
+
sprints: [{ id: VALID_UUID, sprint_status: 'active' }],
|
|
330
|
+
total_count: 1,
|
|
331
|
+
has_more: false,
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
const ctx = createMockContext();
|
|
335
|
+
|
|
336
|
+
const result = await getSprints({
|
|
337
|
+
project_id: VALID_UUID,
|
|
338
|
+
status: 'active',
|
|
339
|
+
}, ctx);
|
|
340
|
+
|
|
341
|
+
expect(mockApiClient.proxy).toHaveBeenCalledWith(
|
|
342
|
+
'get_sprints',
|
|
343
|
+
expect.objectContaining({ status: 'active' })
|
|
344
|
+
);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it('should throw error for invalid status', async () => {
|
|
348
|
+
const ctx = createMockContext();
|
|
349
|
+
|
|
350
|
+
await expect(
|
|
351
|
+
getSprints({ project_id: VALID_UUID, status: 'invalid_status' }, ctx)
|
|
352
|
+
).rejects.toThrow(ValidationError);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
// ============================================================================
|
|
357
|
+
// deleteSprint Tests
|
|
358
|
+
// ============================================================================
|
|
359
|
+
|
|
360
|
+
describe('deleteSprint', () => {
|
|
361
|
+
beforeEach(() => vi.clearAllMocks());
|
|
362
|
+
|
|
363
|
+
it('should throw error for missing sprint_id', async () => {
|
|
364
|
+
const ctx = createMockContext();
|
|
365
|
+
|
|
366
|
+
await expect(deleteSprint({}, ctx)).rejects.toThrow(ValidationError);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('should delete sprint successfully', async () => {
|
|
370
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
371
|
+
ok: true,
|
|
372
|
+
data: { success: true },
|
|
373
|
+
});
|
|
374
|
+
const ctx = createMockContext();
|
|
375
|
+
|
|
376
|
+
const result = await deleteSprint({ sprint_id: VALID_UUID }, ctx);
|
|
377
|
+
|
|
378
|
+
expect(result.result).toMatchObject({
|
|
379
|
+
success: true,
|
|
380
|
+
message: 'Sprint deleted. Tasks are preserved.',
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// ============================================================================
|
|
386
|
+
// startSprint Tests
|
|
387
|
+
// ============================================================================
|
|
388
|
+
|
|
389
|
+
describe('startSprint', () => {
|
|
390
|
+
beforeEach(() => vi.clearAllMocks());
|
|
391
|
+
|
|
392
|
+
it('should throw error for missing sprint_id', async () => {
|
|
393
|
+
const ctx = createMockContext();
|
|
394
|
+
|
|
395
|
+
await expect(startSprint({}, ctx)).rejects.toThrow(ValidationError);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it('should start sprint and lock committed_points', async () => {
|
|
399
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
400
|
+
ok: true,
|
|
401
|
+
data: {
|
|
402
|
+
success: true,
|
|
403
|
+
sprint_id: VALID_UUID,
|
|
404
|
+
sprint_status: 'active',
|
|
405
|
+
committed_points: 21,
|
|
406
|
+
message: 'Sprint started',
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
const ctx = createMockContext();
|
|
410
|
+
|
|
411
|
+
const result = await startSprint({ sprint_id: VALID_UUID }, ctx);
|
|
412
|
+
|
|
413
|
+
expect(result.result).toMatchObject({
|
|
414
|
+
success: true,
|
|
415
|
+
sprint_status: 'active',
|
|
416
|
+
committed_points: 21,
|
|
417
|
+
});
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('should throw error when sprint not in planning', async () => {
|
|
421
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
422
|
+
ok: false,
|
|
423
|
+
error: "Cannot start sprint in 'active' status",
|
|
424
|
+
});
|
|
425
|
+
const ctx = createMockContext();
|
|
426
|
+
|
|
427
|
+
await expect(
|
|
428
|
+
startSprint({ sprint_id: VALID_UUID }, ctx)
|
|
429
|
+
).rejects.toThrow("Cannot start sprint in 'active' status");
|
|
430
|
+
});
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
// ============================================================================
|
|
434
|
+
// completeSprint Tests
|
|
435
|
+
// ============================================================================
|
|
436
|
+
|
|
437
|
+
describe('completeSprint', () => {
|
|
438
|
+
beforeEach(() => vi.clearAllMocks());
|
|
439
|
+
|
|
440
|
+
it('should throw error for missing sprint_id', async () => {
|
|
441
|
+
const ctx = createMockContext();
|
|
442
|
+
|
|
443
|
+
await expect(completeSprint({}, ctx)).rejects.toThrow(ValidationError);
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
it('should complete sprint and calculate velocity', async () => {
|
|
447
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
448
|
+
ok: true,
|
|
449
|
+
data: {
|
|
450
|
+
success: true,
|
|
451
|
+
sprint_id: VALID_UUID,
|
|
452
|
+
sprint_status: 'completed',
|
|
453
|
+
velocity_points: 18,
|
|
454
|
+
committed_points: 21,
|
|
455
|
+
deployment_triggered: true,
|
|
456
|
+
message: 'Sprint completed',
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
const ctx = createMockContext();
|
|
460
|
+
|
|
461
|
+
const result = await completeSprint({
|
|
462
|
+
sprint_id: VALID_UUID,
|
|
463
|
+
skip_retrospective: true,
|
|
464
|
+
}, ctx);
|
|
465
|
+
|
|
466
|
+
expect(result.result).toMatchObject({
|
|
467
|
+
success: true,
|
|
468
|
+
sprint_status: 'completed',
|
|
469
|
+
velocity_points: 18,
|
|
470
|
+
committed_points: 21,
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
it('should transition through status phases', async () => {
|
|
475
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
476
|
+
ok: true,
|
|
477
|
+
data: {
|
|
478
|
+
success: true,
|
|
479
|
+
sprint_id: VALID_UUID,
|
|
480
|
+
sprint_status: 'in_review',
|
|
481
|
+
message: "Sprint moved to 'in_review'",
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
const ctx = createMockContext();
|
|
485
|
+
|
|
486
|
+
const result = await completeSprint({ sprint_id: VALID_UUID }, ctx);
|
|
487
|
+
|
|
488
|
+
expect(result.result).toMatchObject({
|
|
489
|
+
sprint_status: 'in_review',
|
|
490
|
+
});
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// ============================================================================
|
|
495
|
+
// addTaskToSprint Tests
|
|
496
|
+
// ============================================================================
|
|
497
|
+
|
|
498
|
+
describe('addTaskToSprint', () => {
|
|
499
|
+
beforeEach(() => vi.clearAllMocks());
|
|
500
|
+
|
|
501
|
+
it('should throw error for missing sprint_id', async () => {
|
|
502
|
+
const ctx = createMockContext();
|
|
503
|
+
|
|
504
|
+
await expect(
|
|
505
|
+
addTaskToSprint({ task_id: VALID_UUID_2 }, ctx)
|
|
506
|
+
).rejects.toThrow(ValidationError);
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
it('should throw error for missing task_id', async () => {
|
|
510
|
+
const ctx = createMockContext();
|
|
511
|
+
|
|
512
|
+
await expect(
|
|
513
|
+
addTaskToSprint({ sprint_id: VALID_UUID }, ctx)
|
|
514
|
+
).rejects.toThrow(ValidationError);
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
it('should throw error for negative story_points', async () => {
|
|
518
|
+
const ctx = createMockContext();
|
|
519
|
+
|
|
520
|
+
await expect(
|
|
521
|
+
addTaskToSprint({
|
|
522
|
+
sprint_id: VALID_UUID,
|
|
523
|
+
task_id: VALID_UUID_2,
|
|
524
|
+
story_points: -1,
|
|
525
|
+
}, ctx)
|
|
526
|
+
).rejects.toThrow('story_points must be a non-negative integer');
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
it('should add task to sprint with story points', async () => {
|
|
530
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
531
|
+
ok: true,
|
|
532
|
+
data: {
|
|
533
|
+
success: true,
|
|
534
|
+
sprint_id: VALID_UUID,
|
|
535
|
+
task_id: VALID_UUID_2,
|
|
536
|
+
story_points: 5,
|
|
537
|
+
phase: 'core',
|
|
538
|
+
committed_points: 21,
|
|
539
|
+
},
|
|
540
|
+
});
|
|
541
|
+
const ctx = createMockContext();
|
|
542
|
+
|
|
543
|
+
const result = await addTaskToSprint({
|
|
544
|
+
sprint_id: VALID_UUID,
|
|
545
|
+
task_id: VALID_UUID_2,
|
|
546
|
+
story_points: 5,
|
|
547
|
+
}, ctx);
|
|
548
|
+
|
|
549
|
+
expect(result.result).toMatchObject({
|
|
550
|
+
success: true,
|
|
551
|
+
task_id: VALID_UUID_2,
|
|
552
|
+
story_points: 5,
|
|
553
|
+
committed_points: 21,
|
|
554
|
+
});
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
it('should throw error when sprint not in planning', async () => {
|
|
558
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
559
|
+
ok: false,
|
|
560
|
+
error: "Cannot add tasks to sprint in 'active' status",
|
|
561
|
+
});
|
|
562
|
+
const ctx = createMockContext();
|
|
563
|
+
|
|
564
|
+
await expect(
|
|
565
|
+
addTaskToSprint({
|
|
566
|
+
sprint_id: VALID_UUID,
|
|
567
|
+
task_id: VALID_UUID_2,
|
|
568
|
+
}, ctx)
|
|
569
|
+
).rejects.toThrow("Cannot add tasks to sprint in 'active' status");
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
// ============================================================================
|
|
574
|
+
// removeTaskFromSprint Tests
|
|
575
|
+
// ============================================================================
|
|
576
|
+
|
|
577
|
+
describe('removeTaskFromSprint', () => {
|
|
578
|
+
beforeEach(() => vi.clearAllMocks());
|
|
579
|
+
|
|
580
|
+
it('should throw error for missing sprint_id', async () => {
|
|
581
|
+
const ctx = createMockContext();
|
|
582
|
+
|
|
583
|
+
await expect(
|
|
584
|
+
removeTaskFromSprint({ task_id: VALID_UUID_2 }, ctx)
|
|
585
|
+
).rejects.toThrow(ValidationError);
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
it('should throw error for missing task_id', async () => {
|
|
589
|
+
const ctx = createMockContext();
|
|
590
|
+
|
|
591
|
+
await expect(
|
|
592
|
+
removeTaskFromSprint({ sprint_id: VALID_UUID }, ctx)
|
|
593
|
+
).rejects.toThrow(ValidationError);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
it('should remove task from sprint', async () => {
|
|
597
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
598
|
+
ok: true,
|
|
599
|
+
data: {
|
|
600
|
+
success: true,
|
|
601
|
+
sprint_id: VALID_UUID,
|
|
602
|
+
task_id: VALID_UUID_2,
|
|
603
|
+
committed_points: 16,
|
|
604
|
+
message: 'Task removed from sprint',
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
const ctx = createMockContext();
|
|
608
|
+
|
|
609
|
+
const result = await removeTaskFromSprint({
|
|
610
|
+
sprint_id: VALID_UUID,
|
|
611
|
+
task_id: VALID_UUID_2,
|
|
612
|
+
}, ctx);
|
|
613
|
+
|
|
614
|
+
expect(result.result).toMatchObject({
|
|
615
|
+
success: true,
|
|
616
|
+
committed_points: 16,
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// ============================================================================
|
|
622
|
+
// getSprintBacklog Tests
|
|
623
|
+
// ============================================================================
|
|
624
|
+
|
|
625
|
+
describe('getSprintBacklog', () => {
|
|
626
|
+
beforeEach(() => vi.clearAllMocks());
|
|
627
|
+
|
|
628
|
+
it('should throw error for missing project_id', async () => {
|
|
629
|
+
const ctx = createMockContext();
|
|
630
|
+
|
|
631
|
+
await expect(getSprintBacklog({}, ctx)).rejects.toThrow(ValidationError);
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
it('should return available tasks', async () => {
|
|
635
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
636
|
+
ok: true,
|
|
637
|
+
data: {
|
|
638
|
+
tasks: [
|
|
639
|
+
{ id: 'task-1', title: 'Task 1', priority: 2, status: 'pending' },
|
|
640
|
+
{ id: 'task-2', title: 'Task 2', priority: 3, status: 'backlog' },
|
|
641
|
+
],
|
|
642
|
+
total_count: 2,
|
|
643
|
+
},
|
|
644
|
+
});
|
|
645
|
+
const ctx = createMockContext();
|
|
646
|
+
|
|
647
|
+
const result = await getSprintBacklog({ project_id: VALID_UUID }, ctx);
|
|
648
|
+
|
|
649
|
+
expect(result.result).toMatchObject({
|
|
650
|
+
tasks: expect.any(Array),
|
|
651
|
+
total_count: 2,
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
// ============================================================================
|
|
657
|
+
// getSprintVelocity Tests
|
|
658
|
+
// ============================================================================
|
|
659
|
+
|
|
660
|
+
describe('getSprintVelocity', () => {
|
|
661
|
+
beforeEach(() => vi.clearAllMocks());
|
|
662
|
+
|
|
663
|
+
it('should throw error for missing project_id', async () => {
|
|
664
|
+
const ctx = createMockContext();
|
|
665
|
+
|
|
666
|
+
await expect(getSprintVelocity({}, ctx)).rejects.toThrow(ValidationError);
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
it('should return velocity metrics', async () => {
|
|
670
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
671
|
+
ok: true,
|
|
672
|
+
data: {
|
|
673
|
+
sprints: [
|
|
674
|
+
{ sprint_number: 3, committed_points: 21, velocity_points: 18, completion_rate: 86 },
|
|
675
|
+
{ sprint_number: 2, committed_points: 18, velocity_points: 16, completion_rate: 89 },
|
|
676
|
+
{ sprint_number: 1, committed_points: 15, velocity_points: 15, completion_rate: 100 },
|
|
677
|
+
],
|
|
678
|
+
average_velocity: 16,
|
|
679
|
+
total_sprints: 3,
|
|
680
|
+
},
|
|
681
|
+
});
|
|
682
|
+
const ctx = createMockContext();
|
|
683
|
+
|
|
684
|
+
const result = await getSprintVelocity({ project_id: VALID_UUID }, ctx);
|
|
685
|
+
|
|
686
|
+
expect(result.result).toMatchObject({
|
|
687
|
+
average_velocity: 16,
|
|
688
|
+
total_sprints: 3,
|
|
689
|
+
});
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
it('should return empty metrics when no completed sprints', async () => {
|
|
693
|
+
mockApiClient.proxy.mockResolvedValue({
|
|
694
|
+
ok: true,
|
|
695
|
+
data: {
|
|
696
|
+
sprints: [],
|
|
697
|
+
average_velocity: 0,
|
|
698
|
+
total_sprints: 0,
|
|
699
|
+
},
|
|
700
|
+
});
|
|
701
|
+
const ctx = createMockContext();
|
|
702
|
+
|
|
703
|
+
const result = await getSprintVelocity({ project_id: VALID_UUID }, ctx);
|
|
704
|
+
|
|
705
|
+
expect(result.result).toMatchObject({
|
|
706
|
+
sprints: [],
|
|
707
|
+
average_velocity: 0,
|
|
708
|
+
total_sprints: 0,
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
});
|