Tests: fast-path Matrix ACP thread binding

This commit is contained in:
Gustavo Madeira Santana
2026-04-17 01:57:49 -04:00
parent 807c6648f9
commit 878f2122e5
8 changed files with 282 additions and 25 deletions

View File

@@ -0,0 +1,33 @@
import { describe, expect, it } from "vitest";
import {
defaultTopLevelPlacement,
resolveMatrixInboundConversation,
} from "./thread-binding-api.js";
describe("Matrix thread binding public API", () => {
it("advertises child placement for top-level Matrix rooms", () => {
expect(defaultTopLevelPlacement).toBe("child");
});
it("resolves top-level room targets as parent conversations", () => {
expect(resolveMatrixInboundConversation({ to: "channel:!room:example" })).toEqual({
conversationId: "!room:example",
});
});
it("preserves canonical room casing when resolving thread conversations", () => {
expect(
resolveMatrixInboundConversation({
to: "room:!Room:Example.org",
threadId: "$thread-root",
}),
).toEqual({
conversationId: "$thread-root",
parentConversationId: "!Room:Example.org",
});
});
it("does not resolve user targets as thread binding rooms", () => {
expect(resolveMatrixInboundConversation({ to: "user:@user:example.org" })).toBeNull();
});
});