Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { ApiHandler, type ApiActionContext } from '../src/api-handler';
|
|
|
|
describe('get_status transport health (#233, #342)', () => {
|
|
it.each([0, 999, 1_000, 90_999])(
|
|
'reports whole session seconds for %i ms',
|
|
async (uptimeMs) => {
|
|
const ctx = {
|
|
isOnline: () => true,
|
|
getUptimeMs: () => uptimeMs,
|
|
bridge: { receiveHealthy: true },
|
|
} as unknown as ApiActionContext;
|
|
const response = await new ApiHandler(ctx).handle('get_status', {});
|
|
expect(response.data).toEqual({
|
|
online: true,
|
|
good: true,
|
|
time: Math.floor(uptimeMs / 1000),
|
|
});
|
|
},
|
|
);
|
|
|
|
it('keeps online true while reporting a stalled receive path as not good', async () => {
|
|
const ctx = {
|
|
isOnline: () => true,
|
|
getUptimeMs: () => 90_999,
|
|
bridge: { receiveHealthy: false },
|
|
} as unknown as ApiActionContext;
|
|
const response = await new ApiHandler(ctx).handle('get_status', {});
|
|
|
|
expect(response).toMatchObject({
|
|
status: 'ok',
|
|
retcode: 0,
|
|
data: { online: true, good: false, time: 90 },
|
|
});
|
|
});
|
|
});
|