mcp
This commit is contained in:
@@ -40,6 +40,7 @@ describe('AssistantService', () => {
|
||||
listLists: jest.fn(),
|
||||
addItem: jest.fn(),
|
||||
};
|
||||
listsService.listLists.mockResolvedValue([]);
|
||||
service = new AssistantService(
|
||||
chatLogsRepository as never,
|
||||
listRealtimeService as never,
|
||||
@@ -570,6 +571,107 @@ describe('AssistantService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('treats unknown list tool results as created lists for creation requests', async () => {
|
||||
const createdList = {
|
||||
id: 'list-1',
|
||||
ownerId: 'user-1',
|
||||
accessRole: 'owner',
|
||||
name: 'Einkauf',
|
||||
kind: 'shopping',
|
||||
items: [],
|
||||
collaborators: [],
|
||||
createdAt: '2026-06-12T00:00:00.000Z',
|
||||
updatedAt: '2026-06-12T00:00:00.000Z',
|
||||
};
|
||||
const providerResponse = {
|
||||
choices: [
|
||||
{
|
||||
messages: [
|
||||
{
|
||||
role: 'tool',
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: JSON.stringify({ list: createdList }),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: 'assistant',
|
||||
content: 'Erledigt.',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
mockMistralResponse(providerResponse);
|
||||
|
||||
const result = await service.chat('user-1', {
|
||||
messages: [{ role: 'user', content: 'Erstelle eine Einkaufsliste' }],
|
||||
});
|
||||
|
||||
expect(result.actions).toEqual([
|
||||
{
|
||||
type: 'list.created',
|
||||
listId: 'list-1',
|
||||
list: createdList,
|
||||
},
|
||||
]);
|
||||
expect(result.message.content).toBe('Erledigt.');
|
||||
expect(listRealtimeService.publishSnapshot).toHaveBeenCalledWith(
|
||||
'user-1',
|
||||
createdList,
|
||||
);
|
||||
});
|
||||
|
||||
it('detects lists created through the connector when the provider omits tool details', async () => {
|
||||
const createdList = {
|
||||
id: 'list-1',
|
||||
ownerId: 'user-1',
|
||||
accessRole: 'owner',
|
||||
name: 'Einkauf',
|
||||
kind: 'shopping',
|
||||
items: [],
|
||||
collaborators: [],
|
||||
createdAt: '2026-06-12T00:00:00.000Z',
|
||||
updatedAt: '2026-06-12T00:00:00.000Z',
|
||||
};
|
||||
listsService.listLists
|
||||
.mockResolvedValueOnce([])
|
||||
.mockResolvedValueOnce([createdList]);
|
||||
mockMistralResponse({
|
||||
choices: [
|
||||
{
|
||||
message: {
|
||||
content: 'Ich habe die Liste angelegt.',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const result = await service.chat('user-1', {
|
||||
messages: [{ role: 'user', content: 'Erstelle eine Einkaufsliste' }],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: 'Ich habe die Liste angelegt.',
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
type: 'list.created',
|
||||
listId: 'list-1',
|
||||
list: createdList,
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(listRealtimeService.publishSnapshot).toHaveBeenCalledWith(
|
||||
'user-1',
|
||||
createdList,
|
||||
);
|
||||
});
|
||||
|
||||
it('returns a clear message when list creation did not use the connector', async () => {
|
||||
mockMistralResponse({
|
||||
choices: [
|
||||
|
||||
Reference in New Issue
Block a user