mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 11:25:50 -06:00
fix(qa): fence Telegram replies by send time
(cherry picked from commit ec36c3cbbf)
This commit is contained in:
@@ -1034,6 +1034,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1055,6 +1056,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1076,6 +1078,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1098,6 +1101,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
allowAnySutReply: true,
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1119,6 +1123,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
allowAnySutReply: true,
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1136,6 +1141,27 @@ describe("telegram live qa runtime", () => {
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
updateId: 6,
|
||||
messageId: 56,
|
||||
chatId: -100123,
|
||||
senderId: 88,
|
||||
senderIsBot: true,
|
||||
senderUsername: "sut_bot",
|
||||
text: "delayed reply from a previous run",
|
||||
replyToMessageId: 55,
|
||||
timestamp: 1_699_999_999_000,
|
||||
inlineButtons: [],
|
||||
mediaKinds: [],
|
||||
},
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("validates expected Telegram reply markers", () => {
|
||||
@@ -1296,6 +1322,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
message,
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
}),
|
||||
|
||||
@@ -249,6 +249,7 @@ type TelegramUpdate = {
|
||||
|
||||
type TelegramSendMessageResult = {
|
||||
message_id: number;
|
||||
date: number;
|
||||
chat: {
|
||||
id: number;
|
||||
};
|
||||
@@ -1423,12 +1424,14 @@ function matchesTelegramScenarioReply(params: {
|
||||
allowAnySutReply?: boolean;
|
||||
matchText?: string;
|
||||
message: TelegramObservedMessage;
|
||||
sentAtMs: number;
|
||||
sentMessageId: number;
|
||||
sutBotId: number;
|
||||
}) {
|
||||
if (
|
||||
params.message.chatId !== Number(params.groupId) ||
|
||||
params.message.senderId !== params.sutBotId
|
||||
params.message.senderId !== params.sutBotId ||
|
||||
params.message.timestamp < params.sentAtMs
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@@ -1507,6 +1510,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
groupId: params.groupId,
|
||||
matchText: params.step.matchText,
|
||||
message,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
sutBotId: params.sutBotId,
|
||||
}),
|
||||
@@ -1518,6 +1522,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
matched,
|
||||
requestStartedAt: new Date(requestStartedAtMs).toISOString(),
|
||||
requestStartedAtMs,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -1526,6 +1531,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
matched: undefined,
|
||||
requestStartedAt: new Date(requestStartedAtMs).toISOString(),
|
||||
requestStartedAtMs,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
};
|
||||
}
|
||||
@@ -2025,6 +2031,7 @@ export async function runTelegramQaLive(params: {
|
||||
groupId: runtimeEnv.groupId,
|
||||
matchText: step.matchText,
|
||||
message,
|
||||
sentAtMs: stepResult.sentAtMs,
|
||||
sentMessageId: stepResult.sentMessageId,
|
||||
sutBotId: sutIdentity.id,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user