Skip to content

Commit 71473e7

Browse files
committed
test: make telegram live mention scenario privacy-safe
1 parent 32c2337 commit 71473e7

2 files changed

Lines changed: 37 additions & 14 deletions

File tree

extensions/qa-lab/src/live-transports/telegram/telegram-live.runtime.test.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,16 @@ describe("telegram live qa runtime", () => {
311311
});
312312

313313
it("includes mention gating in the Telegram live scenario catalog", () => {
314-
expect(
315-
__testing
316-
.findScenario([
317-
"telegram-help-command",
318-
"telegram-commands-command",
319-
"telegram-tools-compact-command",
320-
"telegram-whoami-command",
321-
"telegram-context-command",
322-
"telegram-mentioned-message-reply",
323-
"telegram-mention-gating",
324-
])
325-
.map((scenario) => scenario.id),
326-
).toEqual([
314+
const scenarios = __testing.findScenario([
315+
"telegram-help-command",
316+
"telegram-commands-command",
317+
"telegram-tools-compact-command",
318+
"telegram-whoami-command",
319+
"telegram-context-command",
320+
"telegram-mentioned-message-reply",
321+
"telegram-mention-gating",
322+
]);
323+
expect(scenarios.map((scenario) => scenario.id)).toEqual([
327324
"telegram-help-command",
328325
"telegram-commands-command",
329326
"telegram-tools-compact-command",
@@ -332,6 +329,11 @@ describe("telegram live qa runtime", () => {
332329
"telegram-mentioned-message-reply",
333330
"telegram-mention-gating",
334331
]);
332+
expect(
333+
scenarios
334+
.find((scenario) => scenario.id === "telegram-mentioned-message-reply")
335+
?.buildRun("sut_bot").replyToLatestSutMessage,
336+
).toBe(true);
335337
});
336338

337339
it("tracks Telegram live coverage against the shared transport contract", () => {

extensions/qa-lab/src/live-transports/telegram/telegram-live.runtime.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type TelegramQaScenarioRun = {
5656
input: string;
5757
expectedTextIncludes?: string[];
5858
matchText?: string;
59+
replyToLatestSutMessage?: boolean;
5960
};
6061

6162
type TelegramQaScenarioDefinition = LiveTransportScenarioDefinition<TelegramQaScenarioId> & {
@@ -276,6 +277,7 @@ const TELEGRAM_QA_SCENARIOS: TelegramQaScenarioDefinition[] = [
276277
allowAnySutReply: true,
277278
expectReply: true,
278279
input: `@${sutUsername} Telegram QA mention routing check. Reply with a short acknowledgement.`,
280+
replyToLatestSutMessage: true,
279281
}),
280282
},
281283
{
@@ -613,11 +615,24 @@ async function flushTelegramUpdates(token: string) {
613615
throw new Error("timed out after 15000ms draining Telegram updates");
614616
}
615617

616-
async function sendGroupMessage(token: string, groupId: string, text: string) {
618+
async function sendGroupMessage(
619+
token: string,
620+
groupId: string,
621+
text: string,
622+
opts: { replyToMessageId?: number } = {},
623+
) {
617624
return await callTelegramApi<TelegramSendMessageResult>(token, "sendMessage", {
618625
chat_id: groupId,
619626
text,
620627
disable_notification: true,
628+
...(opts.replyToMessageId !== undefined
629+
? {
630+
reply_parameters: {
631+
message_id: opts.replyToMessageId,
632+
allow_sending_without_reply: true,
633+
},
634+
}
635+
: {}),
621636
});
622637
}
623638

@@ -1228,6 +1243,7 @@ export async function runTelegramQaLive(params: {
12281243
try {
12291244
await waitForTelegramChannelRunning(gatewayHarness.gateway, sutAccountId);
12301245
assertLeaseHealthy();
1246+
let latestSutMessageId: number | undefined;
12311247
try {
12321248
writeTelegramQaProgress(progressEnabled, "canary start");
12331249
const canaryTiming = await runCanary({
@@ -1238,6 +1254,7 @@ export async function runTelegramQaLive(params: {
12381254
timeoutMs: resolveTelegramQaCanaryTimeoutMs(),
12391255
observedMessages,
12401256
});
1257+
latestSutMessageId = canaryTiming.responseMessageId;
12411258
scenarioResults.push({
12421259
id: "telegram-canary",
12431260
title: "Telegram canary",
@@ -1291,6 +1308,9 @@ export async function runTelegramQaLive(params: {
12911308
runtimeEnv.driverToken,
12921309
runtimeEnv.groupId,
12931310
scenarioRun.input,
1311+
scenarioRun.replyToLatestSutMessage
1312+
? { replyToMessageId: latestSutMessageId }
1313+
: undefined,
12941314
);
12951315
const requestStartedAt = new Date(requestStartedAtMs).toISOString();
12961316
const matched = await waitForObservedMessage({
@@ -1333,6 +1353,7 @@ export async function runTelegramQaLive(params: {
13331353
responseMessageId: redactPublicMetadata ? undefined : matched.message.messageId,
13341354
} satisfies TelegramQaScenarioResult;
13351355
scenarioResults.push(result);
1356+
latestSutMessageId = matched.message.messageId;
13361357
writeTelegramQaProgress(
13371358
progressEnabled,
13381359
`scenario pass ${scenarioIndexLabel}: ${scenarioIdForLog}`,

0 commit comments

Comments
 (0)