mirror of https://github.com/openclaw/openclaw.git
test: dedupe core test teardown paths
This commit is contained in:
parent
b66197f932
commit
051b5ddafe
|
|
@ -42,7 +42,6 @@ describe("channel tools", () => {
|
|||
|
||||
afterEach(() => {
|
||||
setActivePluginRegistry(createTestRegistry([]));
|
||||
errorSpy.mockClear();
|
||||
});
|
||||
|
||||
it("skips crashing plugins and logs once", () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { importFreshModule } from "../../test/helpers/import-fresh.js";
|
||||
|
||||
const state = vi.hoisted(() => ({
|
||||
|
|
@ -49,11 +49,6 @@ describe("live model switch", () => {
|
|||
state.loadSessionStoreMock.mockReset().mockReturnValue({});
|
||||
state.resolveStorePathMock.mockReset().mockReturnValue("/tmp/session-store.json");
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("resolves persisted session overrides ahead of agent defaults", async () => {
|
||||
state.loadSessionStoreMock.mockReturnValue({
|
||||
main: {
|
||||
|
|
|
|||
|
|
@ -115,9 +115,7 @@ describe("announce loop guard (#18264)", () => {
|
|||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
loadSubagentRegistryFromDisk.mockClear();
|
||||
loadSubagentRegistryFromDisk.mockReturnValue(new Map());
|
||||
saveSubagentRegistryToDisk.mockClear();
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ const {
|
|||
listDevicePairing,
|
||||
approveDevicePairing,
|
||||
summarizeDeviceTokens,
|
||||
withProgress,
|
||||
} = mocks;
|
||||
|
||||
vi.mock("../gateway/call.js", () => ({
|
||||
|
|
@ -337,20 +336,12 @@ beforeEach(() => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
buildGatewayConnectionDetails.mockClear();
|
||||
buildGatewayConnectionDetails.mockReturnValue({
|
||||
url: "ws://127.0.0.1:18789",
|
||||
urlSource: "local loopback",
|
||||
message: "",
|
||||
});
|
||||
listDevicePairing.mockClear();
|
||||
listDevicePairing.mockResolvedValue({ pending: [], paired: [] });
|
||||
approveDevicePairing.mockClear();
|
||||
approveDevicePairing.mockResolvedValue(undefined);
|
||||
summarizeDeviceTokens.mockClear();
|
||||
summarizeDeviceTokens.mockReturnValue(undefined);
|
||||
withProgress.mockClear();
|
||||
runtime.log.mockClear();
|
||||
runtime.error.mockClear();
|
||||
runtime.exit.mockClear();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -887,7 +887,6 @@ describe("onboard (non-interactive): provider auth", () => {
|
|||
resetFileLockStateForTest();
|
||||
clearPluginDiscoveryCache();
|
||||
clearPluginManifestRegistryCache();
|
||||
ensureWorkspaceAndSessionsMock.mockClear();
|
||||
});
|
||||
|
||||
it("stores MiniMax API key in the global auth profile", async () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { afterEach, beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||
|
||||
const { resolveRuntimePluginRegistryMock } = vi.hoisted(() => ({
|
||||
|
|
@ -20,7 +20,7 @@ describe("image-generation provider registry", () => {
|
|||
await import("./provider-registry.js"));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
beforeEach(() => {
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue(undefined);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ describe("image-generation runtime helpers", () => {
|
|||
({ generateImage, listRuntimeImageGenerationProviders } = await import("./runtime.js"));
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
beforeEach(() => {
|
||||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue(undefined);
|
||||
resetPluginRuntimeStateForTest();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
afterEach(() => {
|
||||
resetPluginRuntimeStateForTest();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ beforeEach(() => {
|
|||
|
||||
describe("gaxios fetch compat", () => {
|
||||
afterEach(() => {
|
||||
vi.doUnmock("undici");
|
||||
Reflect.deleteProperty(globalThis as object, TEST_GAXIOS_CONSTRUCTOR_OVERRIDE);
|
||||
__testing.resetGaxiosFetchCompatForTests();
|
||||
vi.restoreAllMocks();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import * as replyModule from "../auto-reply/reply.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resolveAgentMainSessionKey, resolveMainSessionKey } from "../config/sessions.js";
|
||||
|
|
@ -38,8 +38,6 @@ async function withHeartbeatFixture(
|
|||
);
|
||||
}
|
||||
|
||||
beforeEach(() => {});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -31,9 +31,6 @@ function decodeCmdPathArg(value: string): string {
|
|||
|
||||
afterEach(() => {
|
||||
envSnapshot.restore();
|
||||
spawnMock.mockReset();
|
||||
resolvePreferredOpenClawTmpDirMock.mockReset();
|
||||
resolvePreferredOpenClawTmpDirMock.mockReturnValue(os.tmpdir());
|
||||
for (const scriptPath of createdScriptPaths) {
|
||||
try {
|
||||
fs.unlinkSync(scriptPath);
|
||||
|
|
|
|||
|
|
@ -18,13 +18,6 @@ describe("compaction hook wiring", () => {
|
|||
let handleAutoCompactionEnd: typeof import("../agents/pi-embedded-subscribe.handlers.compaction.js").handleAutoCompactionEnd;
|
||||
|
||||
beforeAll(async () => {
|
||||
hookMocks.runner.hasHooks.mockClear();
|
||||
hookMocks.runner.hasHooks.mockReturnValue(false);
|
||||
hookMocks.runner.runBeforeCompaction.mockClear();
|
||||
hookMocks.runner.runBeforeCompaction.mockResolvedValue(undefined);
|
||||
hookMocks.runner.runAfterCompaction.mockClear();
|
||||
hookMocks.runner.runAfterCompaction.mockResolvedValue(undefined);
|
||||
hookMocks.emitAgentEvent.mockClear();
|
||||
vi.doMock("../plugins/hook-runner-global.js", () => ({
|
||||
getGlobalHookRunner: () => hookMocks.runner,
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -140,8 +140,6 @@ describe("secrets runtime snapshot", () => {
|
|||
clearSecretsRuntimeSnapshot();
|
||||
clearRuntimeConfigSnapshot();
|
||||
clearConfigCache();
|
||||
resolveBundledPluginWebSearchProvidersMock.mockReset();
|
||||
resolvePluginWebSearchProvidersMock.mockReset();
|
||||
});
|
||||
|
||||
it("resolves env refs for config and auth profiles", async () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
findLatestTaskFlowForOwner,
|
||||
getTaskFlowByIdForOwner,
|
||||
|
|
@ -10,11 +10,6 @@ import { createManagedTaskFlow, resetTaskFlowRegistryForTests } from "./task-flo
|
|||
beforeEach(() => {
|
||||
resetTaskFlowRegistryForTests();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetTaskFlowRegistryForTests();
|
||||
});
|
||||
|
||||
describe("task flow owner access", () => {
|
||||
it("returns owner-scoped flows for direct and owner-key lookups", () => {
|
||||
const older = createManagedTaskFlow({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
|
||||
import type { SpeechProviderPlugin } from "../plugins/types.js";
|
||||
|
|
@ -44,9 +44,6 @@ describe("speech provider registry", () => {
|
|||
resolveRuntimePluginRegistryMock.mockReset();
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue(undefined);
|
||||
});
|
||||
|
||||
afterEach(() => {});
|
||||
|
||||
it("uses active plugin speech providers without reloading plugins", () => {
|
||||
resolveRuntimePluginRegistryMock.mockReturnValue({
|
||||
...createEmptyPluginRegistry(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue