Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(desktop): R1-L1 cover invalid IPC pagination values
Josué57c4b2270a93
diff --git a/desktop-app/test/ipc.test.ts b/desktop-app/test/ipc.test.tsindex cc41d3543..645029908 100644--- a/desktop-app/test/ipc.test.ts+++ b/desktop-app/test/ipc.test.ts@@ -47,10 +47,16 @@ describe('chat IPC pagination validation', () => {it.each([['10', 0],+ [NaN, 0],+ [Infinity, 0],[1.5, 0],[0, 0],[1001, 0],+ [10, NaN],+ [10, Infinity],+ [10, 1.5],[10, -1],+ [10, Number.MAX_SAFE_INTEGER + 1],[Number.MAX_SAFE_INTEGER + 1, 0],])('rejects an invalid limit/offset pair: %s, %s', (limit, offset) => {expect(() => sanitizeChatLoadWindow(limit, offset)).toThrow()@@ -96,6 +102,8 @@ describe('ipc host status stream handlers', () => {getExternalChannelsSummary: vi.fn(),listArtifacts: vi.fn(),downloadArtifact: vi.fn(),+ listSessions: vi.fn(),+ loadSessionMessages: vi.fn(),listWorkflowRuns: vi.fn(),listWorkflowRunArtifacts: vi.fn(),downloadWorkflowRunArtifact: vi.fn(),@@ -146,6 +154,61 @@ describe('ipc host status stream handlers', () => {expect(service.setSandboxUiVisible).toHaveBeenCalledWith(false)})+ it.each([NaN, Infinity, 1.5, 0, -1, Number.MAX_SAFE_INTEGER + 1])(+ 'rejects invalid session catalog limit %s before calling the service',+ async limit => {+ const { event } = makeTrustedEvent()+ const handler = testState.handlers.get('rpc:listSessions')+ await expect(+ Promise.resolve(handler?.(event, { hostRef: 'agent-x', query: { limit } }))+ ).rejects.toThrow(/limit|integer/)+ expect(service.listSessions).not.toHaveBeenCalled()+ }+ )++ it.each([+ ['limit', NaN],+ ['limit', Infinity],+ ['limit', 1.5],+ ['limit', 0],+ ['limit', Number.MAX_SAFE_INTEGER + 1],+ ['beforeTurn', 0],+ ['beforeTurn', -1],+ ['beforeTurn', 1.5],+ ['afterTurn', -1],+ ['afterTurn', 1.5],+ ])('rejects invalid message query %s=%s before calling the service', async (field, value) => {+ const { event } = makeTrustedEvent()+ const handler = testState.handlers.get('rpc:loadSessionMessages')+ await expect(+ Promise.resolve(+ handler?.(event, {+ hostRef: 'agent-x',+ agent: 'agent-x',+ chatId: 'chat-a',+ query: { [field]: value },+ })+ )+ ).rejects.toThrow()+ expect(service.loadSessionMessages).not.toHaveBeenCalled()+ })++ it('rejects mutually exclusive message cursors before calling the service', async () => {+ const { event } = makeTrustedEvent()+ const handler = testState.handlers.get('rpc:loadSessionMessages')+ await expect(+ Promise.resolve(+ handler?.(event, {+ hostRef: 'agent-x',+ agent: 'agent-x',+ chatId: 'chat-a',+ query: { beforeTurn: 2, afterTurn: 1 },+ })+ )+ ).rejects.toThrow(/mutually exclusive/)+ expect(service.loadSessionMessages).not.toHaveBeenCalled()+ })+it('starts stream and forwards emitted events to sender', async () => {let callback: ((event: HostStatusStreamEvent) => void) | null = nullservice.startHostStatusStream.mockImplementation(