test: tighten channel extension assertions

This commit is contained in:
Peter Steinberger
2026-05-11 14:13:43 +01:00
parent 31f128e86f
commit 6781957a99
5 changed files with 38 additions and 51 deletions

View File

@@ -119,12 +119,11 @@ describe("feishu setup wizard", () => {
expect(initAppRegistrationMock).not.toHaveBeenCalled();
expect(beginAppRegistrationMock).not.toHaveBeenCalled();
expect(result.cfg.channels?.feishu).toMatchObject({
appId: "cli_manual",
appSecret: "secret_manual",
connectionMode: "websocket",
domain: "feishu",
});
const feishuConfig = result.cfg.channels?.feishu;
expect(feishuConfig?.appId).toBe("cli_manual");
expect(feishuConfig?.appSecret).toBe("secret_manual");
expect(feishuConfig?.connectionMode).toBe("websocket");
expect(feishuConfig?.domain).toBe("feishu");
});
it("passes selected domain through scan-to-create and poll", async () => {
@@ -162,20 +161,16 @@ describe("feishu setup wizard", () => {
expect(initAppRegistrationMock).toHaveBeenCalledWith("lark");
expect(beginAppRegistrationMock).toHaveBeenCalledWith("lark");
expect(pollAppRegistrationMock).toHaveBeenCalledWith(
expect.objectContaining({
deviceCode: "device-code",
initialDomain: "lark",
tp: "ob_cli_app",
}),
);
expect(result.cfg.channels?.feishu).toMatchObject({
appId: "cli_lark",
appSecret: "secret_lark",
domain: "lark",
groupPolicy: "open",
requireMention: true,
});
const [pollOptions] = pollAppRegistrationMock.mock.calls[0] ?? [];
expect(pollOptions?.deviceCode).toBe("device-code");
expect(pollOptions?.initialDomain).toBe("lark");
expect(pollOptions?.tp).toBe("ob_cli_app");
const feishuConfig = result.cfg.channels?.feishu;
expect(feishuConfig?.appId).toBe("cli_lark");
expect(feishuConfig?.appSecret).toBe("secret_lark");
expect(feishuConfig?.domain).toBe("lark");
expect(feishuConfig?.groupPolicy).toBe("open");
expect(feishuConfig?.requireMention).toBe(true);
});
it("falls back to manual credentials when selected scan-to-create is unavailable", async () => {
@@ -201,11 +196,10 @@ describe("feishu setup wizard", () => {
expect(initAppRegistrationMock).toHaveBeenCalledWith("feishu");
expect(beginAppRegistrationMock).not.toHaveBeenCalled();
expect(result.cfg.channels?.feishu).toMatchObject({
appId: "cli_from_fallback",
appSecret: "secret_from_fallback",
domain: "feishu",
});
const feishuConfig = result.cfg.channels?.feishu;
expect(feishuConfig?.appId).toBe("cli_from_fallback");
expect(feishuConfig?.appSecret).toBe("secret_from_fallback");
expect(feishuConfig?.domain).toBe("feishu");
});
it("prompts over SecretRef appId/appSecret config objects", async () => {

View File

@@ -873,11 +873,10 @@ describe("handleLineWebhookEvents", () => {
expect(processMessage).not.toHaveBeenCalled();
const entries = groupHistories.get("group-hist-1");
expect(entries).toHaveLength(1);
expect(entries?.[0]).toMatchObject({
sender: "user:user-hist",
body: "hello history",
timestamp: 1700000000000,
});
const entry = entries?.[0];
expect(entry?.sender).toBe("user:user-hist");
expect(entry?.body).toBe("hello history");
expect(entry?.timestamp).toBe(1700000000000);
});
it("skips group messages without mention when requireMention is set", async () => {

View File

@@ -414,13 +414,12 @@ describe("mattermost inbound user posts", () => {
expect(mockState.enqueueSystemEvent).not.toHaveBeenCalled();
expect(mockState.dispatchReplyFromConfig).toHaveBeenCalledTimes(1);
expect(mockState.dispatchReplyFromConfig.mock.calls[0]?.[0].ctx).toMatchObject({
BodyForAgent: "hello from mattermost",
ConversationLabel: "Town Square id:chan-1",
MessageSid: "post-1",
OriginatingChannel: "mattermost",
Provider: "mattermost",
});
const ctx = mockState.dispatchReplyFromConfig.mock.calls[0]?.[0].ctx;
expect(ctx?.BodyForAgent).toBe("hello from mattermost");
expect(ctx?.ConversationLabel).toBe("Town Square id:chan-1");
expect(ctx?.MessageSid).toBe("post-1");
expect(ctx?.OriginatingChannel).toBe("mattermost");
expect(ctx?.Provider).toBe("mattermost");
});
it("pins direct-message main route updates to the configured owner", async () => {

View File

@@ -163,12 +163,11 @@ describe("nostr inbound gateway path", () => {
expect(harness.recordInboundSession).toHaveBeenCalledTimes(1);
expect(harness.dispatchReplyWithBufferedBlockDispatcher).toHaveBeenCalledTimes(1);
expect(harness.dispatchReplyWithBufferedBlockDispatcher.mock.calls[0]?.[0]?.ctx).toMatchObject({
BodyForAgent: "hello from nostr",
SenderId: "sender-pubkey",
MessageSid: "event-123",
CommandAuthorized: true,
});
const ctx = harness.dispatchReplyWithBufferedBlockDispatcher.mock.calls[0]?.[0]?.ctx;
expect(ctx?.BodyForAgent).toBe("hello from nostr");
expect(ctx?.SenderId).toBe("sender-pubkey");
expect(ctx?.MessageSid).toBe("event-123");
expect(ctx?.CommandAuthorized).toBe(true);
expect(sendReply).toHaveBeenCalledWith("converted:|a|b|");
cleanup.stop();

View File

@@ -203,14 +203,10 @@ describe("validateProfile", () => {
const result = validateProfile(profile);
expect(result).toMatchObject({
valid: true,
profile: {
name: "validuser",
about: "A valid user",
picture: "https://example.com/pic.png",
},
});
expect(result.valid).toBe(true);
expect(result.profile?.name).toBe("validuser");
expect(result.profile?.about).toBe("A valid user");
expect(result.profile?.picture).toBe("https://example.com/pic.png");
expect(result).not.toHaveProperty("errors");
});