Add WeCom QR bot channel

This commit is contained in:
xmanrui 2026-08-15 20:53:35 +08:00
parent 601271a7f8
commit 4874d3e354
33 changed files with 5200 additions and 440 deletions

View file

@ -3,12 +3,13 @@ import test from 'node:test';
import { createImHostPlugin, inject, name } from '../plugin-src/host/index.mjs';
test('Host composes Feishu, Weixin, DingTalk, and QQ inside one plugin context', async () => {
test('Host composes Feishu, Weixin, DingTalk, Enterprise WeChat, and QQ inside one plugin context', async () => {
const calls = [];
const plugin = createImHostPlugin({
applyFeishu: async (ctx, config) => calls.push(['feishu', ctx, config]),
applyWeixin: async (ctx, config) => calls.push(['weixin', ctx, config]),
applyDingtalk: async (ctx, config) => calls.push(['dingtalk', ctx, config]),
applyWecom: async (ctx, config) => calls.push(['wecom', ctx, config]),
applyQq: async (ctx, config) => calls.push(['qq', ctx, config]),
});
const ctx = { marker: 'shared-context' };
@ -16,6 +17,7 @@ test('Host composes Feishu, Weixin, DingTalk, and QQ inside one plugin context',
feishu: { domain: 'feishu' },
weixin: { timeout: 30 },
dingtalk: { replyTimeoutMs: 60_000 },
wecom: { replyTimeoutMs: 60_000 },
qq: { replyTimeoutMs: 60_000 },
};
@ -27,6 +29,7 @@ test('Host composes Feishu, Weixin, DingTalk, and QQ inside one plugin context',
['feishu', ctx, config.feishu],
['weixin', ctx, config.weixin],
['dingtalk', ctx, config.dingtalk],
['wecom', ctx, config.wecom],
['qq', ctx, config.qq],
]);
});
@ -37,6 +40,7 @@ test('Host does not start Weixin when Feishu activation fails', async () => {
applyFeishu: async () => { throw new Error('feishu unavailable'); },
applyWeixin: async () => { weixinStarted = true; },
applyDingtalk: async () => { throw new Error('DingTalk must not start'); },
applyWecom: async () => { throw new Error('Enterprise WeChat must not start'); },
applyQq: async () => { throw new Error('QQ must not start'); },
});
@ -50,6 +54,7 @@ test('Host does not start DingTalk when Weixin activation fails', async () => {
applyFeishu: async () => {},
applyWeixin: async () => { throw new Error('weixin unavailable'); },
applyDingtalk: async () => { dingtalkStarted = true; },
applyWecom: async () => { throw new Error('Enterprise WeChat must not start'); },
applyQq: async () => { throw new Error('QQ must not start'); },
});
@ -57,15 +62,30 @@ test('Host does not start DingTalk when Weixin activation fails', async () => {
assert.equal(dingtalkStarted, false);
});
test('Host does not start QQ when DingTalk activation fails', async () => {
let qqStarted = false;
test('Host does not start Enterprise WeChat when DingTalk activation fails', async () => {
let wecomStarted = false;
const plugin = createImHostPlugin({
applyFeishu: async () => {},
applyWeixin: async () => {},
applyDingtalk: async () => { throw new Error('dingtalk unavailable'); },
applyQq: async () => { qqStarted = true; },
applyWecom: async () => { wecomStarted = true; },
applyQq: async () => { throw new Error('QQ must not start'); },
});
await assert.rejects(() => plugin.apply({}, {}), /dingtalk unavailable/);
assert.equal(wecomStarted, false);
});
test('Host does not start QQ when Enterprise WeChat activation fails', async () => {
let qqStarted = false;
const plugin = createImHostPlugin({
applyFeishu: async () => {},
applyWeixin: async () => {},
applyDingtalk: async () => {},
applyWecom: async () => { throw new Error('wecom unavailable'); },
applyQq: async () => { qqStarted = true; },
});
await assert.rejects(() => plugin.apply({}, {}), /wecom unavailable/);
assert.equal(qqStarted, false);
});