From ee74d7b8dc410d97683cacd355df2d904b4571e9 Mon Sep 17 00:00:00 2001 From: xingzhou Date: Mon, 20 Jul 2026 23:39:27 +0800 Subject: [PATCH] fix(teams-meetings): expose listening probe timeout (#111486) --- extensions/teams-meetings/src/cli.test.ts | 54 +++++++++++++++++++++++ extensions/teams-meetings/src/cli.ts | 8 ++-- 2 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 extensions/teams-meetings/src/cli.test.ts diff --git a/extensions/teams-meetings/src/cli.test.ts b/extensions/teams-meetings/src/cli.test.ts new file mode 100644 index 00000000000..115df85290a --- /dev/null +++ b/extensions/teams-meetings/src/cli.test.ts @@ -0,0 +1,54 @@ +import { Command } from "commander"; +import { afterEach, describe, expect, it, vi } from "vitest"; + +const callGatewayFromCliMock = vi.hoisted(() => vi.fn()); + +vi.mock("openclaw/plugin-sdk/gateway-runtime", async (importOriginal) => ({ + ...(await importOriginal()), + callGatewayFromCli: callGatewayFromCliMock, +})); + +import { registerTeamsMeetingsCli } from "./cli.js"; +import { resolveTeamsMeetingsConfig } from "./config.js"; + +const MEETING_URL = + "https://teams.microsoft.com/l/meetup-join/19%3ameeting_cli_probe%40thread.v2/0"; + +afterEach(() => { + callGatewayFromCliMock.mockReset(); + vi.restoreAllMocks(); +}); + +function createProgram(): Command { + const program = new Command(); + registerTeamsMeetingsCli({ program, config: resolveTeamsMeetingsConfig({}) }); + return program; +} + +describe("Microsoft Teams meetings CLI", () => { + it("exposes the same bounded timeout on both live probes", () => { + const root = createProgram().commands.find((command) => command.name() === "teamsmeetings"); + + for (const name of ["test-speech", "test-listen"]) { + const probe = root?.commands.find((command) => command.name() === name); + expect(probe?.options.map((option) => option.long)).toContain("--timeout-ms"); + } + }); + + it("forwards the listening probe timeout to the gateway operation", async () => { + callGatewayFromCliMock.mockResolvedValue({ ok: true }); + vi.spyOn(process.stdout, "write").mockImplementation(() => true); + + await createProgram().parseAsync( + ["teamsmeetings", "test-listen", MEETING_URL, "--timeout-ms", "90000"], + { from: "user" }, + ); + + expect(callGatewayFromCliMock).toHaveBeenCalledWith( + "teamsmeetings.testListen", + { json: true, timeout: "120000" }, + { url: MEETING_URL, timeoutMs: 90_000 }, + { progress: false, scopes: ["operator.admin"] }, + ); + }); +}); diff --git a/extensions/teams-meetings/src/cli.ts b/extensions/teams-meetings/src/cli.ts index 4339f31999a..b53b2e13a6f 100644 --- a/extensions/teams-meetings/src/cli.ts +++ b/extensions/teams-meetings/src/cli.ts @@ -158,10 +158,8 @@ export function registerTeamsMeetingsCli(params: { ], ] as const) { const command = root.command(`${name} `).description(description); - (name === "test-speech" ? addProbeOptions(command) : addJoinOptions(command)).action( - async (url: string, options: JoinOptions) => { - await call({ config: params.config, method, payload: joinPayload(url, options) }); - }, - ); + addProbeOptions(command).action(async (url: string, options: JoinOptions) => { + await call({ config: params.config, method, payload: joinPayload(url, options) }); + }); } }