27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
import { describe, it, expect, beforeAll } from 'vitest';
|
|
import { pool } from '../../../../lib/db/pool.js';
|
|
import { resetDb } from '../../../helpers/db.js';
|
|
import { migrateUp } from '../../../../lib/db/migrate.js';
|
|
import { contextTool } from '../../../../lib/ai/agent/tools/context.js';
|
|
|
|
let spaceId, taskId;
|
|
beforeAll(async () => {
|
|
await resetDb(); await migrateUp();
|
|
({ rows: [{ id: spaceId }] } = await pool.query(
|
|
`INSERT INTO spaces(slug,name) VALUES('s','S') RETURNING id`));
|
|
({ rows: [{ id: taskId }] } = await pool.query(
|
|
`INSERT INTO tasks(space_id,title) VALUES($1,'Wire telemetry') RETURNING id`, [spaceId]));
|
|
});
|
|
|
|
describe('context tool', () => {
|
|
it('summarises the current view entity', async () => {
|
|
const out = await contextTool.handler({}, { space_id: spaceId, view: { entityType: 'task', entityId: taskId } });
|
|
expect(out.entityType).toBe('task');
|
|
expect(out.title).toBe('Wire telemetry');
|
|
});
|
|
it('handles no active view', async () => {
|
|
const out = await contextTool.handler({}, { space_id: spaceId, view: null });
|
|
expect(out.note).toMatch(/no specific entity/i);
|
|
});
|
|
});
|