feat: implement PI core chat timeline
This commit is contained in:
@@ -65,6 +65,33 @@ describe('host-api', () => {
|
||||
await expect(hostApiFetch('/api/test')).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('returns authenticated binary IPC data without JSON or browser fallback', async () => {
|
||||
const bytes = new Uint8Array([9, 8, 7]);
|
||||
invokeIpcMock.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
data: {
|
||||
status: 200,
|
||||
ok: true,
|
||||
bytes,
|
||||
contentType: 'image/webp',
|
||||
},
|
||||
});
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
|
||||
const { hostApiFetchBytes } = await import('@/lib/host-api');
|
||||
|
||||
await expect(hostApiFetchBytes('/api/coding/attachments/attachment-1/content'))
|
||||
.resolves.toEqual({ bytes, contentType: 'image/webp' });
|
||||
expect(invokeIpcMock).toHaveBeenCalledWith('hostapi:fetch', {
|
||||
path: '/api/coding/attachments/attachment-1/content',
|
||||
method: 'GET',
|
||||
headers: { Accept: 'application/octet-stream' },
|
||||
body: null,
|
||||
});
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('supports legacy proxy envelope response', async () => {
|
||||
invokeIpcMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user