From 14e84cf0b3e8dde41ac602fd7dfd53837a8101ff Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 19 Mar 2026 11:16:24 -0700 Subject: [PATCH] test(ci): trim runtime test harness churn --- src/agents/tools/message-tool.test.ts | 14 ++++++++------ src/infra/outbound/deliver.test.ts | 8 +++++--- src/plugins/provider-runtime.test.ts | 8 +++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/agents/tools/message-tool.test.ts b/src/agents/tools/message-tool.test.ts index eeb88630072..e87df84b909 100644 --- a/src/agents/tools/message-tool.test.ts +++ b/src/agents/tools/message-tool.test.ts @@ -1,5 +1,5 @@ import { Type } from "@sinclair/typebox"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import type { ChannelMessageCapability } from "../../channels/plugins/message-capabilities.js"; import type { ChannelMessageActionName, ChannelPlugin } from "../../channels/plugins/types.js"; import type { MessageActionRunResult } from "../../infra/outbound/message-action-runner.js"; @@ -86,17 +86,19 @@ function getActionEnum(properties: Record) { return (properties.action as { enum?: string[] } | undefined)?.enum ?? []; } -beforeEach(async () => { - vi.resetModules(); +beforeAll(async () => { + ({ setActivePluginRegistry } = await import("../../plugins/runtime.js")); + ({ createTestRegistry } = await import("../../test-utils/channel-plugins.js")); + ({ createMessageTool } = await import("./message-tool.js")); +}); + +beforeEach(() => { mocks.runMessageAction.mockReset(); mocks.loadConfig.mockReset().mockReturnValue({}); mocks.resolveCommandSecretRefsViaGateway.mockReset().mockImplementation(async ({ config }) => ({ resolvedConfig: config, diagnostics: [], })); - ({ setActivePluginRegistry } = await import("../../plugins/runtime.js")); - ({ createTestRegistry } = await import("../../test-utils/channel-plugins.js")); - ({ createMessageTool } = await import("./message-tool.js")); }); function createChannelPlugin(params: { diff --git a/src/infra/outbound/deliver.test.ts b/src/infra/outbound/deliver.test.ts index e72cbaa0bee..6bf69a519f8 100644 --- a/src/infra/outbound/deliver.test.ts +++ b/src/infra/outbound/deliver.test.ts @@ -1,5 +1,5 @@ import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { markdownToSignalTextChunks } from "../../../extensions/signal/src/format.js"; import { signalOutbound, @@ -201,9 +201,11 @@ function expectSuccessfulWhatsAppInternalHookPayload( } describe("deliverOutboundPayloads", () => { - beforeEach(async () => { - vi.resetModules(); + beforeAll(async () => { ({ deliverOutboundPayloads, normalizeOutboundPayloads } = await import("./deliver.js")); + }); + + beforeEach(() => { setActivePluginRegistry(defaultRegistry); mocks.appendAssistantMessageToSessionTranscript.mockClear(); hookMocks.runner.hasHooks.mockClear(); diff --git a/src/plugins/provider-runtime.test.ts b/src/plugins/provider-runtime.test.ts index 2c1cc1e2d57..5db15a259bb 100644 --- a/src/plugins/provider-runtime.test.ts +++ b/src/plugins/provider-runtime.test.ts @@ -1,4 +1,4 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { expectAugmentedCodexCatalog, expectCodexBuiltInSuppression, @@ -65,8 +65,7 @@ const MODEL: ProviderRuntimeModel = { }; describe("provider-runtime", () => { - beforeEach(async () => { - vi.resetModules(); + beforeAll(async () => { ({ augmentModelCatalogWithProviderPlugins, buildProviderAuthDoctorHintWithPlugin, @@ -91,6 +90,9 @@ describe("provider-runtime", () => { runProviderDynamicModel, wrapProviderStreamFn, } = await import("./provider-runtime.js")); + }); + + beforeEach(() => { resetProviderRuntimeHookCacheForTest(); resolvePluginProvidersMock.mockReset(); resolvePluginProvidersMock.mockReturnValue([]);