mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 07:20:43 +00:00
test(plugins): avoid per-test discovery reloads
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { AuthProfileStore } from "../../../src/agents/auth-profiles/types.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { ModelDefinitionConfig } from "../../../src/config/types.models.js";
|
||||
@@ -171,15 +171,14 @@ function runCatalog(
|
||||
}
|
||||
|
||||
async function importBundledProviderPlugin<T>(moduleUrl: string): Promise<T> {
|
||||
return (await import(`${moduleUrl}?t=${Date.now()}`)) as T;
|
||||
return (await import(moduleUrl)) as T;
|
||||
}
|
||||
|
||||
function installDiscoveryHooks(
|
||||
state: DiscoveryState,
|
||||
providerIds: readonly BundledProviderUnderTest[],
|
||||
) {
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
beforeAll(async () => {
|
||||
vi.doMock("openclaw/plugin-sdk/agent-runtime", () => {
|
||||
return {
|
||||
ensureAuthProfileStore: ensureAuthProfileStoreMock,
|
||||
@@ -315,7 +314,7 @@ function installDiscoveryHooks(
|
||||
setRuntimeAuthStore();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
resolveCopilotApiTokenMock.mockReset();
|
||||
buildOllamaProviderMock.mockReset();
|
||||
@@ -323,6 +322,7 @@ function installDiscoveryHooks(
|
||||
buildSglangProviderMock.mockReset();
|
||||
ensureAuthProfileStoreMock.mockReset();
|
||||
listProfilesForProviderMock.mockReset();
|
||||
setRuntimeAuthStore();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user