mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 01:40:21 +00:00
test(msteams): cover routing and setup
This commit is contained in:
69
extensions/msteams/src/session-route.test.ts
Normal file
69
extensions/msteams/src/session-route.test.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { resolveMSTeamsOutboundSessionRoute } from "./session-route.js";
|
||||
|
||||
describe("msteams session route", () => {
|
||||
it("builds direct routes for explicit user targets", () => {
|
||||
const route = resolveMSTeamsOutboundSessionRoute({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
accountId: "default",
|
||||
target: "msteams:user:alice-id",
|
||||
});
|
||||
|
||||
expect(route).toMatchObject({
|
||||
peer: {
|
||||
kind: "direct",
|
||||
id: "alice-id",
|
||||
},
|
||||
from: "msteams:alice-id",
|
||||
to: "user:alice-id",
|
||||
});
|
||||
});
|
||||
|
||||
it("builds channel routes for thread conversations and strips suffix metadata", () => {
|
||||
const route = resolveMSTeamsOutboundSessionRoute({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
accountId: "default",
|
||||
target: "teams:19:abc123@thread.tacv2;messageid=42",
|
||||
});
|
||||
|
||||
expect(route).toMatchObject({
|
||||
peer: {
|
||||
kind: "channel",
|
||||
id: "19:abc123@thread.tacv2",
|
||||
},
|
||||
from: "msteams:channel:19:abc123@thread.tacv2",
|
||||
to: "conversation:19:abc123@thread.tacv2",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns group routes for non-user, non-channel conversations", () => {
|
||||
const route = resolveMSTeamsOutboundSessionRoute({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
accountId: "default",
|
||||
target: "msteams:conversation:19:groupchat",
|
||||
});
|
||||
|
||||
expect(route).toMatchObject({
|
||||
peer: {
|
||||
kind: "group",
|
||||
id: "19:groupchat",
|
||||
},
|
||||
from: "msteams:group:19:groupchat",
|
||||
to: "conversation:19:groupchat",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns null when the target cannot be normalized", () => {
|
||||
expect(
|
||||
resolveMSTeamsOutboundSessionRoute({
|
||||
cfg: {},
|
||||
agentId: "main",
|
||||
accountId: "default",
|
||||
target: "msteams:",
|
||||
}),
|
||||
).toBeNull();
|
||||
});
|
||||
});
|
||||
34
extensions/msteams/src/setup-core.test.ts
Normal file
34
extensions/msteams/src/setup-core.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/setup";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { msteamsSetupAdapter } from "./setup-core.js";
|
||||
|
||||
describe("msteams setup core", () => {
|
||||
it("always resolves to the default account", () => {
|
||||
expect(msteamsSetupAdapter.resolveAccountId?.({ accountId: "work" } as never)).toBe(
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
);
|
||||
});
|
||||
|
||||
it("enables the msteams channel without dropping existing config", () => {
|
||||
expect(
|
||||
msteamsSetupAdapter.applyAccountConfig?.({
|
||||
cfg: {
|
||||
channels: {
|
||||
msteams: {
|
||||
appId: "existing-app",
|
||||
},
|
||||
},
|
||||
},
|
||||
accountId: DEFAULT_ACCOUNT_ID,
|
||||
input: {},
|
||||
} as never),
|
||||
).toEqual({
|
||||
channels: {
|
||||
msteams: {
|
||||
appId: "existing-app",
|
||||
enabled: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user