feat(agents): conversations.findOrCreateGlobal for space-less agents
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
19
tests/db/conversations_global.test.js
Normal file
19
tests/db/conversations_global.test.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { describe, it, expect, beforeAll } from 'vitest';
|
||||
import { resetDb } from '../helpers/db.js';
|
||||
import { migrateUp } from '../../lib/db/migrate.js';
|
||||
import * as agents from '../../lib/db/repos/agents.js';
|
||||
import * as conversations from '../../lib/db/repos/conversations.js';
|
||||
|
||||
const owner = { kind: 'user', id: null };
|
||||
beforeAll(async () => { await resetDb(); await migrateUp(); });
|
||||
|
||||
describe('findOrCreateGlobal', () => {
|
||||
it('creates one space-less open conversation and reuses it', async () => {
|
||||
const y = await agents.getBySlug('yerin'); // seeded by 011_yerin.sql
|
||||
const c1 = await conversations.findOrCreateGlobal(y.id, owner);
|
||||
expect(c1.space_id).toBeNull();
|
||||
expect(c1.agent_id).toBe(y.id);
|
||||
const c2 = await conversations.findOrCreateGlobal(y.id, owner);
|
||||
expect(c2.id).toBe(c1.id);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user