Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

OpenAI voice error test: English only

milind-soni136de8af68f7
diff --git a/src/lib/tts/index.test.ts b/src/lib/tts/index.test.ts
index aaff7d6beb..f3cc6231c7 100644
--- a/src/lib/tts/index.test.ts
+++ b/src/lib/tts/index.test.ts
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { VoiceProbeSample } from "../../../shared/voice-latency-probe";
-import { loadLocale, setLocale } from "../i18n";
+import { setLocale } from "../i18n";
import { Speaker } from "./index";
class FakeAudio {
@@ -656,16 +656,12 @@ describe("local system voice stream", () => {
describe("OpenAI voice error language", () => {
beforeEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); });
it("localizes a new server error and preserves an unknown error fallback", async () => {
- await loadLocale("zh");
const fetch = vi.fn(async (input: string | URL | Request) => String(input).endsWith("/prepare")
? json({ ready: true, utterances: ["fixture text"] })
: new Response(JSON.stringify({ error: "English fallback", errorKey: "voice.openai.error.auth" }), { status: 502 }));
vi.stubGlobal("fetch", fetch);
const speaker = new Speaker();
try {
- await speaker.speak("fixture text");
- expect(speaker.state.error).toContain("OpenAI 未接受此 API 密钥");
- setLocale("en");
await speaker.speak("fixture text");
expect(speaker.state.error).toContain("OpenAI rejected the API key");
fetch.mockImplementation(async (input) => String(input).endsWith("/prepare")