mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-29 17:50:53 +00:00
test: narrow hook and inbound context assertions
This commit is contained in:
@@ -78,8 +78,11 @@ describe("signal createSignalEventHandler inbound context", () => {
|
||||
);
|
||||
|
||||
expect(capture.ctx).toBeTruthy();
|
||||
expectInboundContextContract(capture.ctx!);
|
||||
const contextWithBody = capture.ctx!;
|
||||
const contextWithBody = capture.ctx;
|
||||
if (!contextWithBody) {
|
||||
throw new Error("expected inbound MsgContext");
|
||||
}
|
||||
expectInboundContextContract(contextWithBody);
|
||||
// Sender should appear as prefix in group messages (no redundant [from:] suffix)
|
||||
expect(String(contextWithBody.Body ?? "")).toContain("Alice");
|
||||
expect(String(contextWithBody.Body ?? "")).toMatch(/Alice.*:/);
|
||||
|
||||
@@ -33,7 +33,10 @@ const BASE_SLACK_SEND_CTX = {
|
||||
} as const;
|
||||
|
||||
const sendSlackText = async (ctx: SlackSendTextCtx) => {
|
||||
const sendText = slackOutbound.sendText as NonNullable<typeof slackOutbound.sendText>;
|
||||
const sendText = slackOutbound.sendText;
|
||||
if (!sendText) {
|
||||
throw new Error("slackOutbound.sendText is unavailable");
|
||||
}
|
||||
return await sendText({
|
||||
cfg: {} as OpenClawConfig,
|
||||
...ctx,
|
||||
@@ -147,7 +150,10 @@ describe("slack outbound hook wiring", () => {
|
||||
};
|
||||
getGlobalHookRunnerMock.mockReturnValue(mockRunner);
|
||||
|
||||
const sendText = slackOutbound.sendText as NonNullable<typeof slackOutbound.sendText>;
|
||||
const sendText = slackOutbound.sendText;
|
||||
if (!sendText) {
|
||||
throw new Error("slackOutbound.sendText is unavailable");
|
||||
}
|
||||
await sendText({
|
||||
cfg: {
|
||||
channels: {
|
||||
|
||||
@@ -47,7 +47,11 @@ describe("twitchMessageActions", () => {
|
||||
configured: true,
|
||||
availableAccountIds: ["default", "secondary"],
|
||||
}));
|
||||
vi.mocked(twitchOutbound.sendText!).mockResolvedValue({
|
||||
const sendText = twitchOutbound.sendText;
|
||||
if (!sendText) {
|
||||
throw new Error("twitchOutbound.sendText is unavailable");
|
||||
}
|
||||
vi.mocked(sendText).mockResolvedValue({
|
||||
channel: "twitch",
|
||||
messageId: "msg-1",
|
||||
timestamp: 1,
|
||||
|
||||
Reference in New Issue
Block a user