mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 23:56:07 +00:00
test(ci): tolerate live STT brand drift
This commit is contained in:
@@ -7,7 +7,10 @@ import {
|
||||
registerProviderPlugin,
|
||||
requireRegisteredProvider,
|
||||
} from "openclaw/plugin-sdk/plugin-test-runtime";
|
||||
import { runRealtimeSttLiveTest } from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import {
|
||||
expectOpenClawLiveTranscriptMarker,
|
||||
runRealtimeSttLiveTest,
|
||||
} from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import plugin from "./index.js";
|
||||
@@ -68,10 +71,6 @@ const registerXaiPlugin = () =>
|
||||
name: "xAI Provider",
|
||||
});
|
||||
|
||||
function normalizeTranscriptForMatch(value: string): string {
|
||||
return value.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
||||
}
|
||||
|
||||
describeLive("xai plugin live", () => {
|
||||
it("synthesizes TTS through the registered speech provider", async () => {
|
||||
const { speechProviders } = await registerXaiPlugin();
|
||||
@@ -146,9 +145,8 @@ describeLive("xai plugin live", () => {
|
||||
});
|
||||
|
||||
const normalized = transcript?.text.toLowerCase() ?? "";
|
||||
const compact = normalizeTranscriptForMatch(normalized);
|
||||
expect(transcript?.model).toBe(XAI_DEFAULT_STT_MODEL);
|
||||
expect(compact).toContain("openclaw");
|
||||
expectOpenClawLiveTranscriptMarker(normalized);
|
||||
expect(normalized).toContain("speech");
|
||||
expect(normalized).toContain("text");
|
||||
expect(normalized).toContain("integration");
|
||||
@@ -222,8 +220,7 @@ describeLive("xai plugin live", () => {
|
||||
});
|
||||
|
||||
const normalized = transcripts.join(" ").toLowerCase();
|
||||
const compact = normalizeTranscriptForMatch(normalized);
|
||||
expect(compact).toContain("openclaw");
|
||||
expectOpenClawLiveTranscriptMarker(normalized);
|
||||
expect(normalized).toContain("transcription");
|
||||
expect(partials.length + transcripts.length).toBeGreaterThan(0);
|
||||
}, 180_000);
|
||||
|
||||
@@ -69,7 +69,9 @@ export {
|
||||
export { expectPassthroughReplayPolicy } from "./test-helpers/provider-replay-policy.js";
|
||||
export { createCapturedThinkingConfigStream } from "./test-helpers/stream-hooks.js";
|
||||
export {
|
||||
expectOpenClawLiveTranscriptMarker,
|
||||
normalizeTranscriptForMatch,
|
||||
OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE,
|
||||
runRealtimeSttLiveTest,
|
||||
streamAudioForLiveTest,
|
||||
synthesizeElevenLabsLiveSpeech,
|
||||
|
||||
@@ -14,7 +14,11 @@ export function normalizeTranscriptForMatch(value: string): string {
|
||||
|
||||
type ExpectedTranscriptMatch = RegExp | string;
|
||||
|
||||
const DEFAULT_OPENCLAW_TRANSCRIPT_MATCH = /open(?:claw|flaw|clar)/;
|
||||
export const OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE = /open(?:claw|flaw|clar|core)/;
|
||||
|
||||
export function expectOpenClawLiveTranscriptMarker(value: string): void {
|
||||
expect(normalizeTranscriptForMatch(value)).toMatch(OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE);
|
||||
}
|
||||
|
||||
export async function waitForLiveExpectation(expectation: () => void, timeoutMs = 30_000) {
|
||||
const started = Date.now();
|
||||
@@ -99,7 +103,7 @@ export async function runRealtimeSttLiveTest(params: {
|
||||
const transcripts: string[] = [];
|
||||
const partials: string[] = [];
|
||||
const errors: Error[] = [];
|
||||
const expected = params.expectedNormalizedText ?? DEFAULT_OPENCLAW_TRANSCRIPT_MATCH;
|
||||
const expected = params.expectedNormalizedText ?? OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE;
|
||||
const session = params.provider.createSession({
|
||||
providerConfig: params.providerConfig,
|
||||
onPartial: (partial) => partials.push(partial),
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { normalizeTranscriptForMatch } from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import {
|
||||
expectOpenClawLiveTranscriptMarker,
|
||||
normalizeTranscriptForMatch,
|
||||
OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE,
|
||||
} from "openclaw/plugin-sdk/provider-test-contracts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("normalizeTranscriptForMatch", () => {
|
||||
@@ -7,5 +11,9 @@ describe("normalizeTranscriptForMatch", () => {
|
||||
expect(normalizeTranscriptForMatch("Testing OpenFlaw realtime transcription")).toMatch(
|
||||
/open(?:claw|flaw)/,
|
||||
);
|
||||
expect(normalizeTranscriptForMatch("OpenCore xAI realtime transcription")).toMatch(
|
||||
OPENCLAW_LIVE_TRANSCRIPT_MARKER_RE,
|
||||
);
|
||||
expectOpenClawLiveTranscriptMarker("OpenClar integration OK");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user