test: tighten regression assertions across extension tests

This commit is contained in:
Peter Steinberger
2026-03-22 07:46:07 +00:00
parent 4becbc8b25
commit 2d492ab534
11 changed files with 195 additions and 78 deletions

View File

@@ -1,6 +1,22 @@
import { describe, expect, it, vi } from "vitest";
import { imessagePlugin } from "./channel.js";
function requireIMessageSendText() {
const sendText = imessagePlugin.outbound?.sendText;
if (!sendText) {
throw new Error("imessage outbound.sendText unavailable");
}
return sendText;
}
function requireIMessageSendMedia() {
const sendMedia = imessagePlugin.outbound?.sendMedia;
if (!sendMedia) {
throw new Error("imessage outbound.sendMedia unavailable");
}
return sendMedia;
}
describe("imessagePlugin outbound", () => {
const cfg = {
channels: {
@@ -12,10 +28,9 @@ describe("imessagePlugin outbound", () => {
it("forwards replyToId on direct sendText adapter path", async () => {
const sendIMessage = vi.fn().mockResolvedValue({ messageId: "m-text" });
const sendText = imessagePlugin.outbound?.sendText;
expect(sendText).toBeDefined();
const sendText = requireIMessageSendText();
const result = await sendText!({
const result = await sendText({
cfg,
to: "chat_id:12",
text: "hello",
@@ -38,10 +53,9 @@ describe("imessagePlugin outbound", () => {
it("forwards replyToId on direct sendMedia adapter path", async () => {
const sendIMessage = vi.fn().mockResolvedValue({ messageId: "m-media" });
const sendMedia = imessagePlugin.outbound?.sendMedia;
expect(sendMedia).toBeDefined();
const sendMedia = requireIMessageSendMedia();
const result = await sendMedia!({
const result = await sendMedia({
cfg,
to: "chat_id:77",
text: "caption",
@@ -66,11 +80,10 @@ describe("imessagePlugin outbound", () => {
it("forwards mediaLocalRoots on direct sendMedia adapter path", async () => {
const sendIMessage = vi.fn().mockResolvedValue({ messageId: "m-media-local" });
const sendMedia = imessagePlugin.outbound?.sendMedia;
expect(sendMedia).toBeDefined();
const sendMedia = requireIMessageSendMedia();
const mediaLocalRoots = ["/tmp/workspace"];
const result = await sendMedia!({
const result = await sendMedia({
cfg,
to: "chat_id:88",
text: "caption",