36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
import test from "node:test"
|
|
import assert from "node:assert/strict"
|
|
|
|
import {
|
|
applyTelegramReplyEndStopPolicy,
|
|
buildTelegramReplyEndAck,
|
|
buildTelegramReplyEndButtonsForReply,
|
|
buildTelegramReplyEndButtonsForResolvedChoice,
|
|
} from "../src/runtime/openclaw-telegram-bridge.ts"
|
|
|
|
test("bridge exposes default buttons", () => {
|
|
const rows = buildTelegramReplyEndButtonsForReply()
|
|
assert.equal(rows[0][0].callback_data, "rec:continue")
|
|
assert.equal(rows[0][1].callback_data, "rec:stop")
|
|
})
|
|
|
|
test("bridge exposes resolved button state", () => {
|
|
const rows = buildTelegramReplyEndButtonsForResolvedChoice("stop")
|
|
assert.match(rows[0][1].text, /^⏹/)
|
|
})
|
|
|
|
test("bridge exposes ack text", () => {
|
|
assert.equal(buildTelegramReplyEndAck("continue"), "reply-end-controls: continue received")
|
|
})
|
|
|
|
test("bridge applies stop policy", () => {
|
|
const out = applyTelegramReplyEndStopPolicy("hello", {
|
|
lastChoice: "stop",
|
|
lastChoiceAt: "2026-05-13T00:00:00Z",
|
|
sourceMessageId: "1",
|
|
sourceCallbackId: "cb-1",
|
|
active: true,
|
|
})
|
|
assert.match(out, /reply-end-controls Stop/)
|
|
})
|