mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor(qa): share live scenario reply assertion
This commit is contained in:
@@ -34,6 +34,7 @@ import {
|
||||
redactQaLiveLaneIssues,
|
||||
} from "../shared/live-artifacts.js";
|
||||
import { startQaLiveLaneGateway } from "../shared/live-gateway.runtime.js";
|
||||
import { assertLiveScenarioReply as assertDiscordScenarioReply } from "../shared/live-scenario-reply.js";
|
||||
import {
|
||||
collectLiveTransportStandardScenarioCoverage,
|
||||
selectLiveTransportScenarios,
|
||||
@@ -1478,22 +1479,6 @@ function matchesDiscordScenarioReply(params: {
|
||||
);
|
||||
}
|
||||
|
||||
function assertDiscordScenarioReply(params: {
|
||||
expectedTextIncludes?: string[];
|
||||
message: DiscordObservedMessage;
|
||||
}) {
|
||||
if (!params.message.text.trim()) {
|
||||
throw new Error(`reply message ${params.message.messageId} was empty`);
|
||||
}
|
||||
for (const expected of params.expectedTextIncludes ?? []) {
|
||||
if (!params.message.text.includes(expected)) {
|
||||
throw new Error(
|
||||
`reply message ${params.message.messageId} missing expected text: ${expected}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function assertDiscordApplicationCommandsRegistered(params: {
|
||||
applicationId: string;
|
||||
expectedCommandNames: string[];
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
type LiveScenarioReplyMessage = {
|
||||
messageId: string | number;
|
||||
text: string;
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
||||
export function assertLiveScenarioReply(params: {
|
||||
expectedTextIncludes?: string[];
|
||||
message: LiveScenarioReplyMessage;
|
||||
}) {
|
||||
if (!params.message.text.trim()) {
|
||||
throw new Error(`reply message ${params.message.messageId} was empty`);
|
||||
}
|
||||
for (const expected of params.expectedTextIncludes ?? []) {
|
||||
if (!params.message.text.includes(expected)) {
|
||||
throw new Error(
|
||||
`reply message ${params.message.messageId} missing expected text: ${expected}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
redactQaLiveLaneIssues,
|
||||
} from "../shared/live-artifacts.js";
|
||||
import { startQaLiveLaneGateway } from "../shared/live-gateway.runtime.js";
|
||||
import { assertLiveScenarioReply as assertTelegramScenarioReply } from "../shared/live-scenario-reply.js";
|
||||
import type { LiveTransportCheckResult } from "../shared/live-transport-result.js";
|
||||
import {
|
||||
normalizeLiveTransportRttOptions,
|
||||
@@ -1442,22 +1443,6 @@ function matchesTelegramScenarioReply(params: {
|
||||
);
|
||||
}
|
||||
|
||||
function assertTelegramScenarioReply(params: {
|
||||
expectedTextIncludes?: string[];
|
||||
message: TelegramObservedMessage;
|
||||
}) {
|
||||
if (!params.message.text.trim()) {
|
||||
throw new Error(`reply message ${params.message.messageId} was empty`);
|
||||
}
|
||||
for (const expected of params.expectedTextIncludes ?? []) {
|
||||
if (!params.message.text.includes(expected)) {
|
||||
throw new Error(
|
||||
`reply message ${params.message.messageId} missing expected text: ${expected}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function assertTelegramCanaryPresenceReply(message: TelegramObservedMessage) {
|
||||
if (!message.senderIsBot) {
|
||||
throw new Error(`canary reply message ${message.messageId} was not sent by a bot`);
|
||||
|
||||
Reference in New Issue
Block a user