Files
OmniRoute/tests/_setup
Diego Rodrigues de Sa e Souza 4963fd2c63 fix(mcp): keep Vitest runs out of the developer's ~/.omniroute database (#20252)
* fix(mcp): keep Vitest runs out of the developer's ~/.omniroute database

The node:test runner isolates DATA_DIR through tests/_setup/isolateDataDir.ts,
but Vitest never loaded an equivalent. The MCP audit resolves its own
database path (DATA_DIR, else ~/.omniroute/storage.sqlite) and writes there
whenever that file exists, so every `npm run test:vitest` without DATA_DIR
appended omniroute_test_combo rows from advancedTools.test.ts to the
developer's real database. One install had 202 such rows, all with the
fixture's input hash.

Two guards:
- both Vitest configs set a throwaway DATA_DIR (and OMNIROUTE_PLUGINS_DIR)
  for every worker through test.env, and a global setup removes it at the
  end; a DATA_DIR chosen by the caller wins and is never removed;
- in a test context with no DATA_DIR, the audit refuses the home database,
  the same rule src/lib/dataPaths.ts applies to the main database (#10428),
  with the same OMNIROUTE_ALLOW_DEFAULT_DATA_DIR=1 opt-in.

The new test failed before the fix (no DATA_DIR in Vitest; the audit opened
the home database). End to end, a run of the MCP audit suites with HOME
pointing at a fake install wrote 1 row into its storage.sqlite before the
fix and 0 after.

* docs(changelog): add the fragment for the Vitest DATA_DIR isolation
2026-11-15 09:49:05 -03:00
..