fix: Fix ProhibitedTermsScanner glob v7 bug and BlogCuration test MongoDB dependency

ProhibitedTermsScanner used await glob() which returns a Glob instance
in v7, not a Promise<string[]>. Changed to glob.sync() so file discovery
actually works. BlogCuration suggestTopics() tests added Document.model
mock to prevent MongoDB connection attempts.

All 14 unit test suites now pass (524/524 tests).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
TheFlow 2026-02-07 17:16:40 +13:00
parent 8e72ecd549
commit 0668b09b54
2 changed files with 9 additions and 8 deletions

View file

@ -15,7 +15,7 @@
const fs = require('fs').promises; const fs = require('fs').promises;
const path = require('path'); const path = require('path');
const { glob } = require('glob'); const glob = require('glob');
const { execSync } = require('child_process'); const { execSync } = require('child_process');
class ProhibitedTermsScanner { class ProhibitedTermsScanner {
@ -259,17 +259,14 @@ class ProhibitedTermsScanner {
const files = []; const files = [];
for (const pattern of this.includePatterns) { for (const pattern of this.includePatterns) {
try { try {
const matches = await glob(pattern, { const matches = glob.sync(pattern, {
ignore: this.excludePatterns, ignore: this.excludePatterns,
nodir: true, nodir: true,
cwd: this.options.basePath cwd: this.options.basePath
}); });
// glob returns an array, so we can spread it // Prepend base path to make absolute paths
if (Array.isArray(matches)) { const absolutePaths = matches.map(f => path.join(this.options.basePath, f));
// Prepend base path to make absolute paths files.push(...absolutePaths);
const absolutePaths = matches.map(f => path.join(this.options.basePath, f));
files.push(...absolutePaths);
}
} catch (err) { } catch (err) {
// Ignore glob errors (e.g., pattern doesn't match anything) // Ignore glob errors (e.g., pattern doesn't match anything)
} }

View file

@ -13,6 +13,10 @@ jest.mock('../../src/services/BoundaryEnforcer.service', () => ({
enforce: jest.fn() enforce: jest.fn()
})); }));
jest.mock('../../src/models/Document.model', () => ({
list: jest.fn().mockResolvedValue([])
}));
const BlogCuration = require('../../src/services/BlogCuration.service'); const BlogCuration = require('../../src/services/BlogCuration.service');
const ClaudeAPI = require('../../src/services/ClaudeAPI.service'); const ClaudeAPI = require('../../src/services/ClaudeAPI.service');
const BoundaryEnforcer = require('../../src/services/BoundaryEnforcer.service'); const BoundaryEnforcer = require('../../src/services/BoundaryEnforcer.service');