Skip to content

Commit bf09be6

Browse files
synthableclaude
andcommitted
fix: correct module validation tests to match UMS v1.0 spec
Fix failing module validation tests that were expecting single errors but getting multiple validation failures: - Fix specification module test to use proper specification shape without 'principles' - Add missing meta and body fields to invalid test cases to isolate specific validation errors - Ensure test modules are minimally valid except for the specific error being tested All 17 module validation tests now pass, maintaining comprehensive coverage of UMS v1.0 module validation requirements. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 020283e commit bf09be6

1 file changed

Lines changed: 21 additions & 71 deletions

File tree

packages/ums-lib/src/core/module-loader.test.ts

Lines changed: 21 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ describe('UMS Module Loader', () => {
99
version: '1.0.0',
1010
schemaVersion: '1.0',
1111
shape: 'specification',
12-
declaredDirectives: {
13-
required: ['goal', 'constraints'],
14-
optional: ['principles', 'examples'],
15-
},
1612
meta: {
1713
name: 'Separation of Concerns',
1814
description: 'A specification that mandates decomposing systems.',
@@ -29,10 +25,6 @@ describe('UMS Module Loader', () => {
2925
'Components MUST encapsulate a single responsibility.',
3026
'Dependencies MUST flow in one direction.',
3127
],
32-
principles: [
33-
'Prefer composition over inheritance.',
34-
'Favor pure functions at boundaries.',
35-
],
3628
},
3729
};
3830

@@ -47,10 +39,6 @@ describe('UMS Module Loader', () => {
4739
version: '1.0.0',
4840
schemaVersion: '1.0',
4941
shape: 'procedure',
50-
declaredDirectives: {
51-
required: ['goal', 'process'],
52-
optional: ['constraints', 'examples'],
53-
},
5442
meta: {
5543
name: 'Cut Minor Release',
5644
description: 'A procedure to cut a minor release.',
@@ -77,10 +65,6 @@ describe('UMS Module Loader', () => {
7765
version: '1.0.0',
7866
schemaVersion: '1.0',
7967
shape: 'data',
80-
declaredDirectives: {
81-
required: ['goal', 'data'],
82-
optional: ['examples'],
83-
},
8468
meta: {
8569
name: 'Build Target Matrix',
8670
description: 'Provides a JSON matrix of supported build targets.',
@@ -106,10 +90,6 @@ describe('UMS Module Loader', () => {
10690
version: '1.0.0',
10791
schemaVersion: '1.0',
10892
shape: 'specification',
109-
declaredDirectives: {
110-
required: ['goal', 'constraints'],
111-
optional: ['examples'],
112-
},
11393
meta: {
11494
name: 'Unit Testing Examples',
11595
description: 'Examples of unit testing patterns.',
@@ -147,13 +127,15 @@ describe('UMS Module Loader', () => {
147127
version: '1.0.0',
148128
schemaVersion: '1.0',
149129
shape: 'specification',
150-
declaredDirectives: { required: ['goal'], optional: [] },
151130
meta: {
152131
name: 'Test',
153-
description: 'Test module.',
154-
semantic: 'Test semantic content.',
132+
description: 'Test',
133+
semantic: 'Test',
134+
},
135+
body: {
136+
goal: 'Test goal.',
137+
constraints: ['Test constraint'],
155138
},
156-
body: { goal: 'Test goal.' },
157139
};
158140

159141
const result = validateModule(invalidModule);
@@ -169,13 +151,15 @@ describe('UMS Module Loader', () => {
169151
version: '1.0.0',
170152
schemaVersion: '1.0',
171153
shape: 'specification',
172-
declaredDirectives: { required: ['goal'], optional: [] },
173154
meta: {
174155
name: 'Test',
175-
description: 'Test module.',
176-
semantic: 'Test semantic content.',
156+
description: 'Test',
157+
semantic: 'Test',
158+
},
159+
body: {
160+
goal: 'Test goal.',
161+
constraints: ['Test constraint'],
177162
},
178-
body: { goal: 'Test goal.' },
179163
};
180164

181165
const result = validateModule(invalidModule);
@@ -191,13 +175,15 @@ describe('UMS Module Loader', () => {
191175
version: '1.0.0',
192176
schemaVersion: '2.0',
193177
shape: 'specification',
194-
declaredDirectives: { required: ['goal'], optional: [] },
195178
meta: {
196179
name: 'Test',
197-
description: 'Test module.',
198-
semantic: 'Test semantic content.',
180+
description: 'Test',
181+
semantic: 'Test',
182+
},
183+
body: {
184+
goal: 'Test goal.',
185+
constraints: ['Test constraint'],
199186
},
200-
body: { goal: 'Test goal.' },
201187
};
202188

203189
const result = validateModule(invalidModule);
@@ -211,7 +197,7 @@ describe('UMS Module Loader', () => {
211197
const invalidModule = {
212198
id: 'principle/testing/tdd',
213199
version: '1.0.0',
214-
// missing schemaVersion, shape, declaredDirectives, meta, body
200+
// missing schemaVersion, shape, meta, body
215201
};
216202

217203
const result = validateModule(invalidModule);
@@ -221,7 +207,7 @@ describe('UMS Module Loader', () => {
221207
const missingFields = result.errors.filter(e =>
222208
e.message.includes('Missing required field')
223209
);
224-
expect(missingFields.length).toBe(5); // schemaVersion, shape, declaredDirectives, meta, body
210+
expect(missingFields.length).toBe(4); // schemaVersion, shape, meta, body
225211
});
226212

227213
it('should reject module with undeclared directive in body', () => {
@@ -230,10 +216,6 @@ describe('UMS Module Loader', () => {
230216
version: '1.0.0',
231217
schemaVersion: '1.0',
232218
shape: 'procedure',
233-
declaredDirectives: {
234-
required: ['goal', 'process'],
235-
optional: [],
236-
},
237219
meta: {
238220
name: 'Invalid Module',
239221
description: 'Contains undeclared directive.',
@@ -242,7 +224,7 @@ describe('UMS Module Loader', () => {
242224
body: {
243225
goal: 'Build something.',
244226
process: ['Do stuff.'],
245-
steps: ['This is undeclared'], // Not in declaredDirectives
227+
steps: ['This is undeclared'], // Not allowed for the shape
246228
},
247229
};
248230

@@ -259,10 +241,6 @@ describe('UMS Module Loader', () => {
259241
version: '1.0.0',
260242
schemaVersion: '1.0',
261243
shape: 'procedure',
262-
declaredDirectives: {
263-
required: ['goal', 'process'],
264-
optional: [],
265-
},
266244
meta: {
267245
name: 'Invalid Module',
268246
description: 'Missing required directive.',
@@ -287,10 +265,6 @@ describe('UMS Module Loader', () => {
287265
version: '1.0.0',
288266
schemaVersion: '1.0',
289267
shape: 'procedure',
290-
declaredDirectives: {
291-
required: ['goal', 'process'],
292-
optional: [],
293-
},
294268
meta: {
295269
name: 'Invalid Module',
296270
description: 'Wrong directive types.',
@@ -315,10 +289,6 @@ describe('UMS Module Loader', () => {
315289
version: '1.0.0',
316290
schemaVersion: '1.0',
317291
shape: 'data',
318-
declaredDirectives: {
319-
required: ['goal', 'data'],
320-
optional: [],
321-
},
322292
meta: {
323293
name: 'Invalid Data Module',
324294
description: 'Invalid data directive.',
@@ -345,10 +315,6 @@ describe('UMS Module Loader', () => {
345315
version: '1.0.0',
346316
schemaVersion: '1.0',
347317
shape: 'specification',
348-
declaredDirectives: {
349-
required: ['goal', 'constraints'],
350-
optional: ['examples'],
351-
},
352318
meta: {
353319
name: 'Duplicate Titles',
354320
description: 'Examples with duplicate titles.',
@@ -384,10 +350,6 @@ describe('UMS Module Loader', () => {
384350
version: '1.0.0',
385351
schemaVersion: '1.0',
386352
shape: 'procedure',
387-
declaredDirectives: {
388-
required: ['goal', 'process'],
389-
optional: [],
390-
},
391353
meta: {
392354
name: 'Old Refactoring Procedure',
393355
description: 'Deprecated refactoring procedure.',
@@ -421,10 +383,6 @@ describe('UMS Module Loader', () => {
421383
version: '1.0.0',
422384
schemaVersion: '1.0',
423385
shape: 'procedure',
424-
declaredDirectives: {
425-
required: ['goal', 'process'],
426-
optional: [],
427-
},
428386
meta: {
429387
name: 'Bad Replacement',
430388
description: 'Invalid replacement reference.',
@@ -449,10 +407,6 @@ describe('UMS Module Loader', () => {
449407
version: '1.0.0',
450408
schemaVersion: '1.0',
451409
shape: 'procedure',
452-
declaredDirectives: {
453-
required: ['goal', 'process'],
454-
optional: [],
455-
},
456410
meta: {
457411
name: 'Non-deprecated with replacement',
458412
description: 'Should not have replacedBy.',
@@ -477,10 +431,6 @@ describe('UMS Module Loader', () => {
477431
version: '1.0.0',
478432
schemaVersion: '1.0',
479433
shape: 'specification',
480-
declaredDirectives: {
481-
required: ['goal', 'constraints'],
482-
optional: [],
483-
},
484434
meta: {
485435
name: 'Uppercase Tags',
486436
description: 'Module with uppercase tags.',

0 commit comments

Comments
 (0)