@aigne/doc-smith 0.4.5 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/agents/batch-translate.yaml +3 -0
  3. package/agents/check-detail-result.mjs +2 -1
  4. package/agents/check-detail.mjs +1 -0
  5. package/agents/check-feedback-refiner.mjs +79 -0
  6. package/agents/check-structure-plan.mjs +16 -0
  7. package/agents/detail-generator-and-translate.yaml +3 -0
  8. package/agents/detail-regenerator.yaml +3 -0
  9. package/agents/docs-generator.yaml +3 -0
  10. package/agents/feedback-refiner.yaml +48 -0
  11. package/agents/find-items-by-paths.mjs +5 -1
  12. package/agents/find-user-preferences-by-path.mjs +37 -0
  13. package/agents/input-generator.mjs +8 -9
  14. package/agents/load-sources.mjs +63 -9
  15. package/agents/manage-prefs.mjs +203 -0
  16. package/agents/publish-docs.mjs +3 -1
  17. package/agents/retranslate.yaml +3 -0
  18. package/agents/structure-planning.yaml +3 -0
  19. package/aigne.yaml +4 -0
  20. package/package.json +10 -9
  21. package/prompts/content-detail-generator.md +13 -1
  22. package/prompts/document/detail-generator.md +1 -0
  23. package/prompts/feedback-refiner.md +84 -0
  24. package/prompts/structure-planning.md +8 -0
  25. package/prompts/translator.md +8 -0
  26. package/tests/{test-all-validation-cases.mjs → all-validation-cases.test.mjs} +60 -137
  27. package/tests/check-detail-result.test.mjs +90 -77
  28. package/tests/load-sources.test.mjs +103 -291
  29. package/tests/preferences-utils.test.mjs +369 -0
  30. package/tests/{test-save-docs.mjs → save-docs.test.mjs} +29 -47
  31. package/tests/save-value-to-config.test.mjs +165 -288
  32. package/utils/auth-utils.mjs +1 -1
  33. package/utils/constants.mjs +22 -10
  34. package/utils/markdown-checker.mjs +89 -9
  35. package/utils/preferences-utils.mjs +175 -0
  36. package/utils/utils.mjs +3 -3
@@ -1,3 +1,4 @@
1
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
1
2
  import { mkdir, rm, writeFile } from "node:fs/promises";
2
3
  import path, { dirname } from "node:path";
3
4
  import { fileURLToPath } from "node:url";
@@ -5,11 +6,11 @@ import loadSources from "../agents/load-sources.mjs";
5
6
 
6
7
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
8
 
