aaronsb_obsidian-mcp-plugin/tests/__mocks__
Aaron Bockelie d636fffe78 fix(vault): Recurse listFiles into subfolders (#154)
vault.list(directory) returned an empty array whenever the target
folder's direct children were all subfolders — listFiles used
folder.children and then filtered to TFile, dropping every
descendant. Meanwhile the root case used vault.getAllLoadedFiles()
which is recursive, so root and directory listings diverged.

listFiles now walks the folder tree when a directory is provided,
matching the recursive semantics of the root case. Callers that
were already iterating result paths get the same shape — full
vault-rooted paths to .md files — they just no longer hit the
empty-list cliff for folder-of-folders inputs.

The synchronous throw on missing directory is preserved; existing
try/catch sites at router.ts:538 and :1030 use it as a "does this
exist as a directory" probe.

Adds tests/list-files-recursive.test.ts with regression coverage:
- recursing through a folder of subfolders returns all descendant files
- recurses through arbitrary nesting depth
- still throws on a missing directory
- root call (no directory) still returns the full vault

Test fixtures: tests/__mocks__/obsidian.ts gained a TFolder class
and a stat field on TFile.

Closes #154.
2026-05-15 13:16:45 -05:00
..
obsidian.ts fix(vault): Recurse listFiles into subfolders (#154) 2026-05-15 13:16:45 -05:00