























@@ -428,16 +428,38 @@ async function waitForSlackNoReply(params: {
428428sutIdentity: SlackAuthIdentity;
429429timeoutMs: number;
430430}) {
431-try {
432-await waitForSlackScenarioReply(params);
433-} catch (error) {
434-const message = formatErrorMessage(error);
435-if (message === `timed out after ${params.timeoutMs}ms waiting for Slack message`) {
436-return;
431+const startedAt = Date.now();
432+while (Date.now() - startedAt < params.timeoutMs) {
433+const messages = await listSlackMessages({
434+channelId: params.channelId,
435+client: params.client,
436+oldestTs: params.sentTs,
437+});
438+for (const message of messages) {
439+const text = message.text ?? "";
440+if (
441+!message.ts ||
442+message.ts === params.sentTs ||
443+!isSutSlackMessage(message, params.sutIdentity)
444+) {
445+continue;
446+}
447+const matchedScenario = text.includes(params.matchText);
448+params.observedMessages.push({
449+botId: message.bot_id,
450+channelId: params.channelId,
451+ matchedScenario,
452+scenarioId: params.observationScenarioId,
453+scenarioTitle: params.observationScenarioTitle,
454+ text,
455+threadTs: message.thread_ts,
456+ts: message.ts,
457+userId: message.user,
458+});
459+throw new Error("unexpected Slack SUT reply observed");
437460}
438-throw error;
461+await new Promise((resolve) => setTimeout(resolve, 1_000));
439462}
440-throw new Error("unexpected Slack SUT reply observed");
441463}
442464443465async function waitForSlackChannelRunning(
@@ -816,4 +838,5 @@ export const __testing = {
816838 parseSlackQaCredentialPayload,
817839 resolveSlackQaRuntimeEnv,
818840SLACK_QA_STANDARD_SCENARIO_IDS,
841+ waitForSlackNoReply,
819842};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。