mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-02 09:01:33 +00:00
* fix(commands): validate native directives and preserve Telegram outcomes * test(commands): isolate native directive fast runtime --------- Co-authored-by: Peter Steinberger <steipete@macos.shared>
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
/** Verifies Telegram update outcomes stay attached to their durable ingress owner. */
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
ensureTelegramMessageProcessingResult,
|
|
recordTelegramMessageProcessingResult,
|
|
runWithTelegramUpdateProcessingFrame,
|
|
} from "./bot-processing-outcome.js";
|
|
|
|
describe("Telegram update processing outcomes", () => {
|
|
it("reuses the ingress outcome frame across nested bot middleware", async () => {
|
|
const outer = await runWithTelegramUpdateProcessingFrame(async () => {
|
|
const inner = await runWithTelegramUpdateProcessingFrame(async () => {
|
|
ensureTelegramMessageProcessingResult({ kind: "completed" });
|
|
return "middleware-finished";
|
|
});
|
|
|
|
expect(inner).toEqual({ value: "middleware-finished", result: { kind: "completed" } });
|
|
return "update-finished";
|
|
});
|
|
|
|
expect(outer).toEqual({ value: "update-finished", result: { kind: "completed" } });
|
|
});
|
|
|
|
it.each([
|
|
{ kind: "skipped" as const },
|
|
{ kind: "failed-retryable" as const, error: new Error("retry") },
|
|
])(
|
|
"does not replace an explicit $kind disposition with middleware completion",
|
|
async (expected) => {
|
|
const { result } = await runWithTelegramUpdateProcessingFrame(async () => {
|
|
recordTelegramMessageProcessingResult(expected);
|
|
ensureTelegramMessageProcessingResult({ kind: "completed" });
|
|
});
|
|
|
|
expect(result).toBe(expected);
|
|
},
|
|
);
|
|
|
|
it("keeps deferred owners outcome-free until their participant settles", async () => {
|
|
const { result } = await runWithTelegramUpdateProcessingFrame(async () => {
|
|
await runWithTelegramUpdateProcessingFrame(async () => {});
|
|
});
|
|
|
|
expect(result).toBeUndefined();
|
|
});
|
|
});
|