diff --git a/CHANGELOG.md b/CHANGELOG.md index dfb9de629f9..9ade3e3457d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Docs: https://docs.openclaw.ai - Skills/prompt budget: preserve all registered skills via a compact catalog fallback before dropping entries when the full prompt format exceeds `maxSkillsPromptChars`. (#47553) Thanks @snese. - Plugins/bundles: make enabled bundle MCP servers expose runnable tools in embedded Pi, and default relative bundle MCP launches to the bundle root so marketplace bundles like Context7 work through Pi instead of stopping at config import. - Scope message SecretRef resolution and harden doctor/status paths. (#48728) Thanks @joshavant. +- Plugins/testing: add a public `openclaw/plugin-sdk/testing` seam for plugin-author test helpers, and move bundled-extension-only test bridges out of `extensions/` into private repo test helpers. ### Breaking diff --git a/extensions/amazon-bedrock/index.test.ts b/extensions/amazon-bedrock/index.test.ts index 61b33a0bc68..4afa67e3501 100644 --- a/extensions/amazon-bedrock/index.test.ts +++ b/extensions/amazon-bedrock/index.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { registerSingleProviderPlugin } from "../test-utils/plugin-registration.js"; +import { registerSingleProviderPlugin } from "../../test/helpers/extensions/plugin-registration.js"; import amazonBedrockPlugin from "./index.js"; describe("amazon-bedrock provider plugin", () => { diff --git a/extensions/bluebubbles/src/monitor.test.ts b/extensions/bluebubbles/src/monitor.test.ts index 1ba2e27f0b6..17467465d82 100644 --- a/extensions/bluebubbles/src/monitor.test.ts +++ b/extensions/bluebubbles/src/monitor.test.ts @@ -2,7 +2,7 @@ import { EventEmitter } from "node:events"; import type { IncomingMessage, ServerResponse } from "node:http"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk/bluebubbles"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import type { ResolvedBlueBubblesAccount } from "./accounts.js"; import { fetchBlueBubblesHistory } from "./history.js"; import { resetBlueBubblesSelfChatCache } from "./monitor-self-chat-cache.js"; diff --git a/extensions/bluebubbles/src/monitor.webhook-auth.test.ts b/extensions/bluebubbles/src/monitor.webhook-auth.test.ts index f6826ac510b..8d98b0c45eb 100644 --- a/extensions/bluebubbles/src/monitor.webhook-auth.test.ts +++ b/extensions/bluebubbles/src/monitor.webhook-auth.test.ts @@ -2,7 +2,7 @@ import { EventEmitter } from "node:events"; import type { IncomingMessage, ServerResponse } from "node:http"; import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk/bluebubbles"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import type { ResolvedBlueBubblesAccount } from "./accounts.js"; import { fetchBlueBubblesHistory } from "./history.js"; import { diff --git a/extensions/diffs/index.test.ts b/extensions/diffs/index.test.ts index b1ade0c6a09..3e7fd3c474b 100644 --- a/extensions/diffs/index.test.ts +++ b/extensions/diffs/index.test.ts @@ -1,8 +1,8 @@ import type { IncomingMessage } from "node:http"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/diffs"; import { describe, expect, it, vi } from "vitest"; -import { createMockServerResponse } from "../test-utils/mock-http-response.js"; -import { createTestPluginApi } from "../test-utils/plugin-api.js"; +import { createMockServerResponse } from "../../test/helpers/extensions/mock-http-response.js"; +import { createTestPluginApi } from "../../test/helpers/extensions/plugin-api.js"; import plugin from "./index.js"; describe("diffs plugin registration", () => { diff --git a/extensions/diffs/src/http.test.ts b/extensions/diffs/src/http.test.ts index eed9abd77d8..e35d847597b 100644 --- a/extensions/diffs/src/http.test.ts +++ b/extensions/diffs/src/http.test.ts @@ -1,6 +1,6 @@ import type { IncomingMessage } from "node:http"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { createMockServerResponse } from "../../test-utils/mock-http-response.js"; +import { createMockServerResponse } from "../../../test/helpers/extensions/mock-http-response.js"; import { createDiffsHttpHandler } from "./http.js"; import { DiffArtifactStore } from "./store.js"; import { createDiffStoreHarness } from "./test-helpers.js"; diff --git a/extensions/diffs/src/tool.test.ts b/extensions/diffs/src/tool.test.ts index 2f845727274..b0e019f33e2 100644 --- a/extensions/diffs/src/tool.test.ts +++ b/extensions/diffs/src/tool.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import type { OpenClawPluginApi } from "openclaw/plugin-sdk/diffs"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { createTestPluginApi } from "../../test-utils/plugin-api.js"; +import { createTestPluginApi } from "../../../test/helpers/extensions/plugin-api.js"; import type { DiffScreenshotter } from "./browser.js"; import { DEFAULT_DIFFS_TOOL_DEFAULTS } from "./config.js"; import { DiffArtifactStore } from "./store.js"; diff --git a/extensions/discord/src/api.test.ts b/extensions/discord/src/api.test.ts index 09e0863e137..11d15d5f59f 100644 --- a/extensions/discord/src/api.test.ts +++ b/extensions/discord/src/api.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { withFetchPreconnect } from "../../test-utils/fetch-mock.js"; +import { withFetchPreconnect } from "../../../test/helpers/extensions/fetch-mock.js"; import { fetchDiscord } from "./api.js"; import { jsonResponse } from "./test-http-helpers.js"; diff --git a/extensions/discord/src/chunk.test.ts b/extensions/discord/src/chunk.test.ts index 69f5ec856ec..228871fe5d6 100644 --- a/extensions/discord/src/chunk.test.ts +++ b/extensions/discord/src/chunk.test.ts @@ -1,5 +1,8 @@ import { describe, expect, it } from "vitest"; -import { countLines, hasBalancedFences } from "../../test-utils/chunk-test-helpers.js"; +import { + countLines, + hasBalancedFences, +} from "../../../test/helpers/extensions/chunk-test-helpers.js"; import { chunkDiscordText, chunkDiscordTextWithMode } from "./chunk.js"; describe("chunkDiscordText", () => { diff --git a/extensions/discord/src/monitor.test.ts b/extensions/discord/src/monitor.test.ts index b3af666c35f..9836984d555 100644 --- a/extensions/discord/src/monitor.test.ts +++ b/extensions/discord/src/monitor.test.ts @@ -1,6 +1,6 @@ import { ChannelType, type Guild } from "@buape/carbon"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { typedCases } from "../../test-utils/typed-cases.js"; +import { typedCases } from "../../../test/helpers/extensions/typed-cases.js"; import { allowListMatches, buildDiscordMediaPayload, diff --git a/extensions/discord/src/monitor.tool-result.test-harness.ts b/extensions/discord/src/monitor.tool-result.test-harness.ts index fd4f67b0890..6d0405d756c 100644 --- a/extensions/discord/src/monitor.tool-result.test-harness.ts +++ b/extensions/discord/src/monitor.tool-result.test-harness.ts @@ -1,4 +1,4 @@ -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; export const sendMock: MockFn = vi.fn(); diff --git a/extensions/discord/src/monitor/message-handler.module-test-helpers.ts b/extensions/discord/src/monitor/message-handler.module-test-helpers.ts index adeaf7953e7..72327dfc608 100644 --- a/extensions/discord/src/monitor/message-handler.module-test-helpers.ts +++ b/extensions/discord/src/monitor/message-handler.module-test-helpers.ts @@ -1,4 +1,4 @@ -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; export const preflightDiscordMessageMock: MockFn = vi.fn(); diff --git a/extensions/discord/src/monitor/provider.registry.test.ts b/extensions/discord/src/monitor/provider.registry.test.ts index 1070bb744e3..5e092445065 100644 --- a/extensions/discord/src/monitor/provider.registry.test.ts +++ b/extensions/discord/src/monitor/provider.registry.test.ts @@ -5,7 +5,7 @@ import { baseRuntime, getProviderMonitorTestMocks, resetDiscordProviderMonitorMocks, -} from "../../../test-utils/discord-provider.test-support.js"; +} from "../../../../test/helpers/extensions/discord-provider.test-support.js"; const { createDiscordNativeCommandMock, clientHandleDeployRequestMock, monitorLifecycleMock } = getProviderMonitorTestMocks(); diff --git a/extensions/discord/src/monitor/provider.test-support.ts b/extensions/discord/src/monitor/provider.test-support.ts index 9eebb9ad38d..360210e3604 100644 --- a/extensions/discord/src/monitor/provider.test-support.ts +++ b/extensions/discord/src/monitor/provider.test-support.ts @@ -1 +1 @@ -export * from "../../../test-utils/discord-provider.test-support.js"; +export * from "../../../../test/helpers/extensions/discord-provider.test-support.js"; diff --git a/extensions/discord/src/resolve-channels.test.ts b/extensions/discord/src/resolve-channels.test.ts index f053fb97888..8fd06593923 100644 --- a/extensions/discord/src/resolve-channels.test.ts +++ b/extensions/discord/src/resolve-channels.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { withFetchPreconnect } from "../../test-utils/fetch-mock.js"; +import { withFetchPreconnect } from "../../../test/helpers/extensions/fetch-mock.js"; import { resolveDiscordChannelAllowlist } from "./resolve-channels.js"; import { jsonResponse, urlToString } from "./test-http-helpers.js"; diff --git a/extensions/discord/src/resolve-users.test.ts b/extensions/discord/src/resolve-users.test.ts index f67b7289a59..080c312b856 100644 --- a/extensions/discord/src/resolve-users.test.ts +++ b/extensions/discord/src/resolve-users.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { withFetchPreconnect } from "../../test-utils/fetch-mock.js"; +import { withFetchPreconnect } from "../../../test/helpers/extensions/fetch-mock.js"; import { resolveDiscordUserAllowlist } from "./resolve-users.js"; import { jsonResponse, urlToString } from "./test-http-helpers.js"; diff --git a/extensions/discord/src/send.test-harness.ts b/extensions/discord/src/send.test-harness.ts index 8a2058772fc..c0069f99770 100644 --- a/extensions/discord/src/send.test-harness.ts +++ b/extensions/discord/src/send.test-harness.ts @@ -1,4 +1,4 @@ -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; type DiscordWebMediaMockFactoryResult = { diff --git a/extensions/feishu/src/bot.test.ts b/extensions/feishu/src/bot.test.ts index df787b0106a..4594f09fd59 100644 --- a/extensions/feishu/src/bot.test.ts +++ b/extensions/feishu/src/bot.test.ts @@ -1,6 +1,6 @@ import type { ClawdbotConfig, PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/feishu"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import type { FeishuMessageEvent } from "./bot.js"; import { buildBroadcastSessionKey, diff --git a/extensions/feishu/src/monitor.bot-menu.test.ts b/extensions/feishu/src/monitor.bot-menu.test.ts index cecb0b0512c..988e04d80ca 100644 --- a/extensions/feishu/src/monitor.bot-menu.test.ts +++ b/extensions/feishu/src/monitor.bot-menu.test.ts @@ -5,7 +5,7 @@ import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../../src/auto-reply/inbound-debounce.js"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import { monitorSingleAccount } from "./monitor.account.js"; import { setFeishuRuntime } from "./runtime.js"; import type { ResolvedFeishuAccount } from "./types.js"; diff --git a/extensions/feishu/src/monitor.reaction.test.ts b/extensions/feishu/src/monitor.reaction.test.ts index 001b8140f80..048aed2247e 100644 --- a/extensions/feishu/src/monitor.reaction.test.ts +++ b/extensions/feishu/src/monitor.reaction.test.ts @@ -5,7 +5,7 @@ import { createInboundDebouncer, resolveInboundDebounceMs, } from "../../../src/auto-reply/inbound-debounce.js"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import { parseFeishuMessageEvent, type FeishuMessageEvent } from "./bot.js"; import * as dedup from "./dedup.js"; import { monitorSingleAccount } from "./monitor.account.js"; diff --git a/extensions/github-copilot/usage.test.ts b/extensions/github-copilot/usage.test.ts index 0bc97974d70..f0687c33b0a 100644 --- a/extensions/github-copilot/usage.test.ts +++ b/extensions/github-copilot/usage.test.ts @@ -1,5 +1,8 @@ import { describe, expect, it } from "vitest"; -import { createProviderUsageFetch, makeResponse } from "../test-utils/provider-usage-fetch.js"; +import { + createProviderUsageFetch, + makeResponse, +} from "../../test/helpers/extensions/provider-usage-fetch.js"; import { fetchCopilotUsage } from "./usage.js"; describe("fetchCopilotUsage", () => { diff --git a/extensions/googlechat/src/channel.startup.test.ts b/extensions/googlechat/src/channel.startup.test.ts index 11c46aa663a..e65aa444314 100644 --- a/extensions/googlechat/src/channel.startup.test.ts +++ b/extensions/googlechat/src/channel.startup.test.ts @@ -4,7 +4,7 @@ import { abortStartedAccount, expectPendingUntilAbort, startAccountAndTrackLifecycle, -} from "../../test-utils/start-account-lifecycle.js"; +} from "../../../test/helpers/extensions/start-account-lifecycle.js"; import type { ResolvedGoogleChatAccount } from "./accounts.js"; const hoisted = vi.hoisted(() => ({ diff --git a/extensions/googlechat/src/monitor.webhook-routing.test.ts b/extensions/googlechat/src/monitor.webhook-routing.test.ts index 2258d154449..f5e7c69ef8a 100644 --- a/extensions/googlechat/src/monitor.webhook-routing.test.ts +++ b/extensions/googlechat/src/monitor.webhook-routing.test.ts @@ -4,7 +4,7 @@ import type { OpenClawConfig, PluginRuntime } from "openclaw/plugin-sdk/googlech import { afterEach, describe, expect, it, vi } from "vitest"; import { createEmptyPluginRegistry } from "../../../src/plugins/registry.js"; import { setActivePluginRegistry } from "../../../src/plugins/runtime.js"; -import { createMockServerResponse } from "../../test-utils/mock-http-response.js"; +import { createMockServerResponse } from "../../../test/helpers/extensions/mock-http-response.js"; import type { ResolvedGoogleChatAccount } from "./accounts.js"; import { verifyGoogleChatRequest } from "./auth.js"; import { handleGoogleChatWebhookRequest, registerGoogleChatWebhookTarget } from "./monitor.js"; diff --git a/extensions/googlechat/src/setup-surface.test.ts b/extensions/googlechat/src/setup-surface.test.ts index 8ecae3855cc..65c124c8180 100644 --- a/extensions/googlechat/src/setup-surface.test.ts +++ b/extensions/googlechat/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/googlechat"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { googlechatPlugin } from "./channel.js"; const googlechatConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/extensions/irc/src/channel.startup.test.ts b/extensions/irc/src/channel.startup.test.ts index 7b4416d1892..de3526a32d2 100644 --- a/extensions/irc/src/channel.startup.test.ts +++ b/extensions/irc/src/channel.startup.test.ts @@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { expectStopPendingUntilAbort, startAccountAndTrackLifecycle, -} from "../../test-utils/start-account-lifecycle.js"; +} from "../../../test/helpers/extensions/start-account-lifecycle.js"; import type { ResolvedIrcAccount } from "./accounts.js"; const hoisted = vi.hoisted(() => ({ diff --git a/extensions/irc/src/send.test.ts b/extensions/irc/src/send.test.ts index 8fbe58e7f22..7dc064930be 100644 --- a/extensions/irc/src/send.test.ts +++ b/extensions/irc/src/send.test.ts @@ -3,7 +3,7 @@ import { createSendCfgThreadingRuntime, expectProvidedCfgSkipsRuntimeLoad, expectRuntimeCfgFallback, -} from "../../test-utils/send-config.js"; +} from "../../../test/helpers/extensions/send-config.js"; import type { IrcClient } from "./client.js"; import type { CoreConfig } from "./types.js"; diff --git a/extensions/irc/src/setup-surface.test.ts b/extensions/irc/src/setup-surface.test.ts index 6ac3fb268cc..d87ba916622 100644 --- a/extensions/irc/src/setup-surface.test.ts +++ b/extensions/irc/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk/irc"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { ircPlugin } from "./channel.js"; import type { CoreConfig } from "./types.js"; diff --git a/extensions/line/src/channel.logout.test.ts b/extensions/line/src/channel.logout.test.ts index b10d484fbb1..4f474032dc9 100644 --- a/extensions/line/src/channel.logout.test.ts +++ b/extensions/line/src/channel.logout.test.ts @@ -1,6 +1,6 @@ import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "openclaw/plugin-sdk/line"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/channel.startup.test.ts b/extensions/line/src/channel.startup.test.ts index e4de0f38e3b..9f1e10cd6fc 100644 --- a/extensions/line/src/channel.startup.test.ts +++ b/extensions/line/src/channel.startup.test.ts @@ -6,7 +6,7 @@ import type { ResolvedLineAccount, } from "openclaw/plugin-sdk/line"; import { describe, expect, it, vi } from "vitest"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import { linePlugin } from "./channel.js"; import { setLineRuntime } from "./runtime.js"; diff --git a/extensions/line/src/setup-surface.test.ts b/extensions/line/src/setup-surface.test.ts index bf4e560e0df..1606cb3ff22 100644 --- a/extensions/line/src/setup-surface.test.ts +++ b/extensions/line/src/setup-surface.test.ts @@ -6,8 +6,8 @@ import { resolveDefaultLineAccountId, resolveLineAccount, } from "../../../src/line/accounts.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { lineSetupAdapter, lineSetupWizard } from "./setup-surface.js"; const lineConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/extensions/matrix/src/channel.directory.test.ts b/extensions/matrix/src/channel.directory.test.ts index 2c5bc9533f3..ced16d90638 100644 --- a/extensions/matrix/src/channel.directory.test.ts +++ b/extensions/matrix/src/channel.directory.test.ts @@ -1,6 +1,6 @@ import type { PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/matrix"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import { matrixPlugin } from "./channel.js"; import { setMatrixRuntime } from "./runtime.js"; import { createMatrixBotSdkMock } from "./test-mocks.js"; diff --git a/extensions/mattermost/index.test.ts b/extensions/mattermost/index.test.ts index b2ef565c4d2..d21403111cb 100644 --- a/extensions/mattermost/index.test.ts +++ b/extensions/mattermost/index.test.ts @@ -1,6 +1,6 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk/mattermost"; import { describe, expect, it, vi } from "vitest"; -import { createTestPluginApi } from "../test-utils/plugin-api.js"; +import { createTestPluginApi } from "../../test/helpers/extensions/plugin-api.js"; import plugin from "./index.js"; function createApi( diff --git a/extensions/mattermost/src/mattermost/send.test.ts b/extensions/mattermost/src/mattermost/send.test.ts index 774f40f99fa..15cf05eb541 100644 --- a/extensions/mattermost/src/mattermost/send.test.ts +++ b/extensions/mattermost/src/mattermost/send.test.ts @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { expectProvidedCfgSkipsRuntimeLoad, expectRuntimeCfgFallback, -} from "../../../test-utils/send-config.js"; +} from "../../../../test/helpers/extensions/send-config.js"; import { parseMattermostTarget, sendMessageMattermost } from "./send.js"; import { resetMattermostOpaqueTargetCacheForTests } from "./target-resolution.js"; diff --git a/extensions/msteams/src/attachments.test.ts b/extensions/msteams/src/attachments.test.ts index 790dc8bd33f..fa119a2b44a 100644 --- a/extensions/msteams/src/attachments.test.ts +++ b/extensions/msteams/src/attachments.test.ts @@ -1,6 +1,6 @@ import type { PluginRuntime, SsrFPolicy } from "openclaw/plugin-sdk/msteams"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import { buildMSTeamsAttachmentPlaceholder, buildMSTeamsGraphMessageUrls, diff --git a/extensions/msteams/src/channel.directory.test.ts b/extensions/msteams/src/channel.directory.test.ts index be95e6103ea..df3547d012a 100644 --- a/extensions/msteams/src/channel.directory.test.ts +++ b/extensions/msteams/src/channel.directory.test.ts @@ -1,6 +1,9 @@ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk/msteams"; import { describe, expect, it } from "vitest"; -import { createDirectoryTestRuntime, expectDirectorySurface } from "../../test-utils/directory.js"; +import { + createDirectoryTestRuntime, + expectDirectorySurface, +} from "../../../test/helpers/extensions/directory.js"; import { msteamsPlugin } from "./channel.js"; describe("msteams directory", () => { diff --git a/extensions/msteams/src/graph-upload.test.ts b/extensions/msteams/src/graph-upload.test.ts index 90a9da1d352..a41147840ec 100644 --- a/extensions/msteams/src/graph-upload.test.ts +++ b/extensions/msteams/src/graph-upload.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from "vitest"; -import { withFetchPreconnect } from "../../test-utils/fetch-mock.js"; +import { withFetchPreconnect } from "../../../test/helpers/extensions/fetch-mock.js"; import { uploadToOneDrive, uploadToSharePoint } from "./graph-upload.js"; describe("graph upload helpers", () => { diff --git a/extensions/msteams/src/messenger.test.ts b/extensions/msteams/src/messenger.test.ts index cc4cf2fb6f0..e67017ed8fc 100644 --- a/extensions/msteams/src/messenger.test.ts +++ b/extensions/msteams/src/messenger.test.ts @@ -3,7 +3,7 @@ import os from "node:os"; import path from "node:path"; import { SILENT_REPLY_TOKEN, type PluginRuntime } from "openclaw/plugin-sdk/msteams"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { createPluginRuntimeMock } from "../../test-utils/plugin-runtime-mock.js"; +import { createPluginRuntimeMock } from "../../../test/helpers/extensions/plugin-runtime-mock.js"; import type { StoredConversationReference } from "./conversation-store.js"; const graphUploadMockState = vi.hoisted(() => ({ uploadAndShareOneDrive: vi.fn(), diff --git a/extensions/nextcloud-talk/src/channel.startup.test.ts b/extensions/nextcloud-talk/src/channel.startup.test.ts index 5fd0607e753..e0117936f51 100644 --- a/extensions/nextcloud-talk/src/channel.startup.test.ts +++ b/extensions/nextcloud-talk/src/channel.startup.test.ts @@ -1,9 +1,9 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { createStartAccountContext } from "../../test-utils/start-account-context.js"; +import { createStartAccountContext } from "../../../test/helpers/extensions/start-account-context.js"; import { expectStopPendingUntilAbort, startAccountAndTrackLifecycle, -} from "../../test-utils/start-account-lifecycle.js"; +} from "../../../test/helpers/extensions/start-account-lifecycle.js"; import type { ResolvedNextcloudTalkAccount } from "./accounts.js"; const hoisted = vi.hoisted(() => ({ diff --git a/extensions/nextcloud-talk/src/send.test.ts b/extensions/nextcloud-talk/src/send.test.ts index 3ee178b815d..b82ac1c4309 100644 --- a/extensions/nextcloud-talk/src/send.test.ts +++ b/extensions/nextcloud-talk/src/send.test.ts @@ -3,7 +3,7 @@ import { createSendCfgThreadingRuntime, expectProvidedCfgSkipsRuntimeLoad, expectRuntimeCfgFallback, -} from "../../test-utils/send-config.js"; +} from "../../../test/helpers/extensions/send-config.js"; const hoisted = vi.hoisted(() => ({ loadConfig: vi.fn(), diff --git a/extensions/nostr/src/channel.outbound.test.ts b/extensions/nostr/src/channel.outbound.test.ts index 0aa63485951..0bbe7f880bf 100644 --- a/extensions/nostr/src/channel.outbound.test.ts +++ b/extensions/nostr/src/channel.outbound.test.ts @@ -1,6 +1,6 @@ import type { PluginRuntime } from "openclaw/plugin-sdk/nostr"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { createStartAccountContext } from "../../test-utils/start-account-context.js"; +import { createStartAccountContext } from "../../../test/helpers/extensions/start-account-context.js"; import { nostrPlugin } from "./channel.js"; import { setNostrRuntime } from "./runtime.js"; diff --git a/extensions/nostr/src/setup-surface.test.ts b/extensions/nostr/src/setup-surface.test.ts index 2985ff3e513..a883fda1234 100644 --- a/extensions/nostr/src/setup-surface.test.ts +++ b/extensions/nostr/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/nostr"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { nostrPlugin } from "./channel.js"; const nostrConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/extensions/phone-control/index.test.ts b/extensions/phone-control/index.test.ts index 5964919e9d7..e5fe260463b 100644 --- a/extensions/phone-control/index.test.ts +++ b/extensions/phone-control/index.test.ts @@ -7,7 +7,7 @@ import type { PluginCommandContext, } from "openclaw/plugin-sdk/phone-control"; import { describe, expect, it, vi } from "vitest"; -import { createTestPluginApi } from "../test-utils/plugin-api.js"; +import { createTestPluginApi } from "../../test/helpers/extensions/plugin-api.js"; import registerPhoneControl from "./index.js"; function createApi(params: { diff --git a/extensions/signal/src/monitor.tool-result.test-harness.ts b/extensions/signal/src/monitor.tool-result.test-harness.ts index 10cf32b383a..bcca049f4d7 100644 --- a/extensions/signal/src/monitor.tool-result.test-harness.ts +++ b/extensions/signal/src/monitor.tool-result.test-harness.ts @@ -1,6 +1,6 @@ import { resetSystemEventsForTest } from "openclaw/plugin-sdk/infra-runtime"; import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime"; -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { beforeEach, vi } from "vitest"; import type { SignalDaemonExitEvent, SignalDaemonHandle } from "./daemon.js"; diff --git a/extensions/slack/src/monitor/media.test.ts b/extensions/slack/src/monitor/media.test.ts index 9d5114e2961..9ac0bc0eeb1 100644 --- a/extensions/slack/src/monitor/media.test.ts +++ b/extensions/slack/src/monitor/media.test.ts @@ -4,7 +4,10 @@ import * as mediaFetch from "../../../../src/media/fetch.js"; import type { SavedMedia } from "../../../../src/media/store.js"; import * as mediaStore from "../../../../src/media/store.js"; import { mockPinnedHostnameResolution } from "../../../../src/test-helpers/ssrf.js"; -import { type FetchMock, withFetchPreconnect } from "../../../test-utils/fetch-mock.js"; +import { + type FetchMock, + withFetchPreconnect, +} from "../../../../test/helpers/extensions/fetch-mock.js"; import { fetchWithSlackAuth, resolveSlackAttachmentContent, diff --git a/extensions/synology-chat/src/setup-surface.test.ts b/extensions/synology-chat/src/setup-surface.test.ts index 96c17300e0f..f6fbf48606f 100644 --- a/extensions/synology-chat/src/setup-surface.test.ts +++ b/extensions/synology-chat/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; import type { OpenClawConfig } from "../../../src/config/config.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { synologyChatPlugin } from "./channel.js"; import { synologyChatSetupWizard } from "./setup-surface.js"; diff --git a/extensions/talk-voice/index.test.ts b/extensions/talk-voice/index.test.ts index 5b246c94bf1..487df4a2d7a 100644 --- a/extensions/talk-voice/index.test.ts +++ b/extensions/talk-voice/index.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import type { OpenClawPluginCommandDefinition } from "../test-utils/plugin-command.js"; -import { createPluginRuntimeMock } from "../test-utils/plugin-runtime-mock.js"; +import type { OpenClawPluginCommandDefinition } from "../../test/helpers/extensions/plugin-command.js"; +import { createPluginRuntimeMock } from "../../test/helpers/extensions/plugin-runtime-mock.js"; import register from "./index.js"; function createHarness(config: Record) { diff --git a/extensions/telegram/src/account-inspect.test.ts b/extensions/telegram/src/account-inspect.test.ts index 54915edb61c..735cf4e53bb 100644 --- a/extensions/telegram/src/account-inspect.test.ts +++ b/extensions/telegram/src/account-inspect.test.ts @@ -3,7 +3,7 @@ import os from "node:os"; import path from "node:path"; import { describe, expect, it } from "vitest"; import type { OpenClawConfig } from "../../../src/config/config.js"; -import { withEnv } from "../../test-utils/env.js"; +import { withEnv } from "../../../test/helpers/extensions/env.js"; import { inspectTelegramAccount } from "./account-inspect.js"; describe("inspectTelegramAccount SecretRef resolution", () => { diff --git a/extensions/telegram/src/accounts.test.ts b/extensions/telegram/src/accounts.test.ts index 6155b89d0af..ae8a56c66cf 100644 --- a/extensions/telegram/src/accounts.test.ts +++ b/extensions/telegram/src/accounts.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../../../src/config/config.js"; import * as subsystemModule from "../../../src/logging/subsystem.js"; -import { withEnv } from "../../test-utils/env.js"; +import { withEnv } from "../../../test/helpers/extensions/env.js"; import { listTelegramAccountIds, resetMissingDefaultWarnFlag, diff --git a/extensions/telegram/src/bot-native-commands.test-helpers.ts b/extensions/telegram/src/bot-native-commands.test-helpers.ts index 43059cd9b61..3afeb63fbb2 100644 --- a/extensions/telegram/src/bot-native-commands.test-helpers.ts +++ b/extensions/telegram/src/bot-native-commands.test-helpers.ts @@ -2,7 +2,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import type { ChannelGroupPolicy } from "openclaw/plugin-sdk/config-runtime"; import type { TelegramAccountConfig } from "openclaw/plugin-sdk/config-runtime"; import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env"; -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; import { createNativeCommandTestParams, diff --git a/extensions/telegram/src/bot.create-telegram-bot.test-harness.ts b/extensions/telegram/src/bot.create-telegram-bot.test-harness.ts index 9f3eea03954..9d015e770a5 100644 --- a/extensions/telegram/src/bot.create-telegram-bot.test-harness.ts +++ b/extensions/telegram/src/bot.create-telegram-bot.test-harness.ts @@ -2,7 +2,7 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { resetInboundDedupe } from "openclaw/plugin-sdk/reply-runtime"; import type { MsgContext } from "openclaw/plugin-sdk/reply-runtime"; import type { GetReplyOptions, ReplyPayload } from "openclaw/plugin-sdk/reply-runtime"; -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { beforeEach, vi } from "vitest"; type AnyMock = MockFn<(...args: unknown[]) => unknown>; diff --git a/extensions/telegram/src/bot.create-telegram-bot.test.ts b/extensions/telegram/src/bot.create-telegram-bot.test.ts index 3390aa3ff24..1cb0fd98512 100644 --- a/extensions/telegram/src/bot.create-telegram-bot.test.ts +++ b/extensions/telegram/src/bot.create-telegram-bot.test.ts @@ -3,8 +3,8 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import { escapeRegExp, formatEnvelopeTimestamp } from "../../../test/helpers/envelope-timestamp.js"; -import { withEnvAsync } from "../../test-utils/env.js"; -import { useFrozenTime, useRealTime } from "../../test-utils/frozen-time.js"; +import { withEnvAsync } from "../../../test/helpers/extensions/env.js"; +import { useFrozenTime, useRealTime } from "../../../test/helpers/extensions/frozen-time.js"; import { answerCallbackQuerySpy, botCtorSpy, diff --git a/extensions/telegram/src/channel.test.ts b/extensions/telegram/src/channel.test.ts index 48d16361b1a..bac2de59f0b 100644 --- a/extensions/telegram/src/channel.test.ts +++ b/extensions/telegram/src/channel.test.ts @@ -5,7 +5,7 @@ import type { PluginRuntime, } from "openclaw/plugin-sdk/telegram"; import { afterEach, describe, expect, it, vi } from "vitest"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; import type { ResolvedTelegramAccount } from "./accounts.js"; import * as auditModule from "./audit.js"; import { telegramPlugin } from "./channel.js"; diff --git a/extensions/telegram/src/probe.test.ts b/extensions/telegram/src/probe.test.ts index 970e2559540..da6f86f9b80 100644 --- a/extensions/telegram/src/probe.test.ts +++ b/extensions/telegram/src/probe.test.ts @@ -1,5 +1,5 @@ import { afterEach, type Mock, describe, expect, it, vi } from "vitest"; -import { withFetchPreconnect } from "../../test-utils/fetch-mock.js"; +import { withFetchPreconnect } from "../../../test/helpers/extensions/fetch-mock.js"; import { probeTelegram, resetTelegramProbeFetcherCacheForTests } from "./probe.js"; const resolveTelegramFetch = vi.hoisted(() => vi.fn()); diff --git a/extensions/telegram/src/send.test-harness.ts b/extensions/telegram/src/send.test-harness.ts index c12a571c642..f313141dab0 100644 --- a/extensions/telegram/src/send.test-harness.ts +++ b/extensions/telegram/src/send.test-harness.ts @@ -1,4 +1,4 @@ -import type { MockFn } from "openclaw/plugin-sdk/test-utils"; +import type { MockFn } from "openclaw/plugin-sdk/testing"; import { beforeEach, vi } from "vitest"; const { botApi, botCtorSpy } = vi.hoisted(() => ({ diff --git a/extensions/test-utils/chunk-test-helpers.ts b/extensions/test-utils/chunk-test-helpers.ts deleted file mode 100644 index 643e28e5c24..00000000000 --- a/extensions/test-utils/chunk-test-helpers.ts +++ /dev/null @@ -1 +0,0 @@ -export { countLines, hasBalancedFences } from "../../src/test-utils/chunk-test-helpers.js"; diff --git a/extensions/test-utils/env.ts b/extensions/test-utils/env.ts deleted file mode 100644 index b171aa55a6c..00000000000 --- a/extensions/test-utils/env.ts +++ /dev/null @@ -1 +0,0 @@ -export { captureEnv, withEnv, withEnvAsync } from "../../src/test-utils/env.js"; diff --git a/extensions/test-utils/fetch-mock.ts b/extensions/test-utils/fetch-mock.ts deleted file mode 100644 index 2cd6b65e680..00000000000 --- a/extensions/test-utils/fetch-mock.ts +++ /dev/null @@ -1 +0,0 @@ -export { withFetchPreconnect, type FetchMock } from "../../src/test-utils/fetch-mock.js"; diff --git a/extensions/test-utils/frozen-time.ts b/extensions/test-utils/frozen-time.ts deleted file mode 100644 index ec31962fb76..00000000000 --- a/extensions/test-utils/frozen-time.ts +++ /dev/null @@ -1 +0,0 @@ -export { useFrozenTime, useRealTime } from "../../src/test-utils/frozen-time.js"; diff --git a/extensions/test-utils/mock-http-response.ts b/extensions/test-utils/mock-http-response.ts deleted file mode 100644 index bf0d8bef20c..00000000000 --- a/extensions/test-utils/mock-http-response.ts +++ /dev/null @@ -1 +0,0 @@ -export { createMockServerResponse } from "../../src/test-utils/mock-http-response.js"; diff --git a/extensions/test-utils/plugin-registration.ts b/extensions/test-utils/plugin-registration.ts deleted file mode 100644 index 7a7da8ecdad..00000000000 --- a/extensions/test-utils/plugin-registration.ts +++ /dev/null @@ -1 +0,0 @@ -export { registerSingleProviderPlugin } from "../../src/test-utils/plugin-registration.js"; diff --git a/extensions/test-utils/provider-usage-fetch.ts b/extensions/test-utils/provider-usage-fetch.ts deleted file mode 100644 index d70a6e1657a..00000000000 --- a/extensions/test-utils/provider-usage-fetch.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { - createProviderUsageFetch, - makeResponse, -} from "../../src/test-utils/provider-usage-fetch.js"; diff --git a/extensions/test-utils/temp-dir.ts b/extensions/test-utils/temp-dir.ts deleted file mode 100644 index 3bd69bcc7b9..00000000000 --- a/extensions/test-utils/temp-dir.ts +++ /dev/null @@ -1 +0,0 @@ -export { withTempDir } from "../../src/test-utils/temp-dir.js"; diff --git a/extensions/test-utils/typed-cases.ts b/extensions/test-utils/typed-cases.ts deleted file mode 100644 index 4b6bd35b1ec..00000000000 --- a/extensions/test-utils/typed-cases.ts +++ /dev/null @@ -1 +0,0 @@ -export { typedCases } from "../../src/test-utils/typed-cases.js"; diff --git a/extensions/tlon/src/setup-surface.test.ts b/extensions/tlon/src/setup-surface.test.ts index f2b53f0df72..d10e35785db 100644 --- a/extensions/tlon/src/setup-surface.test.ts +++ b/extensions/tlon/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk/tlon"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { tlonPlugin } from "./channel.js"; const tlonConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/extensions/whatsapp/src/accounts.whatsapp-auth.test.ts b/extensions/whatsapp/src/accounts.whatsapp-auth.test.ts index 43d1739e13f..9926b3c5324 100644 --- a/extensions/whatsapp/src/accounts.whatsapp-auth.test.ts +++ b/extensions/whatsapp/src/accounts.whatsapp-auth.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs"; import os from "node:os"; import path from "node:path"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { captureEnv } from "../../test-utils/env.js"; +import { captureEnv } from "../../../test/helpers/extensions/env.js"; import { hasAnyWhatsAppAuth, listWhatsAppAuthDirs } from "./accounts.js"; describe("hasAnyWhatsAppAuth", () => { diff --git a/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts b/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts index 6a5184fc059..235942663a8 100644 --- a/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +++ b/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts @@ -5,7 +5,7 @@ import { beforeAll, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../../../src/config/config.js"; import { setLoggerOverride } from "../../../src/logging.js"; import { escapeRegExp, formatEnvelopeTimestamp } from "../../../test/helpers/envelope-timestamp.js"; -import { withEnvAsync } from "../../test-utils/env.js"; +import { withEnvAsync } from "../../../test/helpers/extensions/env.js"; import { createMockWebListener, createWebListenerFactoryCapture, diff --git a/extensions/whatsapp/src/auto-reply/web-auto-reply-utils.test.ts b/extensions/whatsapp/src/auto-reply/web-auto-reply-utils.test.ts index d1011f5c7f8..eb733d14e0e 100644 --- a/extensions/whatsapp/src/auto-reply/web-auto-reply-utils.test.ts +++ b/extensions/whatsapp/src/auto-reply/web-auto-reply-utils.test.ts @@ -2,7 +2,7 @@ import fs from "node:fs/promises"; import path from "node:path"; import { describe, expect, it, vi } from "vitest"; import { saveSessionStore } from "../../../../src/config/sessions.js"; -import { withTempDir } from "../../../test-utils/temp-dir.js"; +import { withTempDir } from "../../../../test/helpers/extensions/temp-dir.js"; import { debugMention, isBotMentionedFromTargets, diff --git a/extensions/whatsapp/src/media.test.ts b/extensions/whatsapp/src/media.test.ts index 45f3fbae309..ce3e98c549c 100644 --- a/extensions/whatsapp/src/media.test.ts +++ b/extensions/whatsapp/src/media.test.ts @@ -7,8 +7,8 @@ import { resolveStateDir } from "../../../src/config/paths.js"; import { resolvePreferredOpenClawTmpDir } from "../../../src/infra/tmp-openclaw-dir.js"; import { optimizeImageToPng } from "../../../src/media/image-ops.js"; import { mockPinnedHostnameResolution } from "../../../src/test-helpers/ssrf.js"; +import { captureEnv } from "../../../test/helpers/extensions/env.js"; import { sendVoiceMessageDiscord } from "../../discord/src/send.js"; -import { captureEnv } from "../../test-utils/env.js"; import { LocalMediaAccessError, loadWebMedia, diff --git a/extensions/zalo/src/channel.directory.test.ts b/extensions/zalo/src/channel.directory.test.ts index 8a303e72a97..ac079109736 100644 --- a/extensions/zalo/src/channel.directory.test.ts +++ b/extensions/zalo/src/channel.directory.test.ts @@ -1,6 +1,9 @@ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk/zalo"; import { describe, expect, it } from "vitest"; -import { createDirectoryTestRuntime, expectDirectorySurface } from "../../test-utils/directory.js"; +import { + createDirectoryTestRuntime, + expectDirectorySurface, +} from "../../../test/helpers/extensions/directory.js"; import { zaloPlugin } from "./channel.js"; describe("zalo directory", () => { diff --git a/extensions/zalo/src/channel.startup.test.ts b/extensions/zalo/src/channel.startup.test.ts index ea0718d29a2..d99f2397438 100644 --- a/extensions/zalo/src/channel.startup.test.ts +++ b/extensions/zalo/src/channel.startup.test.ts @@ -3,7 +3,7 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import { expectPendingUntilAbort, startAccountAndTrackLifecycle, -} from "../../test-utils/start-account-lifecycle.js"; +} from "../../../test/helpers/extensions/start-account-lifecycle.js"; import type { ResolvedZaloAccount } from "./accounts.js"; const hoisted = vi.hoisted(() => ({ diff --git a/extensions/zalo/src/setup-surface.test.ts b/extensions/zalo/src/setup-surface.test.ts index a6e278b6f69..858720c74a8 100644 --- a/extensions/zalo/src/setup-surface.test.ts +++ b/extensions/zalo/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig, RuntimeEnv } from "openclaw/plugin-sdk/zalo"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter, type WizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter, type WizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; import { zaloPlugin } from "./channel.js"; const zaloConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({ diff --git a/extensions/zalo/src/status-issues.test.ts b/extensions/zalo/src/status-issues.test.ts index 581a0dfe916..1187d45a298 100644 --- a/extensions/zalo/src/status-issues.test.ts +++ b/extensions/zalo/src/status-issues.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { expectOpenDmPolicyConfigIssue } from "../../test-utils/status-issues.js"; +import { expectOpenDmPolicyConfigIssue } from "../../../test/helpers/extensions/status-issues.js"; import { collectZaloStatusIssues } from "./status-issues.js"; describe("collectZaloStatusIssues", () => { diff --git a/extensions/zalouser/src/setup-surface.test.ts b/extensions/zalouser/src/setup-surface.test.ts index 1aa8dd93bd0..af95c35465b 100644 --- a/extensions/zalouser/src/setup-surface.test.ts +++ b/extensions/zalouser/src/setup-surface.test.ts @@ -1,8 +1,8 @@ import type { OpenClawConfig } from "openclaw/plugin-sdk/zalouser"; import { describe, expect, it, vi } from "vitest"; import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js"; -import { createRuntimeEnv } from "../../test-utils/runtime-env.js"; -import { createTestWizardPrompter } from "../../test-utils/setup-wizard.js"; +import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js"; +import { createTestWizardPrompter } from "../../../test/helpers/extensions/setup-wizard.js"; vi.mock("./zalo-js.js", async (importOriginal) => { const actual = await importOriginal(); diff --git a/extensions/zalouser/src/status-issues.test.ts b/extensions/zalouser/src/status-issues.test.ts index c1e142c88e8..bd1ae4d4cd4 100644 --- a/extensions/zalouser/src/status-issues.test.ts +++ b/extensions/zalouser/src/status-issues.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from "vitest"; -import { expectOpenDmPolicyConfigIssue } from "../../test-utils/status-issues.js"; +import { expectOpenDmPolicyConfigIssue } from "../../../test/helpers/extensions/status-issues.js"; import { collectZalouserStatusIssues } from "./status-issues.js"; describe("collectZalouserStatusIssues", () => { diff --git a/package.json b/package.json index e1e9379c1a8..c6ed4cab402 100644 --- a/package.json +++ b/package.json @@ -278,6 +278,10 @@ "types": "./dist/plugin-sdk/talk-voice.d.ts", "default": "./dist/plugin-sdk/talk-voice.js" }, + "./plugin-sdk/testing": { + "types": "./dist/plugin-sdk/testing.d.ts", + "default": "./dist/plugin-sdk/testing.js" + }, "./plugin-sdk/test-utils": { "types": "./dist/plugin-sdk/test-utils.d.ts", "default": "./dist/plugin-sdk/test-utils.js" diff --git a/scripts/check-no-extension-test-core-imports.ts b/scripts/check-no-extension-test-core-imports.ts index b8e3b1bc764..01d6639df1e 100644 --- a/scripts/check-no-extension-test-core-imports.ts +++ b/scripts/check-no-extension-test-core-imports.ts @@ -6,17 +6,25 @@ const FORBIDDEN_PATTERNS: Array<{ pattern: RegExp; hint: string }> = [ pattern: /["']openclaw\/plugin-sdk["']/, hint: "Use openclaw/plugin-sdk/ instead of the monolithic root entry.", }, + { + pattern: /["']openclaw\/plugin-sdk\/test-utils["']/, + hint: "Use openclaw/plugin-sdk/testing for the public extension test seam.", + }, { pattern: /["']openclaw\/plugin-sdk\/compat["']/, hint: "Use a focused public plugin-sdk subpath instead of compat.", }, + { + pattern: /["'](?:\.\.\/)+(?:test-utils\/)[^"']+["']/, + hint: "Use test/helpers/extensions/* for repo-only bundled extension test helpers.", + }, { pattern: /["'](?:\.\.\/)+(?:src\/test-utils\/)[^"']+["']/, - hint: "Use extensions/test-utils/* bridges for shared extension test helpers.", + hint: "Use test/helpers/extensions/* for repo-only helpers, or openclaw/plugin-sdk/testing for public seams.", }, { pattern: /["'](?:\.\.\/)+(?:src\/plugins\/types\.js)["']/, - hint: "Use public plugin-sdk/core types or extensions/test-utils bridges instead.", + hint: "Use public plugin-sdk/core types or test/helpers/extensions/* instead.", }, ]; diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 801cebcd462..6e41a759867 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -59,6 +59,7 @@ "qwen-portal-auth", "synology-chat", "talk-voice", + "testing", "test-utils", "thread-ownership", "tlon", diff --git a/src/plugin-sdk/subpaths.test.ts b/src/plugin-sdk/subpaths.test.ts index a3cc2b3ba1f..7a43a159b73 100644 --- a/src/plugin-sdk/subpaths.test.ts +++ b/src/plugin-sdk/subpaths.test.ts @@ -20,6 +20,7 @@ import * as setupSdk from "openclaw/plugin-sdk/setup"; import * as signalSdk from "openclaw/plugin-sdk/signal"; import * as slackSdk from "openclaw/plugin-sdk/slack"; import * as telegramSdk from "openclaw/plugin-sdk/telegram"; +import * as testingSdk from "openclaw/plugin-sdk/testing"; import * as whatsappSdk from "openclaw/plugin-sdk/whatsapp"; import { describe, expect, expectTypeOf, it } from "vitest"; import type { ChannelMessageActionContext } from "../channels/plugins/types.js"; @@ -114,6 +115,11 @@ describe("plugin-sdk subpath exports", () => { expectTypeOf().toMatchTypeOf(); }); + it("exports the public testing seam", () => { + expect(typeof testingSdk.removeAckReactionAfterReply).toBe("function"); + expect(typeof testingSdk.shouldAckReaction).toBe("function"); + }); + it("keeps core shared types aligned with the channel prelude", () => { expectTypeOf().toMatchTypeOf(); expectTypeOf().toMatchTypeOf(); diff --git a/src/plugin-sdk/test-utils.ts b/src/plugin-sdk/test-utils.ts index 5d825813d0e..26cddc72854 100644 --- a/src/plugin-sdk/test-utils.ts +++ b/src/plugin-sdk/test-utils.ts @@ -1,9 +1,4 @@ -// Narrow plugin-sdk surface for the bundled test-utils plugin. -// Keep this list additive and scoped to symbols used under extensions/test-utils. +// Deprecated compatibility alias. +// Prefer openclaw/plugin-sdk/testing for public test helpers. -export { removeAckReactionAfterReply, shouldAckReaction } from "../channels/ack-reactions.js"; -export type { ChannelAccountSnapshot, ChannelGatewayContext } from "../channels/plugins/types.js"; -export type { OpenClawConfig } from "../config/config.js"; -export type { PluginRuntime } from "../plugins/runtime/types.js"; -export type { RuntimeEnv } from "../runtime.js"; -export type { MockFn } from "../test-utils/vitest-mock-fn.js"; +export * from "./testing.js"; diff --git a/src/plugin-sdk/testing.ts b/src/plugin-sdk/testing.ts new file mode 100644 index 00000000000..e8a7e89f646 --- /dev/null +++ b/src/plugin-sdk/testing.ts @@ -0,0 +1,9 @@ +// Narrow public testing surface for plugin authors. +// Keep this list additive and limited to helpers we are willing to support. + +export { removeAckReactionAfterReply, shouldAckReaction } from "../channels/ack-reactions.js"; +export type { ChannelAccountSnapshot, ChannelGatewayContext } from "../channels/plugins/types.js"; +export type { OpenClawConfig } from "../config/config.js"; +export type { PluginRuntime } from "../plugins/runtime/types.js"; +export type { RuntimeEnv } from "../runtime.js"; +export type { MockFn } from "../test-utils/vitest-mock-fn.js"; diff --git a/test/helpers/extensions/chunk-test-helpers.ts b/test/helpers/extensions/chunk-test-helpers.ts new file mode 100644 index 00000000000..c6589284fd3 --- /dev/null +++ b/test/helpers/extensions/chunk-test-helpers.ts @@ -0,0 +1 @@ +export { countLines, hasBalancedFences } from "../../../src/test-utils/chunk-test-helpers.js"; diff --git a/extensions/test-utils/directory.ts b/test/helpers/extensions/directory.ts similarity index 100% rename from extensions/test-utils/directory.ts rename to test/helpers/extensions/directory.ts diff --git a/extensions/test-utils/discord-provider.test-support.ts b/test/helpers/extensions/discord-provider.test-support.ts similarity index 100% rename from extensions/test-utils/discord-provider.test-support.ts rename to test/helpers/extensions/discord-provider.test-support.ts diff --git a/test/helpers/extensions/env.ts b/test/helpers/extensions/env.ts new file mode 100644 index 00000000000..bc48bfd3d10 --- /dev/null +++ b/test/helpers/extensions/env.ts @@ -0,0 +1 @@ +export { captureEnv, withEnv, withEnvAsync } from "../../../src/test-utils/env.js"; diff --git a/test/helpers/extensions/fetch-mock.ts b/test/helpers/extensions/fetch-mock.ts new file mode 100644 index 00000000000..e1774b46463 --- /dev/null +++ b/test/helpers/extensions/fetch-mock.ts @@ -0,0 +1 @@ +export { withFetchPreconnect, type FetchMock } from "../../../src/test-utils/fetch-mock.js"; diff --git a/test/helpers/extensions/frozen-time.ts b/test/helpers/extensions/frozen-time.ts new file mode 100644 index 00000000000..69f188f09ca --- /dev/null +++ b/test/helpers/extensions/frozen-time.ts @@ -0,0 +1 @@ +export { useFrozenTime, useRealTime } from "../../../src/test-utils/frozen-time.js"; diff --git a/test/helpers/extensions/mock-http-response.ts b/test/helpers/extensions/mock-http-response.ts new file mode 100644 index 00000000000..3bbed0372a8 --- /dev/null +++ b/test/helpers/extensions/mock-http-response.ts @@ -0,0 +1 @@ +export { createMockServerResponse } from "../../../src/test-utils/mock-http-response.js"; diff --git a/extensions/test-utils/plugin-api.ts b/test/helpers/extensions/plugin-api.ts similarity index 100% rename from extensions/test-utils/plugin-api.ts rename to test/helpers/extensions/plugin-api.ts diff --git a/extensions/test-utils/plugin-command.ts b/test/helpers/extensions/plugin-command.ts similarity index 100% rename from extensions/test-utils/plugin-command.ts rename to test/helpers/extensions/plugin-command.ts diff --git a/test/helpers/extensions/plugin-registration.ts b/test/helpers/extensions/plugin-registration.ts new file mode 100644 index 00000000000..bd20510800e --- /dev/null +++ b/test/helpers/extensions/plugin-registration.ts @@ -0,0 +1 @@ +export { registerSingleProviderPlugin } from "../../../src/test-utils/plugin-registration.js"; diff --git a/extensions/test-utils/plugin-runtime-mock.ts b/test/helpers/extensions/plugin-runtime-mock.ts similarity index 99% rename from extensions/test-utils/plugin-runtime-mock.ts rename to test/helpers/extensions/plugin-runtime-mock.ts index fbc9bcdc7fd..d71eeb2d584 100644 --- a/extensions/test-utils/plugin-runtime-mock.ts +++ b/test/helpers/extensions/plugin-runtime-mock.ts @@ -1,6 +1,6 @@ import { DEFAULT_MODEL, DEFAULT_PROVIDER } from "openclaw/plugin-sdk/agent-runtime"; -import type { PluginRuntime } from "openclaw/plugin-sdk/test-utils"; -import { removeAckReactionAfterReply, shouldAckReaction } from "openclaw/plugin-sdk/test-utils"; +import type { PluginRuntime } from "openclaw/plugin-sdk/testing"; +import { removeAckReactionAfterReply, shouldAckReaction } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; type DeepPartial = { diff --git a/test/helpers/extensions/provider-usage-fetch.ts b/test/helpers/extensions/provider-usage-fetch.ts new file mode 100644 index 00000000000..fe54174732e --- /dev/null +++ b/test/helpers/extensions/provider-usage-fetch.ts @@ -0,0 +1,4 @@ +export { + createProviderUsageFetch, + makeResponse, +} from "../../../src/test-utils/provider-usage-fetch.js"; diff --git a/extensions/test-utils/runtime-env.ts b/test/helpers/extensions/runtime-env.ts similarity index 77% rename from extensions/test-utils/runtime-env.ts rename to test/helpers/extensions/runtime-env.ts index a5e52665b0e..b197619e43e 100644 --- a/extensions/test-utils/runtime-env.ts +++ b/test/helpers/extensions/runtime-env.ts @@ -1,4 +1,4 @@ -import type { RuntimeEnv } from "openclaw/plugin-sdk/test-utils"; +import type { RuntimeEnv } from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; export function createRuntimeEnv(): RuntimeEnv { diff --git a/extensions/test-utils/send-config.ts b/test/helpers/extensions/send-config.ts similarity index 100% rename from extensions/test-utils/send-config.ts rename to test/helpers/extensions/send-config.ts diff --git a/extensions/test-utils/setup-wizard.ts b/test/helpers/extensions/setup-wizard.ts similarity index 84% rename from extensions/test-utils/setup-wizard.ts rename to test/helpers/extensions/setup-wizard.ts index aab15a4aecc..109394ee886 100644 --- a/extensions/test-utils/setup-wizard.ts +++ b/test/helpers/extensions/setup-wizard.ts @@ -1,7 +1,7 @@ import { vi } from "vitest"; -import type { WizardPrompter } from "../../src/wizard/prompts.js"; +import type { WizardPrompter } from "../../../src/wizard/prompts.js"; -export type { WizardPrompter } from "../../src/wizard/prompts.js"; +export type { WizardPrompter } from "../../../src/wizard/prompts.js"; export async function selectFirstWizardOption(params: { options: Array<{ value: T }>; diff --git a/extensions/test-utils/start-account-context.ts b/test/helpers/extensions/start-account-context.ts similarity index 95% rename from extensions/test-utils/start-account-context.ts rename to test/helpers/extensions/start-account-context.ts index a878b3dbfd9..56a66a9ca56 100644 --- a/extensions/test-utils/start-account-context.ts +++ b/test/helpers/extensions/start-account-context.ts @@ -2,7 +2,7 @@ import type { ChannelAccountSnapshot, ChannelGatewayContext, OpenClawConfig, -} from "openclaw/plugin-sdk/test-utils"; +} from "openclaw/plugin-sdk/testing"; import { vi } from "vitest"; import { createRuntimeEnv } from "./runtime-env.js"; diff --git a/extensions/test-utils/start-account-lifecycle.ts b/test/helpers/extensions/start-account-lifecycle.ts similarity index 98% rename from extensions/test-utils/start-account-lifecycle.ts rename to test/helpers/extensions/start-account-lifecycle.ts index 6ce1c734736..ea76fe857d5 100644 --- a/extensions/test-utils/start-account-lifecycle.ts +++ b/test/helpers/extensions/start-account-lifecycle.ts @@ -1,4 +1,4 @@ -import type { ChannelAccountSnapshot, ChannelGatewayContext } from "openclaw/plugin-sdk/test-utils"; +import type { ChannelAccountSnapshot, ChannelGatewayContext } from "openclaw/plugin-sdk/testing"; import { expect, vi } from "vitest"; import { createStartAccountContext } from "./start-account-context.js"; diff --git a/extensions/test-utils/status-issues.ts b/test/helpers/extensions/status-issues.ts similarity index 100% rename from extensions/test-utils/status-issues.ts rename to test/helpers/extensions/status-issues.ts diff --git a/extensions/test-utils/subagent-hooks.ts b/test/helpers/extensions/subagent-hooks.ts similarity index 100% rename from extensions/test-utils/subagent-hooks.ts rename to test/helpers/extensions/subagent-hooks.ts diff --git a/test/helpers/extensions/temp-dir.ts b/test/helpers/extensions/temp-dir.ts new file mode 100644 index 00000000000..08ec26218ec --- /dev/null +++ b/test/helpers/extensions/temp-dir.ts @@ -0,0 +1 @@ +export { withTempDir } from "../../../src/test-utils/temp-dir.js"; diff --git a/test/helpers/extensions/typed-cases.ts b/test/helpers/extensions/typed-cases.ts new file mode 100644 index 00000000000..45be30b08c3 --- /dev/null +++ b/test/helpers/extensions/typed-cases.ts @@ -0,0 +1 @@ +export { typedCases } from "../../../src/test-utils/typed-cases.js";