feat: implement PI core chat timeline
This commit is contained in:
42
tests/unit/coding-projects-facade.test.ts
Normal file
42
tests/unit/coding-projects-facade.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const hostApiFetch = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('@/lib/host-api', () => ({ hostApiFetch }));
|
||||
|
||||
describe('coding project Host facade', () => {
|
||||
beforeEach(() => vi.clearAllMocks());
|
||||
|
||||
it('uses only the vendor-neutral project metadata routes', async () => {
|
||||
hostApiFetch
|
||||
.mockResolvedValueOnce({ projects: [], activeProjectId: null })
|
||||
.mockResolvedValueOnce({ snapshot: { project: { id: 'project/a' }, config: {} } })
|
||||
.mockResolvedValueOnce({ conversations: [] })
|
||||
.mockResolvedValueOnce({ conversation: { id: 'conversation-1' } });
|
||||
const {
|
||||
createCodingProjectConversation,
|
||||
getCodingProjectConfig,
|
||||
listCodingProjectConversations,
|
||||
listCodingProjects,
|
||||
} = await import('@/lib/coding-projects');
|
||||
|
||||
await listCodingProjects();
|
||||
await getCodingProjectConfig('project/a');
|
||||
await listCodingProjectConversations('project/a');
|
||||
await createCodingProjectConversation({
|
||||
projectId: 'project/a',
|
||||
agentId: 'agent-1',
|
||||
title: '新对话',
|
||||
});
|
||||
|
||||
expect(hostApiFetch.mock.calls).toEqual([
|
||||
['/api/coding/projects'],
|
||||
['/api/coding/projects/config?projectId=project%2Fa'],
|
||||
['/api/coding/projects/conversations?projectId=project%2Fa'],
|
||||
['/api/coding/projects/conversations', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ projectId: 'project/a', agentId: 'agent-1', title: '新对话' }),
|
||||
}],
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user