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:
parent
8e72ecd549
commit
0668b09b54
2 changed files with 9 additions and 8 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
const { glob } = require('glob');
|
||||
const glob = require('glob');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
class ProhibitedTermsScanner {
|
||||
|
|
@ -259,17 +259,14 @@ class ProhibitedTermsScanner {
|
|||
const files = [];
|
||||
for (const pattern of this.includePatterns) {
|
||||
try {
|
||||
const matches = await glob(pattern, {
|
||||
const matches = glob.sync(pattern, {
|
||||
ignore: this.excludePatterns,
|
||||
nodir: true,
|
||||
cwd: this.options.basePath
|
||||
});
|
||||
// glob returns an array, so we can spread it
|
||||
if (Array.isArray(matches)) {
|
||||
// Prepend base path to make absolute paths
|
||||
const absolutePaths = matches.map(f => path.join(this.options.basePath, f));
|
||||
files.push(...absolutePaths);
|
||||
}
|
||||
// Prepend base path to make absolute paths
|
||||
const absolutePaths = matches.map(f => path.join(this.options.basePath, f));
|
||||
files.push(...absolutePaths);
|
||||
} catch (err) {
|
||||
// Ignore glob errors (e.g., pattern doesn't match anything)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ jest.mock('../../src/services/BoundaryEnforcer.service', () => ({
|
|||
enforce: jest.fn()
|
||||
}));
|
||||
|
||||
jest.mock('../../src/models/Document.model', () => ({
|
||||
list: jest.fn().mockResolvedValue([])
|
||||
}));
|
||||
|
||||
const BlogCuration = require('../../src/services/BlogCuration.service');
|
||||
const ClaudeAPI = require('../../src/services/ClaudeAPI.service');
|
||||
const BoundaryEnforcer = require('../../src/services/BoundaryEnforcer.service');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue