Skip to content

Commit

Permalink
chore: fix tests, type context for comment.created fns
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 24, 2024
1 parent 00534fa commit 18f467f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/handlers/ask-llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ import { DEFAULT_SYSTEM_MESSAGE } from "../adapters/openai/helpers/prompts";
* @returns The response from GPT
* @throws If no question is provided
*/
export async function askQuestion(context: Context, question: string) {
export async function askQuestion(context: Context<"issue_comment.created">, question: string) {
if (!question) {
throw context.logger.error("No question provided");
}
const { specAndBodies, streamlinedComments } = await recursivelyFetchLinkedIssues({
context,
owner: context.payload.repository.owner.login,
repo: context.payload.repository.name,
issueNum: context.payload.issue.number,
});
const formattedChat = await formatChatHistory(context, streamlinedComments, specAndBodies);
context.logger.info(`${formattedChat.join("")}`);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/format-chat-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { splitKey } from "./issue";
* @returns A promise that resolves to a formatted string representing the chat history.
*/
export async function formatChatHistory(
context: Context,
context: Context<"issue_comment.created">,
streamlined: Record<string, StreamlinedComment[]>,
specAndBodies: Record<string, string>
): Promise<string[]> {
Expand Down
12 changes: 6 additions & 6 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ function createContext(body = TEST_SLASH_COMMAND) {
const user = db.users.findFirst({ where: { id: { equals: 1 } } });
return {
payload: {
issue: db.issue.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context["payload"]["issue"],
issue: db.issue.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context<"issue_comment.created">["payload"]["issue"],
sender: user,
repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context["payload"]["repository"],
comment: { body, user: user } as unknown as Context["payload"]["comment"],
repository: db.repo.findFirst({ where: { id: { equals: 1 } } }) as unknown as Context<"issue_comment.created">["payload"]["repository"],
comment: { body, user: user } as unknown as Context<"issue_comment.created">["payload"]["comment"],
action: "created" as string,
installation: { id: 1 } as unknown as Context["payload"]["installation"],
organization: { login: "ubiquity" } as unknown as Context["payload"]["organization"],
installation: { id: 1 } as unknown as Context<"issue_comment.created">["payload"]["installation"],
organization: { login: "ubiquity" } as unknown as Context<"issue_comment.created">["payload"]["organization"],
},
owner: "ubiquity",
repo: "test-repo",
Expand Down Expand Up @@ -408,5 +408,5 @@ function createContext(body = TEST_SLASH_COMMAND) {
},
octokit: new octokit.Octokit(),
eventName: "issue_comment.created" as SupportedEventsU,
} as unknown as Context;
} as unknown as Context<"issue_comment.created">;
}

0 comments on commit 18f467f

Please sign in to comment.