Skip to content

Commit 890b431

Browse files
committed
test(agents): shield model-resolution-consistency from leaked snapshot mocks
The agents-embedded shard still failed after completing five factories: ~20 more test files across the repo mock current-plugin-metadata-snapshot with incomplete explicit factories, and under isolate:false composition any of them can strip withPluginMetadataSnapshotScope from this file's imports. Give the victim a file-local identity mock (importOriginal spread) that always wins, and revert the static-catalog factory edit that tipped that grandfathered file over the max-lines cap — the repo-wide factory completion belongs to a dedicated sweep.
1 parent 2219142 commit 890b431

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎src/agents/embedded-agent-runner/model-resolution-consistency.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ import {
88
import type { ModelCatalogEntry } from "../model-catalog.types.js";
99
import { resolveInitialEmbeddedRunModel } from "./run/runtime-resolution.js";
1010

11+
// Self-defense against isolate:false shard composition: sibling test files
12+
// mock this module with incomplete factories, and a leaked mock strips the
13+
// real withPluginMetadataSnapshotScope this file needs. A file-local
14+
// identity mock always wins and restores the actual module.
15+
vi.mock("../../plugins/current-plugin-metadata-snapshot.js", async (importOriginal) => ({
16+
...(await importOriginal<typeof import("../../plugins/current-plugin-metadata-snapshot.js")>()),
17+
}));
18+
1119
const STATIC_MODEL_ID = "claude-haiku-4-5";
1220
const PROVIDER = "anthropic";
1321
const resolveHookModelSelectionMock = vi.hoisted(() =>

‎src/agents/embedded-agent-runner/model.static-catalog.test.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ vi.mock("../../plugins/manifest-metadata-scan.js", () => ({
2020
listOpenClawPluginManifestMetadata: manifestMocks.listOpenClawPluginManifestMetadata,
2121
}));
2222

23-
vi.mock("../../plugins/current-plugin-metadata-snapshot.js", async (importOriginal) => ({
24-
...(await importOriginal<typeof import("../../plugins/current-plugin-metadata-snapshot.js")>()),
23+
vi.mock("../../plugins/current-plugin-metadata-snapshot.js", () => ({
2524
getCurrentPluginMetadataSnapshot: manifestMocks.getCurrentPluginMetadataSnapshot,
2625
}));
2726

0 commit comments

Comments
 (0)