From 3477aea88cd6809ac45231dec65bf514aaf6dd50 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Thu, 10 Oct 2024 17:12:50 -0400 Subject: [PATCH] fix: fixed tests --- src/main.ts | 2 +- tests/__mocks__/adapter.ts | 36 ++++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main.ts b/src/main.ts index 91490bc..0b9b9a4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -36,7 +36,7 @@ async function returnDataToKernel(repoToken: string, stateId: string, output: ob await octokit.repos.createDispatchEvent({ owner: github.context.repo.owner, repo: github.context.repo.repo, - event_type: "return_data_to_ubiquibot_kernel", + event_type: "return-data-to-ubiquity-os-kernel", client_payload: { state_id: stateId, output: JSON.stringify(output), diff --git a/tests/__mocks__/adapter.ts b/tests/__mocks__/adapter.ts index d1f634c..abb271f 100644 --- a/tests/__mocks__/adapter.ts +++ b/tests/__mocks__/adapter.ts @@ -36,21 +36,29 @@ export function createMockAdapters(context: Context) { commentMap.set(commentNodeId, { id: commentNodeId, plaintext, author_id: authorId, embedding, issue_id: issueId }); } ), - updateComment: jest.fn(async (plaintext: string | null, commentNodeId: string, payload: Record | null, isPrivate: boolean) => { - if (!commentMap.has(commentNodeId)) { - throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST); - } - const originalComment = commentMap.get(commentNodeId); - if (!originalComment) { - throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST); - } - const { id, author_id } = originalComment; - const embedding = await context.adapters.voyage.embedding.createEmbedding(plaintext); - if (isPrivate) { - plaintext = null; + updateComment: jest.fn( + async ( + plaintext: string | null, + commentNodeId: string, + authorId: number, + payload: Record | null, + isPrivate: boolean, + issueId: string + ) => { + if (!commentMap.has(commentNodeId)) { + throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST); + } + const originalComment = commentMap.get(commentNodeId); + if (!originalComment) { + throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST); + } + const embedding = await context.adapters.voyage.embedding.createEmbedding(plaintext); + if (isPrivate) { + plaintext = null; + } + commentMap.set(commentNodeId, { id: issueId, plaintext, author_id: authorId, embedding, payload }); } - commentMap.set(commentNodeId, { id, plaintext, author_id, embedding }); - }), + ), deleteComment: jest.fn(async (commentNodeId: string) => { if (!commentMap.has(commentNodeId)) { throw new Error(STRINGS.COMMENT_DOES_NOT_EXIST);