mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-10 02:40:45 +08:00
feat: add workspace list command
This commit is contained in:
parent
c44340accb
commit
1fe6180813
17 changed files with 570 additions and 118 deletions
|
|
@ -5,6 +5,46 @@ import {
|
|||
HarnessReplyTracker,
|
||||
} from '../../../src/channels/feishu/harness-client.mjs';
|
||||
|
||||
test('HarnessClient lists only absolute workspace paths', async () => {
|
||||
const client = new HarnessClient({
|
||||
baseUrl: 'http://127.0.0.1:3080',
|
||||
workspace: '/tmp/default-workspace',
|
||||
});
|
||||
const options = { rpcId: 'feishu-workspace-list' };
|
||||
const calls = [];
|
||||
let response = {
|
||||
items: [
|
||||
{
|
||||
workspaceId: 'workspace-one',
|
||||
path: '/tmp/workspace-one',
|
||||
title: 'private title',
|
||||
sessionIds: ['private-session'],
|
||||
},
|
||||
{ workspaceId: 'relative', path: 'relative/workspace' },
|
||||
null,
|
||||
{ workspaceId: 'workspace-two', path: '/tmp/workspace two' },
|
||||
],
|
||||
archivedSessionIds: ['private-archive'],
|
||||
};
|
||||
client.ensureRunning = async () => { calls.push({ method: 'ensureRunning' }); };
|
||||
client.rpc = async (method, payload, timeoutMs, rpcOptions) => {
|
||||
calls.push({ method, payload, timeoutMs, options: rpcOptions });
|
||||
return response;
|
||||
};
|
||||
|
||||
assert.deepEqual(await client.listWorkspaces(options), [
|
||||
'/tmp/workspace-one',
|
||||
'/tmp/workspace two',
|
||||
]);
|
||||
assert.deepEqual(calls, [
|
||||
{ method: 'ensureRunning' },
|
||||
{ method: 'workspace.list', payload: {}, timeoutMs: 30000, options },
|
||||
]);
|
||||
|
||||
response = { items: 'invalid' };
|
||||
assert.deepEqual(await client.listWorkspaces(), []);
|
||||
});
|
||||
|
||||
test('HarnessClient reads the nested workspace.create response used by DSH rc.6', async (t) => {
|
||||
const methods = [];
|
||||
t.mock.method(globalThis, 'fetch', async (_url, options) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue