mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:20:43 +00:00
test(qa): allow telegram scenario timeout override
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user