Add macOS companion node status and system.nodes APIs
This commit is contained in:
@@ -215,6 +215,58 @@ describe('system handlers', () => {
|
||||
expect(locations[0]?.nodeId).toBe('node-1');
|
||||
expect(getPath(result.result, 'summary')).toEqual({ total: 1 });
|
||||
});
|
||||
|
||||
it('system.nodes returns empty result when getNodes is not provided', async () => {
|
||||
const req: GatewayRequest = { id: 8, method: 'system.nodes' };
|
||||
const result = await handlers['system.nodes'](req) as GatewayResponse;
|
||||
expect(result.id).toBe(8);
|
||||
expect(getPath(result.result, 'nodes')).toEqual([]);
|
||||
expect(getPath(result.result, 'summary')).toEqual({ total: 0 });
|
||||
});
|
||||
|
||||
it('system.nodes returns filtered registered node snapshots', async () => {
|
||||
const handlers = createSystemHandlers({
|
||||
...deps,
|
||||
getNodes: ({ role, platform, limit } = {}) => {
|
||||
const all = [
|
||||
{
|
||||
connectionId: 'c1',
|
||||
nodeId: 'companion-mac',
|
||||
role: 'companion',
|
||||
identity: 'will@example.com',
|
||||
protocolVersion: 1,
|
||||
capabilities: ['ui.canvas'],
|
||||
registeredAt: 100,
|
||||
status: { platform: 'macos' as const, appVersion: '0.3.0', powerSource: 'ac' as const, reportedAt: 120 },
|
||||
},
|
||||
{
|
||||
connectionId: 'c2',
|
||||
nodeId: 'observer-linux',
|
||||
role: 'observer',
|
||||
protocolVersion: 1,
|
||||
capabilities: [],
|
||||
registeredAt: 90,
|
||||
status: { platform: 'linux' as const, powerSource: 'unknown' as const, reportedAt: 95 },
|
||||
},
|
||||
];
|
||||
return all
|
||||
.filter((entry) => !role || entry.role === role)
|
||||
.filter((entry) => !platform || entry.status?.platform === platform)
|
||||
.slice(0, limit ?? 100);
|
||||
},
|
||||
});
|
||||
|
||||
const req: GatewayRequest = {
|
||||
id: 9,
|
||||
method: 'system.nodes',
|
||||
params: { role: 'companion', platform: 'macos', limit: 1 },
|
||||
};
|
||||
const result = await handlers['system.nodes'](req) as GatewayResponse;
|
||||
const nodes = getPath(result.result, 'nodes') as Array<{ nodeId: string }>;
|
||||
expect(nodes).toHaveLength(1);
|
||||
expect(nodes[0]?.nodeId).toBe('companion-mac');
|
||||
expect(getPath(result.result, 'summary')).toEqual({ total: 1 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('system.tokenUsage handler', () => {
|
||||
|
||||
Reference in New Issue
Block a user