From 90927a71f4000217d607944b51f51f362d01eabd Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Tue, 6 Feb 2024 11:09:21 +0100 Subject: [PATCH] Add support for mentioning multiple assignees on GitHub issues (#889) * Add support for multiple assignees on issues * changelog --- changelog.d/889.feature | 1 + src/Connections/GithubRepo.ts | 2 +- tests/connections/GithubRepoTest.ts | 18 +++++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 changelog.d/889.feature diff --git a/changelog.d/889.feature b/changelog.d/889.feature new file mode 100644 index 00000000..a8aa104f --- /dev/null +++ b/changelog.d/889.feature @@ -0,0 +1 @@ +Mention all assignees when a new issue is created on GitHub. \ No newline at end of file diff --git a/src/Connections/GithubRepo.ts b/src/Connections/GithubRepo.ts index a59b2ee2..6e77191d 100644 --- a/src/Connections/GithubRepo.ts +++ b/src/Connections/GithubRepo.ts @@ -887,7 +887,7 @@ export class GitHubRepoConnection extends CommandConnection a.login).join(', ')}` : ''); if (this.showIssueRoomLink) { const appInstance = await this.githubInstance.getSafeOctokitForRepo(this.org, this.repo); if (appInstance) { diff --git a/tests/connections/GithubRepoTest.ts b/tests/connections/GithubRepoTest.ts index 9674a36c..85af40c6 100644 --- a/tests/connections/GithubRepoTest.ts +++ b/tests/connections/GithubRepoTest.ts @@ -6,6 +6,7 @@ import { DefaultConfig } from "../../src/config/Defaults"; import { AppserviceMock } from "../utils/AppserviceMock"; import { ApiError, ErrCode, ValidatorApiError } from "../../src/api"; import { expect } from "chai"; +import { IntentMock } from "../utils/IntentMock"; const ROOM_ID = "!foo:bar"; @@ -58,7 +59,7 @@ function createConnection(state: Record = {}, isExistingState=f // eslint-disable-next-line @typescript-eslint/no-non-null-assertion DefaultConfig.github! ); - return {connection, intent}; + return {connection, intent: intent as IntentMock}; } describe("GitHubRepoConnection", () => { @@ -136,6 +137,21 @@ describe("GitHubRepoConnection", () => { intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0); intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0); }); + it.only("will handle assignees on issue creation", async () => { + const { connection, intent } = createConnection(); + await connection.onIssueCreated({ + ...GITHUB_ISSUE_CREATED_PAYLOAD, + issue: { + ...GITHUB_ISSUE, + assignees: [{ login: 'alice'}, { login: 'bob'}] + } + } as never); + // Statement text. + intent.expectEventBodyContains('**alice** created new issue', 0); + intent.expectEventBodyContains('"My issue" assigned to alice, bob', 0); + intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.html_url, 0); + intent.expectEventBodyContains(GITHUB_ISSUE_CREATED_PAYLOAD.issue.title, 0); + }); it("will filter out issues not matching includingLabels.", async () => { const { connection, intent } = createConnection({ includingLabels: ["include-me"]