test(qa): allow telegram scenario timeout override

This commit is contained in:
Ayaan Zaidi
2026-05-01 11:15:48 +05:30
parent 97d42a9614
commit 9e94a9e418
2 changed files with 27 additions and 2 deletions

View File

@@ -114,6 +114,20 @@ describe("telegram live qa runtime", () => {
).toBe(30_000);
});
it("normalizes the Telegram QA scenario timeout env", () => {
expect(__testing.resolveTelegramQaScenarioTimeoutMs(45_000, {})).toBe(45_000);
expect(
__testing.resolveTelegramQaScenarioTimeoutMs(45_000, {
OPENCLAW_QA_TELEGRAM_SCENARIO_TIMEOUT_MS: "180000",
}),
).toBe(180_000);
expect(
__testing.resolveTelegramQaScenarioTimeoutMs(45_000, {
OPENCLAW_QA_TELEGRAM_SCENARIO_TIMEOUT_MS: "nope",
}),
).toBe(45_000);
});
it("sanitizes and truncates Telegram live progress details", () => {
expect(__testing.sanitizeTelegramQaProgressValue("scenario\nid\tvalue")).toBe(
"scenario id value",

View File

@@ -376,6 +376,13 @@ function resolveTelegramQaCanaryTimeoutMs(env: NodeJS.ProcessEnv = process.env)
);
}
function resolveTelegramQaScenarioTimeoutMs(
fallbackMs: number,
env: NodeJS.ProcessEnv = process.env,
) {
return parsePositiveTelegramQaEnvMs(env, "OPENCLAW_QA_TELEGRAM_SCENARIO_TIMEOUT_MS", fallbackMs);
}
function formatTelegramQaTimeoutSeconds(timeoutMs: number) {
return `${Math.round(timeoutMs / 1_000)}s`;
}
@@ -1308,6 +1315,9 @@ export async function runTelegramQaLive(params: {
);
assertLeaseHealthy();
const scenarioRun = scenario.buildRun(sutUsername);
const scenarioTimeoutMs = scenarioRun.expectReply
? resolveTelegramQaScenarioTimeoutMs(scenario.timeoutMs)
: scenario.timeoutMs;
try {
const requestStartedAtMs = Date.now();
const sent = await sendGroupMessage(
@@ -1322,7 +1332,7 @@ export async function runTelegramQaLive(params: {
const matched = await waitForObservedMessage({
token: runtimeEnv.driverToken,
initialOffset: driverOffset,
timeoutMs: scenario.timeoutMs,
timeoutMs: scenarioTimeoutMs,
observedMessages,
observationScenarioId: scenario.id,
observationScenarioTitle: scenario.title,
@@ -1368,7 +1378,7 @@ export async function runTelegramQaLive(params: {
if (!scenarioRun.expectReply) {
const details = formatErrorMessage(error);
if (
details === `timed out after ${scenario.timeoutMs}ms waiting for Telegram message`
details === `timed out after ${scenarioTimeoutMs}ms waiting for Telegram message`
) {
const result = {
id: scenario.id,
@@ -1537,6 +1547,7 @@ export const __testing = {
parseTelegramQaProgressBooleanEnv,
parseTelegramQaCredentialPayload,
resolveTelegramQaCanaryTimeoutMs,
resolveTelegramQaScenarioTimeoutMs,
resolveTelegramQaRuntimeEnv,
sanitizeTelegramQaProgressValue,
shouldLogTelegramQaLiveProgress,