Skip to content

Commit bc2f383

Browse files
committed
Added test to check that all markdown files mentioned in relationships exist
1 parent 2b81a3c commit bc2f383

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import * as fs from 'fs'
2+
import * as path from 'path'
3+
import { getAllRelationships } from '@/lib/relationships'
4+
5+
describe('Relationship Graph Integrity', () => {
6+
it('should have markdown files for all nodes referenced in relationships.mmd', () => {
7+
const { relationships } = getAllRelationships()
8+
const missingFiles: string[] = []
9+
const documentsDir = path.join(__dirname, '../../..', 'documents')
10+
const checkedSlugs = new Set<string>()
11+
12+
relationships.forEach(rel => {
13+
[rel.from, rel.to].forEach(fullSlug => {
14+
if (checkedSlugs.has(fullSlug)) return
15+
checkedSlugs.add(fullSlug)
16+
17+
const [category, slug] = fullSlug.split('/')
18+
const markdownPath = path.join(documentsDir, category, `${slug}.md`)
19+
20+
if (!fs.existsSync(markdownPath)) {
21+
missingFiles.push(fullSlug)
22+
}
23+
})
24+
})
25+
26+
if (missingFiles.length > 0) {
27+
throw new Error(
28+
`Relationships reference missing markdown files:\n${missingFiles.map(f => ` - ${f}`).join('\n')}`
29+
)
30+
}
31+
})
32+
})

0 commit comments

Comments
 (0)