diff --git a/tests/__mocks__/adapter.ts b/tests/__mocks__/adapter.ts index a2b4f3a..e85d4a9 100644 --- a/tests/__mocks__/adapter.ts +++ b/tests/__mocks__/adapter.ts @@ -114,6 +114,14 @@ export function createMockAdapters(context: Context) { return []; }), + findSimilarIssuesToMatch: jest.fn(async (params: { markdown: string; threshold: number; currentId: string }) => { + if (params.currentId === "task_complete") { + return [{ id: "similar3", similarity: 0.98 }]; + } else if (params.currentId === "task_complete_always") { + return [{ id: "similar5", similarity: 0.5 }]; + } + return []; + }), createIssue: jest.fn(async (issue: IssueData) => { issueMap.set(issue.id, issue); }), diff --git a/tests/main.test.ts b/tests/main.test.ts index bfb34ea..a7638da 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -284,11 +284,6 @@ describe("Plugin tests", () => { ); }); - // Mock the findSimilarIssues function to return predefined similar issues - context.adapters.supabase.issue.findSimilarIssues = jest - .fn() - .mockResolvedValue([{ id: "similar3", similarity: 0.98 }] as unknown as IssueSimilaritySearchResult[]); - // Mock the graphql function to return predefined issue data context.octokit.graphql = jest.fn().mockResolvedValue({ node: { @@ -339,11 +334,6 @@ describe("Plugin tests", () => { ); }); - // Mock findSimilarIssues to return a result with low similarity - context.adapters.supabase.issue.findSimilarIssues = jest - .fn() - .mockResolvedValue([{ id: "similar5", similarity: 0.5 }] as unknown as IssueSimilaritySearchResult[]); - // Mock graphql to return issue data with a contributor context.octokit.graphql = jest.fn().mockResolvedValue({ node: {