refactor(qa): share live scenario reply assertion · openclaw/openclaw@0479da9
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
File tree
extensions/qa-lab/src/live-transports
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,7 @@ import {
|
34 | 34 | redactQaLiveLaneIssues, |
35 | 35 | } from "../shared/live-artifacts.js"; |
36 | 36 | import { startQaLiveLaneGateway } from "../shared/live-gateway.runtime.js"; |
| 37 | +import { assertLiveScenarioReply as assertDiscordScenarioReply } from "../shared/live-scenario-reply.js"; |
37 | 38 | import { |
38 | 39 | collectLiveTransportStandardScenarioCoverage, |
39 | 40 | selectLiveTransportScenarios, |
@@ -1478,22 +1479,6 @@ function matchesDiscordScenarioReply(params: {
|
1478 | 1479 | ); |
1479 | 1480 | } |
1480 | 1481 | |
1481 | | -function assertDiscordScenarioReply(params: { |
1482 | | -expectedTextIncludes?: string[]; |
1483 | | -message: DiscordObservedMessage; |
1484 | | -}) { |
1485 | | -if (!params.message.text.trim()) { |
1486 | | -throw new Error(`reply message ${params.message.messageId} was empty`); |
1487 | | -} |
1488 | | -for (const expected of params.expectedTextIncludes ?? []) { |
1489 | | -if (!params.message.text.includes(expected)) { |
1490 | | -throw new Error( |
1491 | | -`reply message ${params.message.messageId} missing expected text: ${expected}`, |
1492 | | -); |
1493 | | -} |
1494 | | -} |
1495 | | -} |
1496 | | - |
1497 | 1482 | async function assertDiscordApplicationCommandsRegistered(params: { |
1498 | 1483 | applicationId: string; |
1499 | 1484 | expectedCommandNames: string[]; |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +type LiveScenarioReplyMessage = { |
| 2 | +messageId: string | number; |
| 3 | +text: string; |
| 4 | +[key: string]: unknown; |
| 5 | +}; |
| 6 | + |
| 7 | +export function assertLiveScenarioReply(params: { |
| 8 | +expectedTextIncludes?: string[]; |
| 9 | +message: LiveScenarioReplyMessage; |
| 10 | +}) { |
| 11 | +if (!params.message.text.trim()) { |
| 12 | +throw new Error(`reply message ${params.message.messageId} was empty`); |
| 13 | +} |
| 14 | +for (const expected of params.expectedTextIncludes ?? []) { |
| 15 | +if (!params.message.text.includes(expected)) { |
| 16 | +throw new Error( |
| 17 | +`reply message ${params.message.messageId} missing expected text: ${expected}`, |
| 18 | +); |
| 19 | +} |
| 20 | +} |
| 21 | +} |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -39,6 +39,7 @@ import {
|
39 | 39 | redactQaLiveLaneIssues, |
40 | 40 | } from "../shared/live-artifacts.js"; |
41 | 41 | import { startQaLiveLaneGateway } from "../shared/live-gateway.runtime.js"; |
| 42 | +import { assertLiveScenarioReply as assertTelegramScenarioReply } from "../shared/live-scenario-reply.js"; |
42 | 43 | import type { LiveTransportCheckResult } from "../shared/live-transport-result.js"; |
43 | 44 | import { |
44 | 45 | normalizeLiveTransportRttOptions, |
@@ -1442,22 +1443,6 @@ function matchesTelegramScenarioReply(params: {
|
1442 | 1443 | ); |
1443 | 1444 | } |
1444 | 1445 | |
1445 | | -function assertTelegramScenarioReply(params: { |
1446 | | -expectedTextIncludes?: string[]; |
1447 | | -message: TelegramObservedMessage; |
1448 | | -}) { |
1449 | | -if (!params.message.text.trim()) { |
1450 | | -throw new Error(`reply message ${params.message.messageId} was empty`); |
1451 | | -} |
1452 | | -for (const expected of params.expectedTextIncludes ?? []) { |
1453 | | -if (!params.message.text.includes(expected)) { |
1454 | | -throw new Error( |
1455 | | -`reply message ${params.message.messageId} missing expected text: ${expected}`, |
1456 | | -); |
1457 | | -} |
1458 | | -} |
1459 | | -} |
1460 | | - |
1461 | 1446 | function assertTelegramCanaryPresenceReply(message: TelegramObservedMessage) { |
1462 | 1447 | if (!message.senderIsBot) { |
1463 | 1448 | throw new Error(`canary reply message ${message.messageId} was not sent by a bot`); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。