mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
49cd6009cc
`server.sessions.compaction-read-errors` mocks `config/sessions/session-accessor.sqlite-read.js`, but production reaches `loadTranscriptEvents` through re-exports: `server-methods/sessions-compact.ts` imports it from the `session-accessor.js` barrel and `preflightSessionTranscriptForManualCompact` imports it from the leaf. The `gateway-server` project is `isolate: false`, so when a neighbour has already evaluated those importers they stay bound to the real implementation and the mock never fires -- the injected read error simply does not happen and all three tests fail with `expected true to be false`, reading like a product regression. Trigger:33744584f3added `server.chat-metadata-boundary.test.ts`, which boots a full non-minimal Gateway in `beforeAll` and lands immediately before this file in the shard. Main has gone red on it repeatedly since (32338154086, 32339521003, 32339928383, 32341300955, 32341946296);e294c154a6fixed only the sibling symptom where the factory had not run yet. Route the file to a new `gateway-server-isolated` project instead, mirroring `unit-fast-isolated` -- whose comment describes this exact hazard. A fresh graph per file makes both symptoms structurally impossible rather than order-dependent. The list is explicit so the reason travels with the file. Not reproducible on macOS: the exact 24-file stripe in CI's own order, and the triggering pair three times, are green locally every time.
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
// Vitest gateway server isolated config wires module-mocking Gateway tests out of
|
|
// the shared module cache.
|
|
import { defineConfig } from "vitest/config";
|
|
import { gatewayServerIsolatedTestFiles } from "./vitest.gateway-server-paths.mjs";
|
|
import { loadPatternListFromEnv, narrowIncludePatternsForCli } from "./vitest.pattern-file.ts";
|
|
import { resolveRepoRootPath, sharedVitestConfig } from "./vitest.shared.config.ts";
|
|
|
|
export function createGatewayServerIsolatedVitestConfig(
|
|
env: Record<string, string | undefined> = process.env,
|
|
options: { argv?: string[] } = {},
|
|
) {
|
|
const sharedTest = sharedVitestConfig.test ?? {};
|
|
const includeFromEnv = loadPatternListFromEnv("OPENCLAW_VITEST_INCLUDE_FILE", env);
|
|
const cliInclude = narrowIncludePatternsForCli(gatewayServerIsolatedTestFiles, options.argv);
|
|
|
|
return defineConfig({
|
|
...sharedVitestConfig,
|
|
test: {
|
|
...sharedTest,
|
|
name: "gateway-server-isolated",
|
|
// These files replace a module the Gateway reaches through re-exports, so a
|
|
// neighbour that already bound the real implementation would defeat the mock.
|
|
isolate: true,
|
|
runner: undefined,
|
|
setupFiles: [resolveRepoRootPath("test/setup.env.ts")],
|
|
include: includeFromEnv ?? cliInclude ?? gatewayServerIsolatedTestFiles,
|
|
exclude: sharedTest.exclude ?? [],
|
|
passWithNoTests: true,
|
|
},
|
|
});
|
|
}
|
|
|
|
export default createGatewayServerIsolatedVitestConfig();
|