mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-18 18:40:48 +08:00
fix: support Harness interactions across IM channels
This commit is contained in:
parent
3e7e1dcdd7
commit
cd8175d341
30 changed files with 5433 additions and 555 deletions
|
|
@ -1,7 +1,49 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { DiscordHarnessClient } from '../../../src/channels/discord/harness-client.mjs';
|
||||
import { QqHarnessClient } from '../../../src/channels/qq/harness-client.mjs';
|
||||
import { SlackHarnessClient } from '../../../src/channels/slack/harness-client.mjs';
|
||||
import { TelegramHarnessClient } from '../../../src/channels/telegram/harness-client.mjs';
|
||||
import { WecomHarnessClient } from '../../../src/channels/wecom/harness-client.mjs';
|
||||
import { HarnessClient, HarnessReplyTracker } from '../../../src/channels/weixin/harness-client.mjs';
|
||||
import { WhatsappHarnessClient } from '../../../src/channels/whatsapp/harness-client.mjs';
|
||||
|
||||
test('all legacy channel clients now use the shared Harness RPC transport', async () => {
|
||||
const channelClients = [
|
||||
[HarnessClient, 'weixin'],
|
||||
[WecomHarnessClient, 'wecom'],
|
||||
[QqHarnessClient, 'qq'],
|
||||
[SlackHarnessClient, 'slack'],
|
||||
[DiscordHarnessClient, 'discord'],
|
||||
[TelegramHarnessClient, 'telegram'],
|
||||
[WhatsappHarnessClient, 'whatsapp'],
|
||||
];
|
||||
|
||||
for (const [Client, prefix] of channelClients) {
|
||||
let request;
|
||||
const client = new Client({
|
||||
baseUrl: 'http://127.0.0.1:3080',
|
||||
workspace: '/tmp/default-workspace',
|
||||
fetchImpl: async (url, options) => {
|
||||
request = { url: String(url), ...options, body: JSON.parse(options.body) };
|
||||
return {
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
type: 'server-response',
|
||||
rpcId: request.body.rpcId,
|
||||
result: { ok: true, value: { ready: true } },
|
||||
}),
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
assert.deepEqual(await client.rpc('host.describe'), { ready: true });
|
||||
assert.equal(request.url, 'http://127.0.0.1:3080/api/host.describe');
|
||||
assert.match(request.body.rpcId, new RegExp(`^${prefix}-`));
|
||||
assert.equal(request.body.type, 'client-request');
|
||||
}
|
||||
});
|
||||
|
||||
test('HarnessClient lists only absolute workspace paths', async () => {
|
||||
const client = new HarnessClient({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue