mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-11 00:32:43 +08:00
feat: send test messages during bot connection checks
This commit is contained in:
parent
94da24538f
commit
fb61c4235f
78 changed files with 3460 additions and 210 deletions
|
|
@ -4,9 +4,20 @@ import { FeishuRuntime } from '../../../src/channels/feishu/feishu-runtime.mjs';
|
|||
|
||||
class FakeClient {
|
||||
static instances = [];
|
||||
static sent = [];
|
||||
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
this.im = {
|
||||
v1: {
|
||||
message: {
|
||||
create: async (payload) => {
|
||||
FakeClient.sent.push(payload);
|
||||
return { code: 0, data: { message_id: `message-${FakeClient.sent.length}` } };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
FakeClient.instances.push(this);
|
||||
}
|
||||
}
|
||||
|
|
@ -48,6 +59,7 @@ class FakeWSClient {
|
|||
function fakeLark() {
|
||||
FakeWSClient.instances.length = 0;
|
||||
FakeClient.instances.length = 0;
|
||||
FakeClient.sent.length = 0;
|
||||
return {
|
||||
Domain: { Feishu: 'feishu-domain', Lark: 'lark-domain' },
|
||||
LoggerLevel: { info: 'info' },
|
||||
|
|
@ -104,6 +116,16 @@ test('FeishuRuntime becomes chat-ready only after Harness and Feishu are connect
|
|||
url: 'https://open.feishu.cn/test',
|
||||
})).timeout, 15_000);
|
||||
|
||||
assert.deepEqual(await runtime.sendConnectionTest('连接测试'), { sent: true });
|
||||
assert.deepEqual(FakeClient.sent, [{
|
||||
params: { receive_id_type: 'open_id' },
|
||||
data: {
|
||||
receive_id: 'ou_owner',
|
||||
msg_type: 'text',
|
||||
content: JSON.stringify({ text: '连接测试' }),
|
||||
},
|
||||
}]);
|
||||
|
||||
const stopped = await runtime.stop();
|
||||
assert.equal(stopped.ready, false);
|
||||
assert.equal(stopped.feishuLongConnectionState, 'idle');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue