mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-15 08:43:18 +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
|
|
@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
|
|||
import test from 'node:test';
|
||||
|
||||
import { QqHarnessBridge } from '../../../src/channels/qq/qq-bridge.mjs';
|
||||
import { connectionTestTarget } from '../../../src/channels/shared/connection-test.mjs';
|
||||
|
||||
function deferred() {
|
||||
let resolve;
|
||||
|
|
@ -258,6 +259,45 @@ test('QQ executes /compact for the bound Session without prompting the model', a
|
|||
assert.equal(fixture.seen.has('compact-qq'), true);
|
||||
});
|
||||
|
||||
test('QQ remembers a connection-test target only for an authorized private /status', async () => {
|
||||
const fixture = stateFixture();
|
||||
const sent = [];
|
||||
const bridge = new QqHarnessBridge({
|
||||
bot: { sendText: async (target, text) => sent.push({ target, text }) },
|
||||
ownerUserOpenid: 'owner-openid',
|
||||
harness: { ensureRunning: async () => true },
|
||||
state: fixture.state,
|
||||
});
|
||||
|
||||
await bridge.accept(message({
|
||||
messageId: 'status-rejected',
|
||||
senderId: 'other-openid',
|
||||
content: '/status',
|
||||
replyTarget: { scope: 'c2c', targetId: 'other-openid', msgId: 'status-rejected' },
|
||||
}));
|
||||
await bridge.accept(message({
|
||||
kind: 'group',
|
||||
rawEventType: 'GROUP_AT_MESSAGE_CREATE',
|
||||
groupOpenid: 'group-1',
|
||||
messageId: 'status-group',
|
||||
content: '/status',
|
||||
replyTarget: { scope: 'group', targetId: 'group-1', msgId: 'status-group' },
|
||||
}));
|
||||
assert.equal(connectionTestTarget(fixture.state), null);
|
||||
|
||||
const privateTarget = {
|
||||
scope: 'c2c', targetId: 'owner-openid', msgId: 'status-private',
|
||||
};
|
||||
await bridge.accept(message({
|
||||
messageId: 'status-private',
|
||||
content: '/status',
|
||||
replyTarget: privateTarget,
|
||||
}));
|
||||
|
||||
assert.deepEqual(connectionTestTarget(fixture.state), privateTarget);
|
||||
assert.equal(sent.filter(({ text }) => text.includes('连接正常')).length, 2);
|
||||
});
|
||||
|
||||
test('QQ private messages stream Harness snapshots and finalize once', async () => {
|
||||
const frames = [];
|
||||
const sent = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue