mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:40:44 +00:00
test(qa): relax telegram mention reply assertion
(cherry picked from commit 7109251318)
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user