mirror of
https://github.com/letta-ai/claude-subconscious.git
synced 2026-04-25 17:04:56 +02:00
Use a shared URL builder across scripts and update createConversation to call /v1/conversations/ with query params to avoid HTTPS->HTTP redirect failures behind reverse proxies. This also deduplicates LETTA_API_BASE handling and adds regression tests for trailing-slash behavior. 👾 Generated with [Letta Code](https://letta.com) Co-authored-by: Letta Code <noreply@letta.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
|
const fetchMock = vi.fn();
|
|
|
|
vi.stubGlobal('fetch', fetchMock);
|
|
|
|
describe('createConversation', () => {
|
|
afterEach(() => {
|
|
fetchMock.mockReset();
|
|
vi.unstubAllEnvs();
|
|
vi.resetModules();
|
|
});
|
|
|
|
it('uses trailing-slash conversations endpoint with agent_id query', async () => {
|
|
vi.stubEnv('LETTA_BASE_URL', 'https://letta.example.com');
|
|
|
|
fetchMock.mockResolvedValue({
|
|
ok: true,
|
|
json: async () => ({ id: 'conversation-123' }),
|
|
});
|
|
|
|
const { createConversation } = await import('./conversation_utils.js');
|
|
const conversationId = await createConversation('test-key', 'agent-123');
|
|
|
|
expect(conversationId).toBe('conversation-123');
|
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
expect(fetchMock).toHaveBeenCalledWith(
|
|
'https://letta.example.com/v1/conversations/?agent_id=agent-123',
|
|
expect.objectContaining({
|
|
method: 'POST',
|
|
headers: expect.objectContaining({
|
|
Authorization: 'Bearer test-key',
|
|
}),
|
|
}),
|
|
);
|
|
});
|
|
}); |