Skip to content

Commit 0fa371c

Browse files
committed
test: Refine logger mock and add lint suppressions
1 parent 8b62a8a commit 0fa371c

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

src/tests/agent.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,21 @@ describe('Agent', () => {
166166
// Object.defineProperty is used to make properties configurable and writable if needed,
167167
// but direct assignment should work for simple mocks if Dirent properties are writable.
168168
// For simplicity, we'll assume direct assignment works or cast.
169+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
169170
(dirent as any).name = name;
171+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
170172
(dirent as any).isFile = () => !isDir;
173+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
171174
(dirent as any).isDirectory = () => isDir;
175+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
172176
(dirent as any).isBlockDevice = () => false;
177+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
173178
(dirent as any).isCharacterDevice = () => false;
179+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
174180
(dirent as any).isSymbolicLink = () => false;
181+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
175182
(dirent as any).isFIFO = () => false;
183+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
176184
(dirent as any).isSocket = () => false;
177185
// The 'path' property is not standard on Dirent from 'fs', it's usually inferred or constructed.
178186
// If your code relies on a 'path' or 'parentPath' property on Dirent objects *returned by readdir*,

src/tests/lib/query-refinement.helpers.test.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { preprocessText } from '../../utils/text-utils';
55
import { DetailedQdrantSearchResult } from '../../lib/types';
66

77
vi.mock('../../utils/text-utils'); // Mock dependencies of helpers
8+
9+
const mockLoggerInstance = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
810
// Mock configService and logger if they are DIRECTLY used by these helpers
911
// If they are only used by searchWithRefinement or refineQuery (dispatcher),
1012
// then this mock might not be needed here.
@@ -14,22 +16,22 @@ vi.mock('../../lib/config-service', () => ({
1416
// Add any config values DIRECTLY used by extractKeywords, broadenQuery, etc.
1517
// If none, this can be simpler or removed if logger isn't used by helpers.
1618
},
17-
logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
19+
logger: mockLoggerInstance,
1820
}));
1921

22+
// Import logger AFTER the mock is set up
23+
import { logger as mockedLoggerFromImport } from '../../lib/config-service'; // This will be mockLoggerInstance
2024

2125
describe('Query Refinement Helper Utilities', () => {
2226
beforeEach(() => {
23-
vi.clearAllMocks();
27+
vi.clearAllMocks(); // This clears all mocks, including those on mockLoggerInstance
2428
vi.mocked(preprocessText).mockImplementation(text => text.trim().replace(/\s+/g, ' '));
25-
26-
vi.mocked(logger.info).mockClear();
27-
28-
vi.mocked(logger.warn).mockClear();
29-
30-
vi.mocked(logger.error).mockClear();
31-
32-
vi.mocked(logger.debug).mockClear();
29+
30+
// Now use the imported mockedLoggerFromImport
31+
mockedLoggerFromImport.info.mockClear();
32+
mockedLoggerFromImport.warn.mockClear();
33+
mockedLoggerFromImport.error.mockClear();
34+
mockedLoggerFromImport.debug.mockClear();
3335
});
3436
afterEach(() => {
3537
vi.restoreAllMocks();

0 commit comments

Comments
 (0)