wip: complete rework first round

This commit is contained in:
2026-02-26 09:27:22 +01:00
parent c70f4b9154
commit affd62ca79
78 changed files with 2635 additions and 4053 deletions

View File

@@ -25,7 +25,6 @@ describe('pythonApiContractV1', () => {
'app.getSystemLanguage',
'chat.getConversations',
'chat.sendMessage',
'chat.getProtocolHealth',
]));
});
@@ -44,7 +43,7 @@ describe('pythonApiContractV1', () => {
});
});
it('documents chat.sendMessage protocol envelope return contract and metadata input', () => {
it('documents chat.sendMessage return contract and metadata input', () => {
expect(getPythonApiMethodContract('chat.sendMessage')).toEqual({
method: 'chat.sendMessage',
description: 'Send message to chat conversation.',
@@ -65,7 +64,7 @@ describe('pythonApiContractV1', () => {
required: false,
},
],
returns: "{ success: boolean; message?: string; envelope?: ProtocolResponseEnvelope; protocolVersion?: '2.0'; traceId?: string; warnings?: string[]; error?: string }",
returns: '{ success: boolean; message?: string; error?: string }',
});
});
@@ -81,8 +80,6 @@ describe('pythonApiContractV1', () => {
expect.objectContaining({ name: 'PostData' }),
expect.objectContaining({ name: 'MediaData' }),
expect.objectContaining({ name: 'ProjectData' }),
expect.objectContaining({ name: 'ProtocolResponseEnvelope' }),
expect.objectContaining({ name: 'ProtocolTelemetrySnapshot' }),
]));
});
});

View File

@@ -29,16 +29,12 @@ describe('invokePythonApiMethodV1', () => {
const getProjectMetadata = vi.fn().mockResolvedValue({ name: 'My Project' });
const getAllProjects = vi.fn().mockResolvedValue([{ id: 'prj-1', name: 'Main' }]);
const getAllPosts = vi.fn().mockResolvedValue({ items: [], hasMore: false, total: 0 });
const getProtocolHealth = vi.fn().mockResolvedValue({ totalTurns: 1, parseValidityRate: 1 });
vi.stubGlobal('window', {
electronAPI: {
projects: {
getAll: getAllProjects,
},
chat: {
getProtocolHealth,
},
posts: {
search: searchPosts,
getAll: getAllPosts,
@@ -53,12 +49,10 @@ describe('invokePythonApiMethodV1', () => {
await expect(invokePythonApiMethodV1('posts.getAll', { options: { limit: 10, offset: 5 } })).resolves.toEqual({ items: [], hasMore: false, total: 0 });
await expect(invokePythonApiMethodV1('posts.search', { query: 'hit' })).resolves.toEqual([{ id: 'p1', title: 'Hit' }]);
await expect(invokePythonApiMethodV1('meta.getProjectMetadata', {})).resolves.toEqual({ name: 'My Project' });
await expect(invokePythonApiMethodV1('chat.getProtocolHealth', {})).resolves.toEqual({ totalTurns: 1, parseValidityRate: 1 });
expect(getAllProjects).toHaveBeenCalledWith();
expect(getAllPosts).toHaveBeenCalledWith({ limit: 10, offset: 5 });
expect(searchPosts).toHaveBeenCalledWith('hit');
expect(getProjectMetadata).toHaveBeenCalledWith();
expect(getProtocolHealth).toHaveBeenCalledWith();
});
it('rejects unknown methods and malformed args', async () => {
@@ -72,9 +66,6 @@ describe('invokePythonApiMethodV1', () => {
projects: {
getAll: vi.fn(),
},
chat: {
getProtocolHealth: vi.fn(),
},
meta: {
getProjectMetadata: vi.fn(),
},