test(plugins): route tts contract helper changes narrowly

This commit is contained in:
Peter Steinberger
2026-04-25 06:04:53 +01:00
parent b79272baad
commit a2a49b430c
5 changed files with 80 additions and 15 deletions

View File

@@ -1,6 +1,7 @@
import type { AssistantMessage } from "@mariozechner/pi-ai";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS } from "../../../src/plugins/contracts/inventory/bundled-capability-metadata.js";
import { createEmptyPluginRegistry } from "../../../src/plugins/registry-empty.js";
import { setActivePluginRegistry } from "../../../src/plugins/runtime.js";
import type { SpeechProviderPlugin } from "../../../src/plugins/types.js";
@@ -37,16 +38,12 @@ let formatTtsProviderError: TtsRuntimeModule["_test"]["formatTtsProviderError"];
let sanitizeTtsErrorForLog: TtsRuntimeModule["_test"]["sanitizeTtsErrorForLog"];
const SPEECH_PROVIDER_ENV_KEYS = [
"ELEVENLABS_API_KEY",
"GEMINI_API_KEY",
"GOOGLE_API_KEY",
"GRADIUM_API_KEY",
"MINIMAX_API_KEY",
"OPENAI_API_KEY",
"VYDRA_API_KEY",
"XAI_API_KEY",
"XI_API_KEY",
] as const;
...new Set(
BUNDLED_PLUGIN_CONTRACT_SNAPSHOTS.flatMap((entry) =>
entry.speechProviderIds.flatMap((providerId) => entry.providerAuthEnvVars[providerId] ?? []),
),
),
].toSorted((left, right) => left.localeCompare(right));
function isolatedSpeechProviderEnv(
overrides: Record<string, string | undefined> = {},

View File

@@ -137,6 +137,17 @@ describe("scripts/test-projects changed-target routing", () => {
).toBeNull();
});
it("routes precise plugin contract helpers without broad-running every shard", () => {
expect(
resolveChangedTargetArgs(["--changed", "origin/main"], process.cwd(), () => [
"test/helpers/plugins/tts-contract-suites.ts",
]),
).toEqual([
"src/plugins/contracts/core-extension-facade-boundary.test.ts",
"src/plugins/contracts/tts.contract.test.ts",
]);
});
it("keeps the broad changed run for unknown root surfaces", () => {
expect(
resolveChangedTargetArgs(["--changed", "origin/main"], process.cwd(), () => [