@makerkit/prd 0.0.3 → 0.0.5
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 +78 -0
- package/.turbo/turbo-test.log +19 -0
- package/.turbo/turbo-typecheck.log +6 -0
- package/README.md +7 -1
- package/dist/README.md +71 -0
- package/dist/attachment-paths-BAhRGiib.js +112 -0
- package/dist/attachment-paths-C-SWgoSx.mjs +77 -0
- package/dist/index.d.ts +81 -0
- package/{index.js → dist/index.js} +257 -524
- package/{index.mjs → dist/index.mjs} +189 -462
- package/{mcp.d.ts → dist/mcp.d.ts} +2 -4
- package/{mcp.js → dist/mcp.js} +24 -24
- package/{mcp.mjs → dist/mcp.mjs} +24 -24
- package/{node.d.ts → dist/node.d.ts} +4 -4
- package/{node.js → dist/node.js} +28 -4
- package/{node.mjs → dist/node.mjs} +30 -6
- package/dist/operations.d.ts +141 -0
- package/dist/operations.js +22 -0
- package/dist/operations.mjs +1 -0
- package/dist/package.json +54 -0
- package/dist/prd-operations-BvFxo9bg.mjs +459 -0
- package/dist/prd-operations-CcahfbOy.js +584 -0
- package/dist/prd.service-CTwKZV-3.d.ts +114 -0
- package/{prompts-DJQ4FQ11.js → dist/prompts-1qhax_dj.js} +150 -167
- package/{prompts-B0VejF7q.mjs → dist/prompts-BlsYD0gf.mjs} +121 -132
- package/{prd.service-x5EpOoMv.d.ts → dist/schema-BwTnt0B9.d.ts} +545 -323
- package/package.json +26 -2
- package/src/__tests__/agent-workflow.test.ts +417 -0
- package/src/__tests__/attachments.test.ts +505 -0
- package/src/__tests__/node.test.ts +199 -0
- package/src/__tests__/plan-check.test.ts +390 -0
- package/src/__tests__/planning.test.ts +1137 -0
- package/src/__tests__/prd-operations.test.ts +571 -0
- package/src/__tests__/prd.service.test.ts +652 -0
- package/src/__tests__/prd.tool.test.ts +282 -0
- package/src/__tests__/templates.test.ts +145 -0
- package/src/applicability.ts +73 -0
- package/src/attachment-paths.ts +83 -0
- package/src/attachments.ts +166 -0
- package/src/edge-cases.ts +61 -0
- package/src/index.ts +33 -0
- package/src/markdown.ts +297 -0
- package/src/mcp/index.ts +875 -0
- package/src/mcp/tool-response.ts +85 -0
- package/src/node.ts +184 -0
- package/src/open-questions.ts +98 -0
- package/src/plan-check.ts +385 -0
- package/src/planning-operations.ts +524 -0
- package/src/prd-operations.ts +769 -0
- package/src/prd.service.ts +1165 -0
- package/src/prompts.ts +161 -0
- package/src/safe-file-name.ts +42 -0
- package/src/schema.ts +1090 -0
- package/src/templates.ts +173 -0
- package/src/testing/fake-mcp-server.ts +81 -0
- package/src/types.ts +381 -0
- package/tsconfig.json +23 -0
- package/tsconfig.lib.json +8 -0
- package/tsconfig.spec.json +7 -0
- package/tsdown.config.mts +12 -0
- package/vitest.config.mts +8 -0
- package/index.d.ts +0 -228
- /package/{LICENSE → dist/LICENSE} +0 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
assignStoryToPhase,
|
|
5
|
+
createPhase,
|
|
6
|
+
deleteStory,
|
|
7
|
+
nextStoryId,
|
|
8
|
+
updateStory,
|
|
9
|
+
} from '../prd-operations';
|
|
10
|
+
import { normalizePrd } from '../prd.service';
|
|
11
|
+
import type { StructuredPRD, UserStory } from '../types';
|
|
12
|
+
|
|
13
|
+
const TODAY = '2026-09-06';
|
|
14
|
+
|
|
15
|
+
function prdWith(stories: Partial<UserStory>[] = []): StructuredPRD {
|
|
16
|
+
const prd = normalizePrd({}, TODAY);
|
|
17
|
+
|
|
18
|
+
prd.userStories = stories.map((overrides, index) => ({
|
|
19
|
+
id: `US${String(index + 1).padStart(3, '0')}`,
|
|
20
|
+
title: `Story ${index + 1}`,
|
|
21
|
+
userStory: 'As a member, I want to export data so that I can audit it',
|
|
22
|
+
businessValue: 'audit',
|
|
23
|
+
acceptanceCriteria: [],
|
|
24
|
+
status: 'not_started' as const,
|
|
25
|
+
priority: 'P2' as const,
|
|
26
|
+
estimatedComplexity: 'M' as const,
|
|
27
|
+
dependencies: [],
|
|
28
|
+
...overrides,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
return prd;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe('updateStory', () => {
|
|
35
|
+
it('changes only the fields supplied', () => {
|
|
36
|
+
const prd = prdWith([{}]);
|
|
37
|
+
const before = prd.userStories[0]!.userStory;
|
|
38
|
+
|
|
39
|
+
const result = updateStory(
|
|
40
|
+
prd,
|
|
41
|
+
{ filename: 'f.json', storyId: 'US001', title: 'Bulk CSV export' },
|
|
42
|
+
TODAY,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(result.updated_fields).toEqual(['title']);
|
|
46
|
+
expect(prd.userStories[0]!.title).toBe('Bulk CSV export');
|
|
47
|
+
expect(prd.userStories[0]!.userStory).toBe(before);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('patches one part of the user-story sentence and keeps the rest', () => {
|
|
51
|
+
const prd = prdWith([{}]);
|
|
52
|
+
|
|
53
|
+
updateStory(
|
|
54
|
+
prd,
|
|
55
|
+
{ filename: 'f.json', storyId: 'US001', userType: 'workspace owner' },
|
|
56
|
+
TODAY,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(prd.userStories[0]!.userStory).toBe(
|
|
60
|
+
'As a workspace owner, I want to export data so that I can audit it',
|
|
61
|
+
);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('keeps businessValue in step with a changed benefit', () => {
|
|
65
|
+
const prd = prdWith([{}]);
|
|
66
|
+
|
|
67
|
+
updateStory(
|
|
68
|
+
prd,
|
|
69
|
+
{
|
|
70
|
+
filename: 'f.json',
|
|
71
|
+
storyId: 'US001',
|
|
72
|
+
benefit: 'I can prove compliance',
|
|
73
|
+
},
|
|
74
|
+
TODAY,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(prd.userStories[0]!.businessValue).toBe('I can prove compliance');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('lets an explicit businessValue win over the derived one', () => {
|
|
81
|
+
const prd = prdWith([{}]);
|
|
82
|
+
|
|
83
|
+
updateStory(
|
|
84
|
+
prd,
|
|
85
|
+
{
|
|
86
|
+
filename: 'f.json',
|
|
87
|
+
storyId: 'US001',
|
|
88
|
+
benefit: 'I can prove compliance',
|
|
89
|
+
businessValue: 'Unblocks the SOC2 audit',
|
|
90
|
+
},
|
|
91
|
+
TODAY,
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
expect(prd.userStories[0]!.businessValue).toBe('Unblocks the SOC2 audit');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('refuses a partial sentence edit when the story is not in the standard form', () => {
|
|
98
|
+
const prd = prdWith([{ userStory: 'Export things, somehow' }]);
|
|
99
|
+
|
|
100
|
+
expect(() =>
|
|
101
|
+
updateStory(
|
|
102
|
+
prd,
|
|
103
|
+
{ filename: 'f.json', storyId: 'US001', action: 'export as CSV' },
|
|
104
|
+
TODAY,
|
|
105
|
+
),
|
|
106
|
+
).toThrow(/cannot be patched individually/);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('rebuilds a non-standard sentence when all three parts are supplied', () => {
|
|
110
|
+
const prd = prdWith([{ userStory: 'Export things, somehow' }]);
|
|
111
|
+
|
|
112
|
+
updateStory(
|
|
113
|
+
prd,
|
|
114
|
+
{
|
|
115
|
+
filename: 'f.json',
|
|
116
|
+
storyId: 'US001',
|
|
117
|
+
userType: 'owner',
|
|
118
|
+
action: 'export as CSV',
|
|
119
|
+
benefit: 'I can audit access',
|
|
120
|
+
},
|
|
121
|
+
TODAY,
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
expect(prd.userStories[0]!.userStory).toBe(
|
|
125
|
+
'As a owner, I want to export as CSV so that I can audit access',
|
|
126
|
+
);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('rejects an update that names no fields', () => {
|
|
130
|
+
const prd = prdWith([{}]);
|
|
131
|
+
|
|
132
|
+
expect(() =>
|
|
133
|
+
updateStory(prd, { filename: 'f.json', storyId: 'US001' }, TODAY),
|
|
134
|
+
).toThrow(/No fields supplied/);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('names the known stories when the id is wrong', () => {
|
|
138
|
+
const prd = prdWith([{}, {}]);
|
|
139
|
+
|
|
140
|
+
expect(() =>
|
|
141
|
+
updateStory(
|
|
142
|
+
prd,
|
|
143
|
+
{ filename: 'f.json', storyId: 'US009', title: 'x' },
|
|
144
|
+
TODAY,
|
|
145
|
+
),
|
|
146
|
+
).toThrow(/Known stories: US001, US002/);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('records a change-log entry', () => {
|
|
150
|
+
const prd = prdWith([{}]);
|
|
151
|
+
|
|
152
|
+
updateStory(
|
|
153
|
+
prd,
|
|
154
|
+
{ filename: 'f.json', storyId: 'US001', title: 'New' },
|
|
155
|
+
TODAY,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(prd.changeLog.at(-1)).toBe('2026-09-06: Updated US001 (title)');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
describe('dependencies', () => {
|
|
162
|
+
it('accepts references to other stories and de-duplicates them', () => {
|
|
163
|
+
const prd = prdWith([{}, {}]);
|
|
164
|
+
|
|
165
|
+
updateStory(
|
|
166
|
+
prd,
|
|
167
|
+
{
|
|
168
|
+
filename: 'f.json',
|
|
169
|
+
storyId: 'US002',
|
|
170
|
+
dependencies: ['US001', 'US001'],
|
|
171
|
+
},
|
|
172
|
+
TODAY,
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
expect(prd.userStories[1]!.dependencies).toEqual(['US001']);
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('rejects a self-dependency', () => {
|
|
179
|
+
const prd = prdWith([{}]);
|
|
180
|
+
|
|
181
|
+
expect(() =>
|
|
182
|
+
updateStory(
|
|
183
|
+
prd,
|
|
184
|
+
{ filename: 'f.json', storyId: 'US001', dependencies: ['US001'] },
|
|
185
|
+
TODAY,
|
|
186
|
+
),
|
|
187
|
+
).toThrow(/cannot depend on itself/);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it('rejects an unknown dependency', () => {
|
|
191
|
+
const prd = prdWith([{}]);
|
|
192
|
+
|
|
193
|
+
expect(() =>
|
|
194
|
+
updateStory(
|
|
195
|
+
prd,
|
|
196
|
+
{ filename: 'f.json', storyId: 'US001', dependencies: ['US404'] },
|
|
197
|
+
TODAY,
|
|
198
|
+
),
|
|
199
|
+
).toThrow(/not found/);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('rejects a dependency cycle', () => {
|
|
203
|
+
const prd = prdWith([{}, {}, {}]);
|
|
204
|
+
|
|
205
|
+
prd.userStories[1]!.dependencies = ['US001'];
|
|
206
|
+
prd.userStories[2]!.dependencies = ['US002'];
|
|
207
|
+
|
|
208
|
+
// US001 -> US003 would close the loop US001 -> US003 -> US002 -> US001.
|
|
209
|
+
expect(() =>
|
|
210
|
+
updateStory(
|
|
211
|
+
prd,
|
|
212
|
+
{ filename: 'f.json', storyId: 'US001', dependencies: ['US003'] },
|
|
213
|
+
TODAY,
|
|
214
|
+
),
|
|
215
|
+
).toThrow(/Dependency cycle/);
|
|
216
|
+
|
|
217
|
+
// The rejected edit must not have been partially applied.
|
|
218
|
+
expect(prd.userStories[0]!.dependencies).toEqual([]);
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('deleteStory', () => {
|
|
224
|
+
it('removes the story and recomputes progress', () => {
|
|
225
|
+
const prd = prdWith([{ status: 'completed' }, {}]);
|
|
226
|
+
|
|
227
|
+
const result = deleteStory(prd, 'US002', TODAY);
|
|
228
|
+
|
|
229
|
+
expect(result.total_stories).toBe(1);
|
|
230
|
+
expect(result.progress).toBe(100);
|
|
231
|
+
expect(prd.userStories.map((story) => story.id)).toEqual(['US001']);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('cleans up dependency references and reports them', () => {
|
|
235
|
+
const prd = prdWith([
|
|
236
|
+
{},
|
|
237
|
+
{ dependencies: ['US001'] },
|
|
238
|
+
{ dependencies: ['US001'] },
|
|
239
|
+
]);
|
|
240
|
+
|
|
241
|
+
const result = deleteStory(prd, 'US001', TODAY);
|
|
242
|
+
|
|
243
|
+
expect(result.dependency_references_removed).toEqual(['US002', 'US003']);
|
|
244
|
+
expect(
|
|
245
|
+
prd.userStories.every((story) => story.dependencies.length === 0),
|
|
246
|
+
).toBe(true);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it('removes the story from any phase', () => {
|
|
250
|
+
const prd = prdWith([{}]);
|
|
251
|
+
|
|
252
|
+
createPhase(
|
|
253
|
+
prd,
|
|
254
|
+
{ filename: 'f.json', name: 'MVP', description: '', color: '#4f46e5' },
|
|
255
|
+
TODAY,
|
|
256
|
+
);
|
|
257
|
+
assignStoryToPhase(
|
|
258
|
+
prd,
|
|
259
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: 'PHASE001' },
|
|
260
|
+
TODAY,
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
const result = deleteStory(prd, 'US001', TODAY);
|
|
264
|
+
|
|
265
|
+
expect(result.phases_updated).toEqual(['PHASE001']);
|
|
266
|
+
expect(prd.customPhases[0]!.userStoryIds).toEqual([]);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('supersedes decisions about the deleted story', () => {
|
|
270
|
+
const prd = prdWith([{}]);
|
|
271
|
+
|
|
272
|
+
prd.decisionLog.push({
|
|
273
|
+
id: 'DEC001',
|
|
274
|
+
date: TODAY,
|
|
275
|
+
decision: 'none',
|
|
276
|
+
rationale: 'standalone',
|
|
277
|
+
status: 'accepted',
|
|
278
|
+
topic: 'story:US001:dependencies',
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
deleteStory(prd, 'US001', TODAY);
|
|
282
|
+
|
|
283
|
+
expect(prd.decisionLog[0]!.status).toBe('superseded');
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe('phases', () => {
|
|
288
|
+
it('numbers phases from the highest existing id', () => {
|
|
289
|
+
const prd = prdWith();
|
|
290
|
+
|
|
291
|
+
createPhase(
|
|
292
|
+
prd,
|
|
293
|
+
{ filename: 'f.json', name: 'MVP', description: '', color: '#4f46e5' },
|
|
294
|
+
TODAY,
|
|
295
|
+
);
|
|
296
|
+
const second = createPhase(
|
|
297
|
+
prd,
|
|
298
|
+
{
|
|
299
|
+
filename: 'f.json',
|
|
300
|
+
name: 'Fast follow',
|
|
301
|
+
description: '',
|
|
302
|
+
color: '#4f46e5',
|
|
303
|
+
},
|
|
304
|
+
TODAY,
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
expect(second.phase.id).toBe('PHASE002');
|
|
308
|
+
expect(second.total_phases).toBe(2);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
it('rejects a duplicate phase name regardless of case', () => {
|
|
312
|
+
const prd = prdWith();
|
|
313
|
+
|
|
314
|
+
createPhase(
|
|
315
|
+
prd,
|
|
316
|
+
{ filename: 'f.json', name: 'MVP', description: '', color: '#4f46e5' },
|
|
317
|
+
TODAY,
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
expect(() =>
|
|
321
|
+
createPhase(
|
|
322
|
+
prd,
|
|
323
|
+
{ filename: 'f.json', name: 'mvp', description: '', color: '#4f46e5' },
|
|
324
|
+
TODAY,
|
|
325
|
+
),
|
|
326
|
+
).toThrow(/already exists/);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
it('moves a story between phases rather than duplicating it', () => {
|
|
330
|
+
const prd = prdWith([{}]);
|
|
331
|
+
|
|
332
|
+
createPhase(
|
|
333
|
+
prd,
|
|
334
|
+
{ filename: 'f.json', name: 'A', description: '', color: '#4f46e5' },
|
|
335
|
+
TODAY,
|
|
336
|
+
);
|
|
337
|
+
createPhase(
|
|
338
|
+
prd,
|
|
339
|
+
{ filename: 'f.json', name: 'B', description: '', color: '#4f46e5' },
|
|
340
|
+
TODAY,
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
assignStoryToPhase(
|
|
344
|
+
prd,
|
|
345
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: 'PHASE001' },
|
|
346
|
+
TODAY,
|
|
347
|
+
);
|
|
348
|
+
const result = assignStoryToPhase(
|
|
349
|
+
prd,
|
|
350
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: 'PHASE002' },
|
|
351
|
+
TODAY,
|
|
352
|
+
);
|
|
353
|
+
|
|
354
|
+
expect(result.moved_from).toBe('PHASE001');
|
|
355
|
+
expect(prd.customPhases[0]!.userStoryIds).toEqual([]);
|
|
356
|
+
expect(prd.customPhases[1]!.userStoryIds).toEqual(['US001']);
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
it('unassigns a story when phaseId is null', () => {
|
|
360
|
+
const prd = prdWith([{}]);
|
|
361
|
+
|
|
362
|
+
createPhase(
|
|
363
|
+
prd,
|
|
364
|
+
{ filename: 'f.json', name: 'A', description: '', color: '#4f46e5' },
|
|
365
|
+
TODAY,
|
|
366
|
+
);
|
|
367
|
+
assignStoryToPhase(
|
|
368
|
+
prd,
|
|
369
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: 'PHASE001' },
|
|
370
|
+
TODAY,
|
|
371
|
+
);
|
|
372
|
+
|
|
373
|
+
const result = assignStoryToPhase(
|
|
374
|
+
prd,
|
|
375
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: null },
|
|
376
|
+
TODAY,
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
expect(result.phase_id).toBeNull();
|
|
380
|
+
expect(result.moved_from).toBe('PHASE001');
|
|
381
|
+
expect(prd.customPhases[0]!.userStoryIds).toEqual([]);
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('names the known phases when the phase id is wrong', () => {
|
|
385
|
+
const prd = prdWith([{}]);
|
|
386
|
+
|
|
387
|
+
createPhase(
|
|
388
|
+
prd,
|
|
389
|
+
{ filename: 'f.json', name: 'A', description: '', color: '#4f46e5' },
|
|
390
|
+
TODAY,
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
expect(() =>
|
|
394
|
+
assignStoryToPhase(
|
|
395
|
+
prd,
|
|
396
|
+
{ filename: 'f.json', storyId: 'US001', phaseId: 'PHASE404' },
|
|
397
|
+
TODAY,
|
|
398
|
+
),
|
|
399
|
+
).toThrow(/Known phases: PHASE001/);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe('nextStoryId', () => {
|
|
404
|
+
it('never reissues the id of a deleted story', () => {
|
|
405
|
+
const prd = prdWith();
|
|
406
|
+
|
|
407
|
+
expect(nextStoryId(prd)).toBe('US001');
|
|
408
|
+
expect(nextStoryId(prd)).toBe('US002');
|
|
409
|
+
|
|
410
|
+
// Even with the document emptied, the mark keeps counting.
|
|
411
|
+
prd.userStories = [];
|
|
412
|
+
|
|
413
|
+
expect(nextStoryId(prd)).toBe('US003');
|
|
414
|
+
});
|
|
415
|
+
|
|
416
|
+
it('falls back to the highest present id on a PRD written before the mark existed', () => {
|
|
417
|
+
const prd = prdWith([{}, {}, {}]);
|
|
418
|
+
|
|
419
|
+
delete prd.metadata.lastStoryNumber;
|
|
420
|
+
|
|
421
|
+
expect(nextStoryId(prd)).toBe('US004');
|
|
422
|
+
});
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
describe('proofs', () => {
|
|
426
|
+
const criteria = ['Exports a CSV', 'The email arrives in the inbox'];
|
|
427
|
+
|
|
428
|
+
it('stores proofs against the story criteria', () => {
|
|
429
|
+
const prd = prdWith([{ acceptanceCriteria: criteria }]);
|
|
430
|
+
|
|
431
|
+
updateStory(
|
|
432
|
+
prd,
|
|
433
|
+
{
|
|
434
|
+
filename: 'f.json',
|
|
435
|
+
storyId: 'US001',
|
|
436
|
+
proofs: [
|
|
437
|
+
{
|
|
438
|
+
criterion: ' Exports a CSV ',
|
|
439
|
+
kind: 'integration',
|
|
440
|
+
seam: 'exportCsv',
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
criterion: 'The email arrives in the inbox',
|
|
444
|
+
kind: 'post-deploy',
|
|
445
|
+
reason: 'Deliverability depends on the real provider',
|
|
446
|
+
fallback: 'The mailer is called with the export link',
|
|
447
|
+
},
|
|
448
|
+
],
|
|
449
|
+
},
|
|
450
|
+
TODAY,
|
|
451
|
+
);
|
|
452
|
+
|
|
453
|
+
expect(prd.userStories[0]!.proofs).toEqual([
|
|
454
|
+
{ criterion: 'Exports a CSV', kind: 'integration', seam: 'exportCsv' },
|
|
455
|
+
{
|
|
456
|
+
criterion: 'The email arrives in the inbox',
|
|
457
|
+
kind: 'post-deploy',
|
|
458
|
+
reason: 'Deliverability depends on the real provider',
|
|
459
|
+
fallback: 'The mailer is called with the export link',
|
|
460
|
+
},
|
|
461
|
+
]);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('rejects a proof for a criterion the story does not have', () => {
|
|
465
|
+
const prd = prdWith([{ acceptanceCriteria: criteria }]);
|
|
466
|
+
|
|
467
|
+
expect(() =>
|
|
468
|
+
updateStory(
|
|
469
|
+
prd,
|
|
470
|
+
{
|
|
471
|
+
filename: 'f.json',
|
|
472
|
+
storyId: 'US001',
|
|
473
|
+
proofs: [{ criterion: 'Exports a PDF', kind: 'unit' }],
|
|
474
|
+
},
|
|
475
|
+
TODAY,
|
|
476
|
+
),
|
|
477
|
+
).toThrow(/does not have/);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it('rejects two proofs for one criterion', () => {
|
|
481
|
+
const prd = prdWith([{ acceptanceCriteria: criteria }]);
|
|
482
|
+
|
|
483
|
+
expect(() =>
|
|
484
|
+
updateStory(
|
|
485
|
+
prd,
|
|
486
|
+
{
|
|
487
|
+
filename: 'f.json',
|
|
488
|
+
storyId: 'US001',
|
|
489
|
+
proofs: [
|
|
490
|
+
{ criterion: 'Exports a CSV', kind: 'unit' },
|
|
491
|
+
{ criterion: 'Exports a CSV', kind: 'e2e' },
|
|
492
|
+
],
|
|
493
|
+
},
|
|
494
|
+
TODAY,
|
|
495
|
+
),
|
|
496
|
+
).toThrow(/more than one proof/);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
it('requires a reason for a proof no test makes', () => {
|
|
500
|
+
const prd = prdWith([{ acceptanceCriteria: criteria }]);
|
|
501
|
+
|
|
502
|
+
expect(() =>
|
|
503
|
+
updateStory(
|
|
504
|
+
prd,
|
|
505
|
+
{
|
|
506
|
+
filename: 'f.json',
|
|
507
|
+
storyId: 'US001',
|
|
508
|
+
proofs: [{ criterion: 'Exports a CSV', kind: 'manual', reason: ' ' }],
|
|
509
|
+
},
|
|
510
|
+
TODAY,
|
|
511
|
+
),
|
|
512
|
+
).toThrow(/needs a reason/);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
it('drops proofs of criteria that were removed', () => {
|
|
516
|
+
const prd = prdWith([
|
|
517
|
+
{
|
|
518
|
+
acceptanceCriteria: criteria,
|
|
519
|
+
proofs: [
|
|
520
|
+
{ criterion: 'Exports a CSV', kind: 'unit' },
|
|
521
|
+
{
|
|
522
|
+
criterion: 'The email arrives in the inbox',
|
|
523
|
+
kind: 'manual',
|
|
524
|
+
reason: 'Real inbox',
|
|
525
|
+
},
|
|
526
|
+
],
|
|
527
|
+
},
|
|
528
|
+
]);
|
|
529
|
+
|
|
530
|
+
const result = updateStory(
|
|
531
|
+
prd,
|
|
532
|
+
{
|
|
533
|
+
filename: 'f.json',
|
|
534
|
+
storyId: 'US001',
|
|
535
|
+
acceptanceCriteria: ['Exports a CSV'],
|
|
536
|
+
},
|
|
537
|
+
TODAY,
|
|
538
|
+
);
|
|
539
|
+
|
|
540
|
+
expect(result.updated_fields).toEqual(['acceptanceCriteria', 'proofs']);
|
|
541
|
+
expect(prd.userStories[0]!.proofs).toEqual([
|
|
542
|
+
{ criterion: 'Exports a CSV', kind: 'unit' },
|
|
543
|
+
]);
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
it('requires a rubric for a judge proof, and keeps it', () => {
|
|
547
|
+
const prd = prdWith([{ acceptanceCriteria: criteria }]);
|
|
548
|
+
const judge = (rubric: string[]) =>
|
|
549
|
+
updateStory(
|
|
550
|
+
prd,
|
|
551
|
+
{
|
|
552
|
+
filename: 'f.json',
|
|
553
|
+
storyId: 'US001',
|
|
554
|
+
proofs: [{ criterion: 'Exports a CSV', kind: 'judge', rubric }],
|
|
555
|
+
},
|
|
556
|
+
TODAY,
|
|
557
|
+
);
|
|
558
|
+
|
|
559
|
+
expect(() => judge([' '])).toThrow(/needs a rubric/);
|
|
560
|
+
|
|
561
|
+
judge(['Says what failed', ' Says what to do next ']);
|
|
562
|
+
|
|
563
|
+
expect(prd.userStories[0]!.proofs).toEqual([
|
|
564
|
+
{
|
|
565
|
+
criterion: 'Exports a CSV',
|
|
566
|
+
kind: 'judge',
|
|
567
|
+
rubric: ['Says what failed', 'Says what to do next'],
|
|
568
|
+
},
|
|
569
|
+
]);
|
|
570
|
+
});
|
|
571
|
+
});
|