test(perf): pin runtime metadata fixtures · openclaw/openclaw@167e433
steipete
·
2026-05-06
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | |
3 | 3 | const normalizeProviderModelIdWithPluginMock = vi.fn(); |
| 4 | +const emptyPluginMetadataSnapshot = vi.hoisted(() => ({ |
| 5 | +configFingerprint: "model-selection-plugin-runtime-test-empty-plugin-metadata", |
| 6 | +plugins: [ |
| 7 | +{ |
| 8 | +modelIdNormalization: { |
| 9 | +providers: { |
| 10 | +google: { |
| 11 | +aliases: { |
| 12 | +"gemini-3.1-pro": "gemini-3.1-pro-preview", |
| 13 | +}, |
| 14 | +}, |
| 15 | +}, |
| 16 | +}, |
| 17 | +}, |
| 18 | +], |
| 19 | +})); |
4 | 20 | |
5 | 21 | vi.mock("./provider-model-normalization.runtime.js", () => ({ |
6 | 22 | normalizeProviderModelIdWithRuntime: (params: unknown) => |
7 | 23 | normalizeProviderModelIdWithPluginMock(params), |
8 | 24 | })); |
9 | 25 | |
| 26 | +vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({ |
| 27 | +getCurrentPluginMetadataSnapshot: () => emptyPluginMetadataSnapshot, |
| 28 | +})); |
| 29 | + |
10 | 30 | describe("model-selection plugin runtime normalization", () => { |
11 | 31 | beforeEach(() => { |
12 | 32 | vi.resetModules(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | import { describe, expect, it, vi } from "vitest"; |
2 | 2 | |
| 3 | +const emptyPluginMetadataSnapshot = vi.hoisted(() => ({ |
| 4 | +configFingerprint: "models-list-configured-test-empty-plugin-metadata", |
| 5 | +plugins: [], |
| 6 | +})); |
| 7 | + |
3 | 8 | vi.mock("../../agents/provider-model-normalization.runtime.js", () => ({ |
4 | 9 | normalizeProviderModelIdWithRuntime: vi.fn(() => { |
5 | 10 | throw new Error("runtime model normalization should not load for models list entries"); |
6 | 11 | }), |
7 | 12 | })); |
8 | 13 | |
| 14 | +vi.mock("../../plugins/current-plugin-metadata-snapshot.js", () => ({ |
| 15 | +getCurrentPluginMetadataSnapshot: () => emptyPluginMetadataSnapshot, |
| 16 | +})); |
| 17 | + |
9 | 18 | import { resolveConfiguredEntries } from "./list.configured.js"; |
10 | 19 | |
11 | 20 | describe("resolveConfiguredEntries", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -3,12 +3,20 @@ import type { OpenClawConfig } from "../config/config.js";
|
3 | 3 | import type { SessionEntry } from "../config/sessions.js"; |
4 | 4 | |
5 | 5 | const normalizeProviderModelIdWithPluginMock = vi.fn(); |
| 6 | +const emptyPluginMetadataSnapshot = vi.hoisted(() => ({ |
| 7 | +configFingerprint: "gateway-session-utils-plugin-runtime-test-empty-plugin-metadata", |
| 8 | +plugins: [], |
| 9 | +})); |
6 | 10 | |
7 | 11 | vi.mock("../agents/provider-model-normalization.runtime.js", () => ({ |
8 | 12 | normalizeProviderModelIdWithRuntime: (params: unknown) => |
9 | 13 | normalizeProviderModelIdWithPluginMock(params), |
10 | 14 | })); |
11 | 15 | |
| 16 | +vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({ |
| 17 | +getCurrentPluginMetadataSnapshot: () => emptyPluginMetadataSnapshot, |
| 18 | +})); |
| 19 | + |
12 | 20 | describe("gateway session list plugin runtime normalization", () => { |
13 | 21 | beforeEach(() => { |
14 | 22 | vi.resetModules(); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。