mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 05:12:33 +00:00
+16




![github-actions[bot] <github-actions[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)




Mega Mind
GitHub
YellowSnnowmann
Steven Enamakel
github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Cyrus Gray
Horst1993
Cursor
James Gentes
Sam
Sami Rusani
oxoxDev
Muhammad Ismail
Claude Fable 5
nb213
binyangzhu000-sudo
Steven Enamakel
CodeGhost21
sanil-23
M3gA-Mind
oxoxDev
mysma-9403
mwakidenis
NgoQuocViet2001
viet.ngo
Maciej Myszkiewicz
2e5b5e7b23
Co-authored-by: YellowSnnowmann <167776381+YellowSnnowmann@users.noreply.github.com> Co-authored-by: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Cyrus Gray <144336577+graycyrus@users.noreply.github.com> Co-authored-by: Horst1993 <horst.w@gmicloud.ai> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: James Gentes <jgentes@users.noreply.github.com> Co-authored-by: Sam <samrusani@users.noreply.github.com> Co-authored-by: Sami Rusani <14844597+samrusani@users.noreply.github.com> Co-authored-by: oxoxDev <164490987+oxoxDev@users.noreply.github.com> Co-authored-by: Muhammad Ismail <78064250+myi1@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: nb213 <binyangzhu000@gmail.com> Co-authored-by: binyangzhu000-sudo <224954946+binyangzhu000-sudo@users.noreply.github.com> Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai> Co-authored-by: CodeGhost21 <164498022+CodeGhost21@users.noreply.github.com> Co-authored-by: sanil-23 <sanil@tinyhumans.ai> Co-authored-by: M3gA-Mind <elvin@mahadao.com> Co-authored-by: oxoxDev <oxoxdev@users.noreply.github.com> Co-authored-by: mysma-9403 <64923976+mysma-9403@users.noreply.github.com> Co-authored-by: mwakidenis <mwakidenice@gmail.com> Co-authored-by: NgoQuocViet2001 <123613986+NgoQuocViet2001@users.noreply.github.com> Co-authored-by: viet.ngo <viet.ngo@sotatek.com> Co-authored-by: Maciej Myszkiewicz <mmyszkiewicz@bwcoders.com>
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
import { formatRpcCallFailure } from './e2e/helpers/core-rpc-node';
|
|
|
|
describe('formatRpcCallFailure', () => {
|
|
it('includes the RPC method, status, and error text', () => {
|
|
expect(
|
|
formatRpcCallFailure('openhuman.composio_list_triggers', {
|
|
ok: false,
|
|
httpStatus: 500,
|
|
error: 'Backend returned 500: trigger store unavailable',
|
|
})
|
|
).toContain(
|
|
'openhuman.composio_list_triggers failed: httpStatus=500 error=Backend returned 500: trigger store unavailable'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('callOpenhumanRpcNode', () => {
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
vi.resetModules();
|
|
});
|
|
|
|
it('rediscovers the core when the cached listener disappears after a reset', async () => {
|
|
const requestedUrls: string[] = [];
|
|
let firstListenerAlive = true;
|
|
|
|
vi.stubGlobal(
|
|
'fetch',
|
|
vi.fn(async (input: string | URL | Request, init?: RequestInit) => {
|
|
const url = String(input);
|
|
requestedUrls.push(url);
|
|
const body = JSON.parse(String(init?.body)) as { method: string };
|
|
|
|
if (url.includes(':7788/')) {
|
|
if (body.method === 'core.ping' && firstListenerAlive) {
|
|
return new Response('', { status: 401 });
|
|
}
|
|
if (body.method === 'openhuman.first_call' && firstListenerAlive) {
|
|
return Response.json({ result: 'first' });
|
|
}
|
|
throw new TypeError('fetch failed');
|
|
}
|
|
|
|
if (url.includes(':7789/')) {
|
|
if (body.method === 'core.ping') return new Response('', { status: 401 });
|
|
return Response.json({ result: 'replacement' });
|
|
}
|
|
|
|
throw new TypeError('fetch failed');
|
|
})
|
|
);
|
|
|
|
const { callOpenhumanRpcNode } = await import('./e2e/helpers/core-rpc-node');
|
|
await expect(callOpenhumanRpcNode('openhuman.first_call')).resolves.toMatchObject({
|
|
ok: true,
|
|
result: 'first',
|
|
});
|
|
|
|
firstListenerAlive = false;
|
|
await expect(callOpenhumanRpcNode('openhuman.after_reset')).resolves.toMatchObject({
|
|
ok: true,
|
|
result: 'replacement',
|
|
});
|
|
expect(requestedUrls.some(url => url.includes(':7789/rpc'))).toBe(true);
|
|
});
|
|
});
|