Fix test isolation to prevent loading real user config

Tests were picking up real ~/.warelay/warelay.json with emojis and
prefixes (like "🦞"), causing test assertions to fail. Added proper
config mocks to all test files.

Changes:
- Mock loadConfig() in index.core.test.ts, inbound.media.test.ts,
  monitor-inbox.test.ts
- Update test-helpers.ts default mock to disable all prefixes
- Tests now use clean config: no messagePrefix, no responsePrefix,
  no timestamp, allowFrom=["*"]

This ensures tests validate core behavior without user-specific config.
The responsePrefix feature itself is already fully config-driven - this
only fixes test isolation.
This commit is contained in:
Peter Steinberger
2025-11-30 18:00:57 +00:00
parent 69319a0569
commit 21ba0fb8a4
5 changed files with 37 additions and 2 deletions

View File

@@ -9,6 +9,18 @@ import { createMockTwilio } from "../test/mocks/twilio.js";
import * as exec from "./process/exec.js";
import { withWhatsAppPrefix } from "./utils.js";
// Mock config to avoid loading real user config
vi.mock("../src/config/config.js", () => ({
loadConfig: vi.fn().mockReturnValue({
inbound: {
allowFrom: ["*"],
messagePrefix: undefined,
responsePrefix: undefined,
timestampPrefix: false,
},
}),
}));
// Twilio mock factory shared across tests
vi.mock("twilio", () => {
const { factory } = createMockTwilio();