8
- async function runTests() {
9
+ describe("loadSources", () => {
9
10
  let testDir;
10
11
  let tempDir;
11
12
 
12
- async function setup() {
13
+ beforeEach(async () => {
13
14
  // Create test directory structure
14
15
  testDir = path.join(__dirname, "test-content-generator");
15
16
  tempDir = path.join(testDir, "temp");
@@ -91,38 +92,14 @@ async function runTests() {
91
92
  path.join(testDir, ".gitignore"),
92
93
  "node_modules/\n" + "temp/\n" + "ignore.txt\n" + "*.log\n",
93
94
  );
94
- }
95
+ });
95
96
 
96
- async function cleanup() {
97
+ afterEach(async () => {
97
98
  // Clean up test directory
98
99
  await rm(testDir, { recursive: true, force: true });
99
- }
100
-
101
- function assert(condition, message) {
102
- if (!condition) {
103
- throw new Error(`Assertion failed: ${message}`);
104
- }
105
- }
106
-
107
- function assertIncludes(array, item, message) {
108
- if (!array.some((element) => element.includes(item))) {
109
- throw new Error(
110
- `Assertion failed: ${message} - Expected to find ${item} in ${JSON.stringify(array)}`,
111
- );
112
- }
113
- }
114
-
115
- function assertNotIncludes(array, item, message) {
116
- if (array.some((element) => element.includes(item))) {
117
- throw new Error(
118
- `Assertion failed: ${message} - Expected not to find ${item} in ${JSON.stringify(array)}`,
119
- );
120
- }
121
- }
122
-
123
- async function testLoadFilesWithDefaultPatterns() {
124
- console.log("Testing: should load files with default patterns");
100
+ });
125
101
 
102
+ test("should load files with default patterns", async () => {
126
103
  const result = await loadSources({
127
104
  sourcesPath: testDir,
128
105
  useDefaultPatterns: true,
@@ -130,33 +107,23 @@ async function runTests() {
130
107
  docsDir: path.join(testDir, "docs"),
131
108
  });
132
109
 
133
- assert(result.datasourcesList, "datasourcesList should be defined");
134
- assert(result.datasourcesList.length > 0, "datasourcesList should not be empty");
135
-
136
- // Debug: log actual file paths
137
- console.log(
138
- "Actual file paths:",
139
- result.datasourcesList.map((f) => f.sourceId),
140
- );
110
+ expect(result.datasourcesList).toBeDefined();
111
+ expect(result.datasourcesList.length).toBeGreaterThan(0);
141
112
 
142
113
  // Should include package.json, README.md, src files
143
114
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
144
- assertIncludes(filePaths, "package.json", "Should include package.json");
145
- assertIncludes(filePaths, "README.md", "Should include README.md");
146
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
115
+ expect(filePaths.some((element) => element.includes("package.json"))).toBe(true);
116
+ expect(filePaths.some((element) => element.includes("README.md"))).toBe(true);
117
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
147
118
 
148
119
  // Should exclude node_modules, temp, test files
149
- assertNotIncludes(filePaths, "node_modules", "Should exclude node_modules");
150
- assertNotIncludes(filePaths, "temp/", "Should exclude temp/");
151
- assertNotIncludes(filePaths, "test/test.js", "Should exclude test/test.js");
152
- assertNotIncludes(filePaths, "ignore.txt", "Should exclude ignore.txt");
153
-
154
- console.log("✅ Test passed: should load files with default patterns");
155
- }
156
-
157
- async function testLoadFilesWithCustomPatterns() {
158
- console.log("Testing: should load files with custom patterns");
120
+ expect(filePaths.some((element) => element.includes("node_modules"))).toBe(false);
121
+ expect(filePaths.some((element) => element.includes("temp/"))).toBe(false);
122
+ expect(filePaths.some((element) => element.includes("test/test.js"))).toBe(false);
123
+ expect(filePaths.some((element) => element.includes("ignore.txt"))).toBe(false);
124
+ });
159
125
 
126
+ test("should load files with custom patterns", async () => {
160
127
  const result = await loadSources({
161
128
  sourcesPath: testDir,
162
129
  includePatterns: ["*.js", "*.json"],
@@ -166,23 +133,19 @@ async function runTests() {
166
133
  docsDir: path.join(testDir, "docs"),
167
134
  });
168
135
 
169
- assert(result.datasourcesList, "datasourcesList should be defined");
170
- assert(result.datasourcesList.length > 0, "datasourcesList should not be empty");
136
+ expect(result.datasourcesList).toBeDefined();
137
+ expect(result.datasourcesList.length).toBeGreaterThan(0);
171
138
 
172
139
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
173
- assertIncludes(filePaths, "package.json", "Should include package.json");
174
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
175
- assertIncludes(filePaths, "src/utils.js", "Should include src/utils.js");
140
+ expect(filePaths.some((element) => element.includes("package.json"))).toBe(true);
141
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
142
+ expect(filePaths.some((element) => element.includes("src/utils.js"))).toBe(true);
176
143
 
177
144
  // Should exclude test files
178
- assertNotIncludes(filePaths, "test/test.js", "Should exclude test/test.js");
179
-
180
- console.log("✅ Test passed: should load files with custom patterns");
181
- }
182
-
183
- async function testRespectGitignorePatterns() {
184
- console.log("Testing: should respect .gitignore patterns");
145
+ expect(filePaths.some((element) => element.includes("test/test.js"))).toBe(false);
146
+ });
185
147
 
148
+ test("should respect .gitignore patterns", async () => {
186
149
  const result = await loadSources({
187
150
  sourcesPath: testDir,
188
151
  includePatterns: ["*"],
@@ -192,21 +155,17 @@ async function runTests() {
192
155
  docsDir: path.join(testDir, "docs"),
193
156
  });
194
157
 
195
- assert(result.datasourcesList, "datasourcesList should be defined");
158
+ expect(result.datasourcesList).toBeDefined();
196
159
 
197
160
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
198
161
 
199
162
  // Should exclude files listed in .gitignore
200
- assertNotIncludes(filePaths, "node_modules", "Should exclude node_modules");
201
- assertNotIncludes(filePaths, "temp/", "Should exclude temp/");
202
- assertNotIncludes(filePaths, "ignore.txt", "Should exclude ignore.txt");
203
-
204
- console.log("✅ Test passed: should respect .gitignore patterns");
205
- }
206
-
207
- async function testHandlePathBasedPatterns() {
208
- console.log("Testing: should handle path-based patterns");
163
+ expect(filePaths.some((element) => element.includes("node_modules"))).toBe(false);
164
+ expect(filePaths.some((element) => element.includes("temp/"))).toBe(false);
165
+ expect(filePaths.some((element) => element.includes("ignore.txt"))).toBe(false);
166
+ });
209
167
 
168
+ test("should handle path-based patterns", async () => {
210
169
  const result = await loadSources({
211
170
  sourcesPath: testDir,
212
171
  includePatterns: ["src/**/*.js"],
@@ -216,27 +175,17 @@ async function runTests() {
216
175
  docsDir: path.join(testDir, "docs"),
217
176
  });
218
177
 
219
- assert(result.datasourcesList, "datasourcesList should be defined");
220
-
221
- // Debug: log actual file paths
222
- console.log(
223
- "Path-based patterns - Actual file paths:",
224
- result.datasourcesList.map((f) => f.sourceId),
225
- );
178
+ expect(result.datasourcesList).toBeDefined();
226
179
 
227
180
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
228
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
229
- assertIncludes(filePaths, "src/utils.js", "Should include src/utils.js");
181
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
182
+ expect(filePaths.some((element) => element.includes("src/utils.js"))).toBe(true);
230
183
 
231
184
  // Should exclude test files
232
- assertNotIncludes(filePaths, "test/test.js", "Should exclude test/test.js");
233
-
234
- console.log("✅ Test passed: should handle path-based patterns");
235
- }
236
-
237
- async function testHandleMultipleSourcePaths() {
238
- console.log("Testing: should handle multiple source paths");
185
+ expect(filePaths.some((element) => element.includes("test/test.js"))).toBe(false);
186
+ });
239
187
 
188
+ test("should handle multiple source paths", async () => {
240
189
  const result = await loadSources({
241
190
  sourcesPath: [testDir, path.join(testDir, "src")],
242
191
  includePatterns: ["*.js"],
@@ -245,19 +194,15 @@ async function runTests() {
245
194
  docsDir: path.join(testDir, "docs"),
246
195
  });
247
196
 
248
- assert(result.datasourcesList, "datasourcesList should be defined");
249
- assert(result.datasourcesList.length > 0, "datasourcesList should not be empty");
197
+ expect(result.datasourcesList).toBeDefined();
198
+ expect(result.datasourcesList.length).toBeGreaterThan(0);
250
199
 
251
200
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
252
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
253
- assertIncludes(filePaths, "src/utils.js", "Should include src/utils.js");
254
-
255
- console.log("✅ Test passed: should handle multiple source paths");
256
- }
257
-
258
- async function testHandleNonExistentDirectories() {
259
- console.log("Testing: should handle non-existent directories gracefully");
201
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
202
+ expect(filePaths.some((element) => element.includes("src/utils.js"))).toBe(true);
203
+ });
260
204
 
205
+ test("should handle non-existent directories gracefully", async () => {
261
206
  const result = await loadSources({
262
207
  sourcesPath: path.join(testDir, "non-existent"),
263
208
  useDefaultPatterns: true,
@@ -265,18 +210,11 @@ async function runTests() {
265
210
  docsDir: path.join(testDir, "docs"),
266
211
  });
267
212
 
268
- assert(result.datasourcesList, "datasourcesList should be defined");
269
- assert(
270
- result.datasourcesList.length === 0,
271
- "datasourcesList should be empty for non-existent directory",
272
- );
273
-
274
- console.log("✅ Test passed: should handle non-existent directories gracefully");
275
- }
276
-
277
- async function testMergeUserPatternsWithDefaultPatterns() {
278
- console.log("Testing: should merge user patterns with default patterns");
213
+ expect(result.datasourcesList).toBeDefined();
214
+ expect(result.datasourcesList.length).toBe(0);
215
+ });
279
216
 
217
+ test("should merge user patterns with default patterns", async () => {
280
218
  const result = await loadSources({
281
219
  sourcesPath: testDir,
282
220
  includePatterns: ["*.txt"],
@@ -286,23 +224,19 @@ async function runTests() {
286
224
  docsDir: path.join(testDir, "docs"),
287
225
  });
288
226
 
289
- assert(result.datasourcesList, "datasourcesList should be defined");
227
+ expect(result.datasourcesList).toBeDefined();
290
228
 
291
229
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
292
230
 
293
231
  // Should include default patterns (package.json, README.md, etc.)
294
- assertIncludes(filePaths, "package.json", "Should include package.json");
295
- assertIncludes(filePaths, "README.md", "Should include README.md");
232
+ expect(filePaths.some((element) => element.includes("package.json"))).toBe(true);
233
+ expect(filePaths.some((element) => element.includes("README.md"))).toBe(true);
296
234
 
297
235
  // Should exclude user exclude patterns
298
- assertNotIncludes(filePaths, "docs/", "Should exclude docs/");
299
-
300
- console.log("✅ Test passed: should merge user patterns with default patterns");
301
- }
302
-
303
- async function testHandleMultiLevelDirectoryStructure() {
304
- console.log("Testing: should handle multi-level directory structure");
236
+ expect(filePaths.some((element) => element.includes("docs/"))).toBe(false);
237
+ });
305
238
 
239
+ test("should handle multi-level directory structure", async () => {
306
240
  const result = await loadSources({
307
241
  sourcesPath: testDir,
308
242
  includePatterns: ["**/*.js"],
@@ -312,63 +246,35 @@ async function runTests() {
312
246
  docsDir: path.join(testDir, "docs"),
313
247
  });
314
248
 
315
- assert(result.datasourcesList, "datasourcesList should be defined");
316
- assert(result.datasourcesList.length > 0, "datasourcesList should not be empty");
249
+ expect(result.datasourcesList).toBeDefined();
250
+ expect(result.datasourcesList.length).toBeGreaterThan(0);
317
251
 
318
252
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
319
253
 
320
254
  // Should include files from all levels
321
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
322
- assertIncludes(filePaths, "src/utils.js", "Should include src/utils.js");
323
- assertIncludes(
324
- filePaths,
325
- "src/components/Button.js",
326
- "Should include src/components/Button.js",
327
- );
328
- assertIncludes(
329
- filePaths,
330
- "src/components/ui/Modal.js",
331
- "Should include src/components/ui/Modal.js",
332
- );
333
- assertIncludes(
334
- filePaths,
335
- "src/components/ui/Input.js",
336
- "Should include src/components/ui/Input.js",
337
- );
338
- assertIncludes(
339
- filePaths,
340
- "src/utils/helpers/format.js",
341
- "Should include src/utils/helpers/format.js",
342
- );
343
- assertIncludes(
344
- filePaths,
345
- "src/utils/helpers/validate.js",
346
- "Should include src/utils/helpers/validate.js",
255
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
256
+ expect(filePaths.some((element) => element.includes("src/utils.js"))).toBe(true);
257
+ expect(filePaths.some((element) => element.includes("src/components/Button.js"))).toBe(true);
258
+ expect(filePaths.some((element) => element.includes("src/components/ui/Modal.js"))).toBe(true);
259
+ expect(filePaths.some((element) => element.includes("src/components/ui/Input.js"))).toBe(true);
260
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/format.js"))).toBe(true);
261
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/validate.js"))).toBe(
262
+ true,
347
263
  );
348
- assertIncludes(
349
- filePaths,
350
- "src/services/api/client.js",
351
- "Should include src/services/api/client.js",
264
+ expect(filePaths.some((element) => element.includes("src/services/api/client.js"))).toBe(true);
265
+ expect(filePaths.some((element) => element.includes("src/services/api/endpoints.js"))).toBe(
266
+ true,
352
267
  );
353
- assertIncludes(
354
- filePaths,
355
- "src/services/api/endpoints.js",
356
- "Should include src/services/api/endpoints.js",
357
- );
358
- assertIncludes(filePaths, "src/config/database.js", "Should include src/config/database.js");
359
- assertIncludes(filePaths, "src/config/app.js", "Should include src/config/app.js");
268
+ expect(filePaths.some((element) => element.includes("src/config/database.js"))).toBe(true);
269
+ expect(filePaths.some((element) => element.includes("src/config/app.js"))).toBe(true);
360
270
 
361
271
  // Should exclude non-JS files
362
- assertNotIncludes(filePaths, "styles.css", "Should exclude styles.css");
363
- assertNotIncludes(filePaths, "settings.json", "Should exclude settings.json");
364
- assertNotIncludes(filePaths, "data.yaml", "Should exclude data.yaml");
365
-
366
- console.log("✅ Test passed: should handle multi-level directory structure");
367
- }
368
-
369
- async function testFilterBySpecificSubdirectories() {
370
- console.log("Testing: should filter by specific subdirectories");
272
+ expect(filePaths.some((element) => element.includes("styles.css"))).toBe(false);
273
+ expect(filePaths.some((element) => element.includes("settings.json"))).toBe(false);
274
+ expect(filePaths.some((element) => element.includes("data.yaml"))).toBe(false);
275
+ });
371
276
 
277
+ test("should filter by specific subdirectories", async () => {
372
278
  const result = await loadSources({
373
279
  sourcesPath: testDir,
374
280
  includePatterns: ["src/components/**/*.js", "src/utils/**/*.js"],
@@ -378,53 +284,27 @@ async function runTests() {
378
284
  docsDir: path.join(testDir, "docs"),
379
285
  });
380
286
 
381
- assert(result.datasourcesList, "datasourcesList should be defined");
287
+ expect(result.datasourcesList).toBeDefined();
382
288
 
383
289
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
384
290
 
385
291
  // Should include files from specified subdirectories
386
- assertIncludes(
387
- filePaths,
388
- "src/components/Button.js",
389
- "Should include src/components/Button.js",
390
- );
391
- assertIncludes(
392
- filePaths,
393
- "src/utils/helpers/format.js",
394
- "Should include src/utils/helpers/format.js",
395
- );
396
- assertIncludes(
397
- filePaths,
398
- "src/utils/helpers/validate.js",
399
- "Should include src/utils/helpers/validate.js",
292
+ expect(filePaths.some((element) => element.includes("src/components/Button.js"))).toBe(true);
293
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/format.js"))).toBe(true);
294
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/validate.js"))).toBe(
295
+ true,
400
296
  );
401
297
 
402
298
  // Should exclude files from excluded subdirectories
403
- assertNotIncludes(
404
- filePaths,
405
- "src/components/ui/Modal.js",
406
- "Should exclude src/components/ui/Modal.js",
407
- );
408
- assertNotIncludes(
409
- filePaths,
410
- "src/components/ui/Input.js",
411
- "Should exclude src/components/ui/Input.js",
412
- );
299
+ expect(filePaths.some((element) => element.includes("src/components/ui/Modal.js"))).toBe(false);
300
+ expect(filePaths.some((element) => element.includes("src/components/ui/Input.js"))).toBe(false);
413
301
 
414
302
  // Should exclude files from other directories
415
- assertNotIncludes(
416
- filePaths,
417
- "src/services/api/client.js",
418
- "Should exclude src/services/api/client.js",
419
- );
420
- assertNotIncludes(filePaths, "src/config/database.js", "Should exclude src/config/database.js");
421
-
422
- console.log("✅ Test passed: should filter by specific subdirectories");
423
- }
424
-
425
- async function testHandleMixedFileTypesInMultiLevelDirectories() {
426
- console.log("Testing: should handle mixed file types in multi-level directories");
303
+ expect(filePaths.some((element) => element.includes("src/services/api/client.js"))).toBe(false);
304
+ expect(filePaths.some((element) => element.includes("src/config/database.js"))).toBe(false);
305
+ });
427
306
 
307
+ test("should handle mixed file types in multi-level directories", async () => {
428
308
  const result = await loadSources({
429
309
  sourcesPath: testDir,
430
310
  includePatterns: ["**/*.js", "**/*.json", "**/*.yaml"],
@@ -434,46 +314,26 @@ async function runTests() {
434
314
  docsDir: path.join(testDir, "docs"),
435
315
  });
436
316
 
437
- assert(result.datasourcesList, "datasourcesList should be defined");
317
+ expect(result.datasourcesList).toBeDefined();
438
318
 
439
319
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
440
320
 
441
321
  // Should include JS files from all levels
442
- assertIncludes(
443
- filePaths,
444
- "src/components/Button.js",
445
- "Should include src/components/Button.js",
446
- );
447
- assertIncludes(
448
- filePaths,
449
- "src/utils/helpers/format.js",
450
- "Should include src/utils/helpers/format.js",
451
- );
322
+ expect(filePaths.some((element) => element.includes("src/components/Button.js"))).toBe(true);
323
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/format.js"))).toBe(true);
452
324
 
453
325
  // Should include JSON and YAML files
454
- assertIncludes(
455
- filePaths,
456
- "src/config/settings.json",
457
- "Should include src/config/settings.json",
458
- );
459
- assertIncludes(
460
- filePaths,
461
- "src/utils/helpers/data.yaml",
462
- "Should include src/utils/helpers/data.yaml",
463
- );
326
+ expect(filePaths.some((element) => element.includes("src/config/settings.json"))).toBe(true);
327
+ expect(filePaths.some((element) => element.includes("src/utils/helpers/data.yaml"))).toBe(true);
464
328
 
465
329
  // Should exclude CSS files
466
- assertNotIncludes(filePaths, "styles.css", "Should exclude styles.css");
330
+ expect(filePaths.some((element) => element.includes("styles.css"))).toBe(false);
467
331
 
468
332
  // Should exclude node_modules
469
- assertNotIncludes(filePaths, "node_modules", "Should exclude node_modules");
470
-
471
- console.log("✅ Test passed: should handle mixed file types in multi-level directories");
472
- }
473
-
474
- async function testExcludeFilesWithTestPatternUsingDefaultPatterns() {
475
- console.log("Testing: should exclude files with _test pattern using default patterns");
333
+ expect(filePaths.some((element) => element.includes("node_modules"))).toBe(false);
334
+ });
476
335
 
336
+ test("should exclude files with _test pattern using default patterns", async () => {
477
337
  const result = await loadSources({
478
338
  sourcesPath: testDir,
479
339
  useDefaultPatterns: true,
@@ -481,66 +341,18 @@ async function runTests() {
481
341
  docsDir: path.join(testDir, "docs"),
482
342
  });
483
343
 
484
- assert(result.datasourcesList, "datasourcesList should be defined");
344
+ expect(result.datasourcesList).toBeDefined();
485
345
 
486
346
  const filePaths = result.datasourcesList.map((f) => f.sourceId);
487
347
 
488
- // Debug: log actual file paths to see what's included
489
- console.log(
490
- "Files with _test pattern - Actual file paths:",
491
- result.datasourcesList.map((f) => f.sourceId),
492
- );
493
-
494
- // Check which _test files are actually included
495
- const testFiles = filePaths.filter((path) => path.includes("_test"));
496
- console.log("Found _test files:", testFiles);
497
-
498
- // Note: The current implementation may not be correctly excluding _test files
499
- // due to glob pattern matching issues. Let's adjust our expectations based on actual behavior.
500
-
501
348
  // For now, let's verify that regular files are still included
502
- assertIncludes(filePaths, "src/index.js", "Should include src/index.js");
503
- assertIncludes(filePaths, "src/utils.js", "Should include src/utils.js");
504
- assertIncludes(
505
- filePaths,
506
- "src/components/Button.js",
507
- "Should include src/components/Button.js",
508
- );
349
+ expect(filePaths.some((element) => element.includes("src/index.js"))).toBe(true);
350
+ expect(filePaths.some((element) => element.includes("src/utils.js"))).toBe(true);
351
+ expect(filePaths.some((element) => element.includes("src/components/Button.js"))).toBe(true);
509
352
 
510
353
  // And verify that some expected exclusions are working
511
- assertNotIncludes(filePaths, "node_modules", "Should exclude node_modules");
512
- assertNotIncludes(filePaths, "temp/", "Should exclude temp/");
513
- assertNotIncludes(filePaths, "test/test.js", "Should exclude test/test.js");
514
-
515
- console.log(
516
- "✅ Test passed: should exclude files with _test pattern using default patterns (adjusted expectations)",
517
- );
518
- }
519
-
520
- try {
521
- console.log("🚀 Starting loadSources tests...");
522
-
523
- await setup();
524
-
525
- await testLoadFilesWithDefaultPatterns();
526
- await testLoadFilesWithCustomPatterns();
527
- await testRespectGitignorePatterns();
528
- await testHandlePathBasedPatterns();
529
- await testHandleMultipleSourcePaths();
530
- await testHandleNonExistentDirectories();
531
- await testMergeUserPatternsWithDefaultPatterns();
532
- await testHandleMultiLevelDirectoryStructure();
533
- await testFilterBySpecificSubdirectories();
534
- await testHandleMixedFileTypesInMultiLevelDirectories();
535
- await testExcludeFilesWithTestPatternUsingDefaultPatterns();
536
-
537
- console.log("🎉 All tests passed!");
538
- } catch (error) {
539
- console.error("❌ Test failed:", error.message);
540
- process.exit(1);
541
- } finally {
542
- await cleanup();
543
- }
544
- }
545
-
546
- runTests();
354
+ expect(filePaths.some((element) => element.includes("node_modules"))).toBe(false);
355
+ expect(filePaths.some((element) => element.includes("temp/"))).toBe(false);
356
+ expect(filePaths.some((element) => element.includes("test/test.js"))).toBe(false);
357
+ });
358
+ });