mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
fix: support legacy and current DSH hosts
This commit is contained in:
parent
72ffd7115c
commit
6b9118fe95
20 changed files with 1279 additions and 259 deletions
|
|
@ -38,7 +38,6 @@ test('Host composes nine IM channels and the AI Office connector inside one plug
|
|||
assert.deepEqual(inject, [
|
||||
'connection',
|
||||
'credentials',
|
||||
'apiProxy',
|
||||
'typertGateway',
|
||||
]);
|
||||
assert.deepEqual(calls, [
|
||||
|
|
@ -55,6 +54,36 @@ test('Host composes nine IM channels and the AI Office connector inside one plug
|
|||
]);
|
||||
});
|
||||
|
||||
test('Host waits for apiProxy on legacy Harness and Controllers on modern Harness', async () => {
|
||||
for (const [modern, expected] of [
|
||||
[false, ['apiProxy']],
|
||||
[true, ['sessionController', 'workspaceController']],
|
||||
]) {
|
||||
const injections = [];
|
||||
const calls = [];
|
||||
const plugin = createImHostPlugin(Object.fromEntries(CHANNELS.map(([channel, applyName]) => [
|
||||
applyName,
|
||||
async () => calls.push(channel),
|
||||
])));
|
||||
const ctx = {
|
||||
credentials: {},
|
||||
typertGateway: modern ? { stream() {} } : { invoke() {} },
|
||||
inject(dependencies, callback) {
|
||||
injections.push(dependencies);
|
||||
if (dependencies.includes('tools')) return {};
|
||||
return {
|
||||
then(resolve, reject) {
|
||||
Promise.resolve(callback(ctx)).then(resolve, reject);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
await plugin.apply(ctx, {});
|
||||
assert.deepEqual(injections[0], expected);
|
||||
assert.deepEqual(calls, CHANNELS.map(([channel]) => channel));
|
||||
}
|
||||
});
|
||||
|
||||
const CHANNELS = [
|
||||
['feishu', 'applyFeishu'],
|
||||
['weixin', 'applyWeixin'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue