test(qa): relax telegram mention reply assertion

(cherry picked from commit 7109251318)
This commit is contained in:
Peter Steinberger
2026-04-26 22:43:54 +01:00
parent 17094640f8
commit e7d069edcf
2 changed files with 32 additions and 9 deletions

View File

@@ -376,6 +376,27 @@ describe("telegram live qa runtime", () => {
matchText: "TELEGRAM_QA_NOMENTION_TOKEN",
}),
).toBe(false);
expect(
__testing.matchesTelegramScenarioReply({
allowAnySutReply: true,
groupId: "-100123",
sentMessageId: 55,
sutBotId: 88,
message: {
updateId: 3,
messageId: 12,
chatId: -100123,
senderId: 88,
senderIsBot: true,
senderUsername: "sut_bot",
text: "Protocol note: acknowledged.",
replyToMessageId: undefined,
timestamp: 1_700_000_003_000,
inlineButtons: [],
mediaKinds: [],
},
}),
).toBe(true);
});
it("validates expected Telegram reply markers", () => {

View File

@@ -51,6 +51,7 @@ type TelegramQaScenarioId =
| "telegram-mention-gating";
type TelegramQaScenarioRun = {
allowAnySutReply?: boolean;
expectReply: boolean;
input: string;
expectedTextIncludes?: string[];
@@ -268,15 +269,11 @@ const TELEGRAM_QA_SCENARIOS: TelegramQaScenarioDefinition[] = [
id: "telegram-mentioned-message-reply",
title: "Telegram mentioned message gets a reply",
timeoutMs: 45_000,
buildRun: (sutUsername) => {
const token = `TELEGRAM_QA_REPLY_${randomUUID().slice(0, 8).toUpperCase()}`;
return {
expectReply: true,
input: `@${sutUsername} reply with only this exact marker: ${token}`,
expectedTextIncludes: [token],
matchText: token,
};
},
buildRun: (sutUsername) => ({
allowAnySutReply: true,
expectReply: true,
input: `@${sutUsername} Telegram QA mention routing check. Reply with a short acknowledgement.`,
}),
},
{
id: "telegram-mention-gating",
@@ -758,6 +755,7 @@ function findScenario(ids?: string[]) {
function matchesTelegramScenarioReply(params: {
groupId: string;
allowAnySutReply?: boolean;
matchText?: string;
message: TelegramObservedMessage;
sentMessageId: number;
@@ -772,6 +770,9 @@ function matchesTelegramScenarioReply(params: {
if (params.message.replyToMessageId === params.sentMessageId) {
return true;
}
if (params.allowAnySutReply === true) {
return true;
}
return Boolean(params.matchText && params.message.text.includes(params.matchText));
}
@@ -1223,6 +1224,7 @@ export async function runTelegramQaLive(params: {
observationScenarioTitle: scenario.title,
predicate: (message) =>
matchesTelegramScenarioReply({
allowAnySutReply: scenarioRun.allowAnySutReply,
groupId: runtimeEnv.groupId,
matchText: scenarioRun.matchText,
message,