diff --git a/tests/smoketests/object-oriented/agent.test.ts b/tests/smoketests/object-oriented/agent.test.ts index 4e2d8c5ac..5e4726afb 100644 --- a/tests/smoketests/object-oriented/agent.test.ts +++ b/tests/smoketests/object-oriented/agent.test.ts @@ -65,6 +65,26 @@ describe('smoketest: object-oriented agent', () => { }, SHORT_TIMEOUT, ); + test.concurrent( + 'delete agent', + async () => { + const agent = await runloop.agent.create({ + name: uniqueName('sdk-agent-test-delete'), + version: '1.0.0', + source: { + type: 'npm', + npm: { + package_name: '@runloop/hello-world-agent', + }, + }, + }); + + await runloop.agent.delete(agent); + + await expect(agent.getInfo()).rejects.toThrow(); + }, + SHORT_TIMEOUT, + ); }); describe('agent listing', () => { @@ -80,6 +100,31 @@ describe('smoketest: object-oriented agent', () => { SHORT_TIMEOUT, ); + test.concurrent( + 'list public agents', + async () => { + const agents = await runloop.agent.listPublic({ limit: 10 }); + + expect(Array.isArray(agents)).toBe(true); + for (const agent of agents) { + expect(agent).toBeInstanceOf(Agent); + expect(agent.id).toBeTruthy(); + } + }, + SHORT_TIMEOUT, + ); + + test.concurrent( + 'get devbox counts', + async () => { + const counts = await runloop.agent.getDevboxCounts(); + + expect(typeof counts.total_count).toBe('number'); + expect(typeof counts.counts).toBe('object'); + }, + SHORT_TIMEOUT, + ); + test.concurrent( 'get agent by ID', async () => { diff --git a/tests/smoketests/object-oriented/eviction.test.ts b/tests/smoketests/object-oriented/eviction.test.ts index 6cae58f2e..aadfe8ad6 100644 --- a/tests/smoketests/object-oriented/eviction.test.ts +++ b/tests/smoketests/object-oriented/eviction.test.ts @@ -102,4 +102,26 @@ const tick = (ms = 20) => new Promise((resolve) => setTimeout(resolve, ms)); await tick(); expect(callback).not.toHaveBeenCalled(); }); + + test('onEvict reconnects after the stream ends cleanly', async () => { + const watchEvictions = jest + .fn, []>() + .mockResolvedValueOnce(streamOf([])) + .mockResolvedValueOnce(streamOf([{ devbox_id: 'dbx_reconnect', eviction_deadline_ms: 1 }])); + const devbox = Devbox.fromId(fakeClient(watchEvictions), 'dbx_reconnect'); + + const fired = new Promise((resolve) => devbox.onEvict(() => resolve())); + + let guard: ReturnType; + const timeout = new Promise((_resolve, reject) => { + guard = setTimeout(() => reject(new Error('onEvict callback never fired after reconnect')), 3000); + }); + try { + await Promise.race([fired, timeout]); + } finally { + clearTimeout(guard!); + } + + expect(watchEvictions).toHaveBeenCalledTimes(2); + }); });