Skip to content

test(mcp): fix store tests writing fixtures outside getStateDir; sync hub-search specs with pagination API#693

Open
mojoho81 wants to merge 1 commit into
outsourc-e:mainfrom
mojoho81:fix/mcp-store-test-isolation
Open

test(mcp): fix store tests writing fixtures outside getStateDir; sync hub-search specs with pagination API#693
mojoho81 wants to merge 1 commit into
outsourc-e:mainfrom
mojoho81:fix/mcp-store-test-isolation

Conversation

@mojoho81

@mojoho81 mojoho81 commented Jul 6, 2026

Copy link
Copy Markdown

Summary

27 tests across the 5 MCP store/route test files fail on any machine (verified identical failures on a clean checkout of main). Two independent root causes, both test-side:

Root cause A (23 tests): fixtures written outside getStateDir().
mcp-presets-store.test.ts, mcp-hub-sources-store.test.ts, mcp-tools-cache.test.ts, and -presets.test.ts set HERMES_HOME to a temp dir correctly, but then write fixture files at $HERMES_HOME/<file> — while the stores resolve their paths via getStateDir(), which appends a workspace/ segment ($HERMES_HOME/workspace/<file>). The stores never see the fixtures and bootstrap from seed data instead, so every user-file / invalid-path assertion fails.

Fix: tests now derive paths from the modules' own exported helpers (presetsFilePath(), hubSourcesFilePath(), getStateDir()) instead of hand-building them. This also un-vacuouses the two mcp-tools-cache corrupt-file tests, which previously wrote the corrupt file to a path the cache never read (they passed for the wrong reason).

Root cause B (4 tests): stale hub-search specs.
-hub-search.test.ts still expected the old 3-arg unifiedSearch signature and a limit clamp of 100; the route now clamps to 500 and forwards an offset param. Updated expectations and added offset coverage.

The only product-code change is a comment: the limit/offset docblock in hub-search.ts said 1..100 while the code clamps to 500 — corrected to match behavior.

Test results

  • Before: 27 failed / 42 passed across the 5 files (same on main)
  • After: 70/70 pass
  • Full vitest run: no new failures introduced; eslint and tsc output identical to baseline

Notes

Test-only change (plus the one docblock line). No behavior changes. Should make these suites pass for every contributor regardless of local Hermes state or platform.

@mojoho81
mojoho81 requested a review from outsourc-e as a code owner July 6, 2026 20:10
… hub-search specs with pagination API

Root cause A (23 tests): mcp-presets-store, mcp-hub-sources-store,
mcp-tools-cache and the /api/mcp/presets route tests wrote fixture files
at $HERMES_HOME/<file>, but the stores resolve paths via getStateDir(),
which appends a workspace/ segment ($HERMES_HOME/workspace/<file>).
The stores never saw the fixtures and bootstrapped from seed instead,
so every user-file/invalid-path assertion failed on any machine.
Fix: tests now derive paths from the modules' own exported helpers
(presetsFilePath(), hubSourcesFilePath(), getStateDir()) instead of
hand-building them. Also un-vacuouses the two mcp-tools-cache corrupt-
file tests, which previously wrote the corrupt file to an unread path.

Root cause B (4 tests): -hub-search.test.ts still expected the old
3-arg unifiedSearch signature and a limit clamp of 100; the route now
clamps to 500 and forwards an offset param. Updated expectations, added
offset coverage, and corrected the stale limit/offset docblock in
hub-search.ts (comment-only product change).

Before: 27 failed across these 5 files. After: 70/70 pass; full vitest
run leaves only the known out-of-scope failures (chat components, i18n,
e2e playwright).
@mojoho81
mojoho81 force-pushed the fix/mcp-store-test-isolation branch from f6456b0 to 01424e7 Compare July 6, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant