Skip to content

Commit

Permalink
fix: unit test
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Dec 26, 2023
1 parent 40c9ba3 commit 01a30d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/routes/chat_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export function registerChatRoutes(router: IRouter, routeOptions: RoutesOptions)
*/
const interaction = await storageService.getInteraction(sessionId, interactionId);
resultPayload.interactions = [interaction].filter((item) => item);
resultPayload.messages =
(await storageService.getMessagesFromInteractions(resultPayload.interactions)) || [];
resultPayload.messages = resultPayload.interactions.length
? await storageService.getMessagesFromInteractions(resultPayload.interactions)
: [];
}

return response.ok({
Expand Down
3 changes: 3 additions & 0 deletions server/routes/regenerate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ describe('regenerate route when rootAgentId is provided', () => {
create_time: 'create_time',
};
});
mockAgentFrameworkStorageService.getMessagesFromInteractions.mockImplementationOnce(
async () => []
);
const result = (await regenerateRequest({
sessionId: 'foo',
interactionId: 'bar',
Expand Down
6 changes: 6 additions & 0 deletions server/routes/send_message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ describe('send_message route when rootAgentId is provided', () => {
create_time: 'create_time',
};
});
mockAgentFrameworkStorageService.getMessagesFromInteractions.mockImplementationOnce(
async () => []
);
const result = (await sendMessageRequest({
input: {
content: '1',
Expand Down Expand Up @@ -193,6 +196,9 @@ describe('send_message route when rootAgentId is provided', () => {
create_time: 'create_time',
};
});
mockAgentFrameworkStorageService.getMessagesFromInteractions.mockImplementationOnce(
async () => []
);
const result = (await sendMessageRequest({
input: {
content: '1',
Expand Down

0 comments on commit 01a30d1

Please sign in to comment.