fix(weixin): align long-reply limits across runtime

This commit is contained in:
cuidong233 2026-08-24 19:29:02 +08:00
parent 868372fb04
commit 5e07137c44
7 changed files with 178 additions and 165 deletions

View file

@ -63,6 +63,8 @@ test('Weixin production has no per-bot result-file Gate', async (t) => {
assert.equal(Object.hasOwn(runtimes[0], 'outboundArtifactsEnabled'), false);
assert.equal(Object.hasOwn(runtimes[1], 'outboundArtifactsEnabled'), false);
assert.equal(runtimes[0].maxMessageChars, 1_800);
assert.equal(runtimes[1].maxMessageChars, 1_800);
await production.close();
const productionWithDefault = await createProductionController(ctx, { dataDir }, internals);
@ -72,5 +74,6 @@ test('Weixin production has no per-bot result-file Gate', async (t) => {
token: 'host-only',
});
assert.equal(Object.hasOwn(runtimes[2], 'outboundArtifactsEnabled'), false);
assert.equal(runtimes[2].maxMessageChars, 1_800);
await productionWithDefault.close();
});

View file

@ -85,6 +85,7 @@ test('runtime verifies the token, consumes getUpdates, replies, persists cursor,
const calls = [];
let pollCount = 0;
let askSignal;
const answer = '答'.repeat(2_000);
const stateData = { cursor: '', seen: new Set(), session: null };
const api = {
notifyStart: async (request) => calls.push(['start', request.token]),
@ -133,7 +134,7 @@ test('runtime verifies the token, consumes getUpdates, replies, persists cursor,
createSession: async () => 'session-1',
ask: async (_sessionId, _text, options) => {
askSignal = options.signal;
return '回答';
return answer;
},
},
state,
@ -145,10 +146,14 @@ test('runtime verifies the token, consumes getUpdates, replies, persists cursor,
await flush();
await flush();
assert.equal(stateData.cursor, 'cursor-next');
assert.deepEqual(calls.slice(0, 2), [
['start', 'bot-token'],
['send', '回答', 'context-7'],
assert.equal(calls[0][0], 'start');
assert.deepEqual(calls.slice(1, 3).map((call) => call[1].length), [1_800, 200]);
assert.equal(calls.slice(1, 3).map((call) => call[1]).join(''), answer);
assert.deepEqual(calls.slice(1, 3).map((call) => call[2]), [
'context-7',
'context-7',
]);
assert.equal(runtime.status.messagesReplied, 1);
assert.equal(askSignal.aborted, false);
await runtime.stop();
assert.equal(askSignal.aborted, true);