test(openai): add focused realtime live smoke

This commit is contained in:
Vincent Koc 2026-07-06 22:19:34 -07:00 committed by Vincent Koc
parent f0564943a7
commit 6e6d1aac4c
3 changed files with 29 additions and 13 deletions

View file

@ -825,6 +825,7 @@ compatibility fallback when the shared
`OPENAI_API_KEY=... GEMINI_API_KEY=... node --import tsx scripts/dev/realtime-talk-live-smoke.ts`;
the OpenAI legs verify both the backend WebSocket bridge and the browser
WebRTC SDP exchange without logging secrets.
Pass `--openai-only` to run those two legs without Google credentials.
</Note>
</Accordion>

View file

@ -24,6 +24,7 @@ const GOOGLE_LIVE_WS_URL =
type RealtimeSmokeCliOptions = {
help: boolean;
openAIOnly: boolean;
};
// Keep live stacks behind their owning smoke paths so help and safety helpers stay lightweight.
@ -66,7 +67,8 @@ function usage(): string {
"Usage: node --import tsx scripts/dev/realtime-talk-live-smoke.ts [options]",
"",
"Options:",
" -h, --help Show this help",
" --openai-only Run only the OpenAI backend and browser legs",
" -h, --help Show this help",
"",
"Environment:",
" OPENAI_API_KEY",
@ -76,12 +78,15 @@ function usage(): string {
function parseRealtimeSmokeArgs(argv = process.argv.slice(2)): RealtimeSmokeCliOptions {
for (const arg of argv) {
if (arg === "--help" || arg === "-h") {
if (arg === "--help" || arg === "-h" || arg === "--openai-only") {
continue;
}
throw new CliArgumentError(`Unknown argument: ${arg}`);
}
return { help: argv.includes("--help") || argv.includes("-h") };
return {
help: argv.includes("--help") || argv.includes("-h"),
openAIOnly: argv.includes("--openai-only"),
};
}
function getEnv(name: string): string | undefined {
@ -799,16 +804,18 @@ async function main(argv = process.argv.slice(2)): Promise<void> {
results.push(await smokeOpenAIBackendBridge(openAIKey));
results.push(await smokeOpenAIWebRtc(browser, openAIKey));
}
if (!googleKey) {
results.push({
name: "google-live-browser-ws",
ok: false,
details: { error: "GEMINI_API_KEY or GOOGLE_API_KEY missing" },
});
} else {
results.push(await smokeGoogleLiveBrowserWs(browser, googleKey));
if (!cli.openAIOnly) {
if (!googleKey) {
results.push({
name: "google-live-browser-ws",
ok: false,
details: { error: "GEMINI_API_KEY or GOOGLE_API_KEY missing" },
});
} else {
results.push(await smokeGoogleLiveBrowserWs(browser, googleKey));
}
results.push(await smokeGatewayRelayBrowser(browser));
}
results.push(await smokeGatewayRelayBrowser(browser));
} finally {
await browser.close();
}

View file

@ -594,10 +594,18 @@ describe("script-specific dev tooling hardening", () => {
});
it("formats OpenAI realtime smoke help without launching live checks", () => {
expect(realtimeSmokeTesting.parseRealtimeSmokeArgs(["--help"])).toEqual({ help: true });
expect(realtimeSmokeTesting.parseRealtimeSmokeArgs(["--help"])).toEqual({
help: true,
openAIOnly: false,
});
expect(realtimeSmokeTesting.parseRealtimeSmokeArgs(["--openai-only"])).toEqual({
help: false,
openAIOnly: true,
});
expect(realtimeSmokeTesting.usage()).toContain(
"Usage: node --import tsx scripts/dev/realtime-talk-live-smoke.ts",
);
expect(realtimeSmokeTesting.usage()).toContain("--openai-only");
});
it("rejects unknown OpenAI realtime smoke args before runtime setup", () => {