mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-25 03:45:46 -06:00
fix(qa): fence Telegram replies by send time
This commit is contained in:
@@ -944,6 +944,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -965,6 +966,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -986,6 +988,7 @@ describe("telegram live qa runtime", () => {
|
||||
expect(
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1008,6 +1011,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
allowAnySutReply: true,
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1029,6 +1033,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
allowAnySutReply: true,
|
||||
groupId: "-100123",
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
message: {
|
||||
@@ -1046,6 +1051,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", () => {
|
||||
@@ -1203,6 +1229,7 @@ describe("telegram live qa runtime", () => {
|
||||
testing.matchesTelegramScenarioReply({
|
||||
groupId: "-100123",
|
||||
message,
|
||||
sentAtMs: 1_700_000_000_000,
|
||||
sentMessageId: 55,
|
||||
sutBotId: 88,
|
||||
}),
|
||||
|
||||
@@ -232,6 +232,7 @@ type TelegramUpdate = {
|
||||
|
||||
type TelegramSendMessageResult = {
|
||||
message_id: number;
|
||||
date: number;
|
||||
chat: {
|
||||
id: number;
|
||||
};
|
||||
@@ -1395,12 +1396,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;
|
||||
}
|
||||
@@ -1495,6 +1498,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
groupId: params.groupId,
|
||||
matchText: params.step.matchText,
|
||||
message,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
sutBotId: params.sutBotId,
|
||||
}),
|
||||
@@ -1506,6 +1510,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
matched,
|
||||
requestStartedAt: new Date(requestStartedAtMs).toISOString(),
|
||||
requestStartedAtMs,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
};
|
||||
} catch (error) {
|
||||
@@ -1514,6 +1519,7 @@ async function runTelegramQaScenarioStep(params: {
|
||||
matched: undefined,
|
||||
requestStartedAt: new Date(requestStartedAtMs).toISOString(),
|
||||
requestStartedAtMs,
|
||||
sentAtMs: sent.date * 1000,
|
||||
sentMessageId: sent.message_id,
|
||||
};
|
||||
}
|
||||
@@ -2012,6 +2018,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