From a0f9af25ce7405ef844be4992c0cf7ecbf83e006 Mon Sep 17 00:00:00 2001 From: BottlecapDave Date: Wed, 17 Jul 2024 18:39:53 +0100 Subject: [PATCH] fix: Fixed link to pull request in raised slack messages --- reminder/src/githubService.test.ts | 5 +++-- reminder/src/githubService.ts | 2 +- reminder/src/notifiers/slackService.test.ts | 4 ++-- reminder/src/notifiers/slackService.ts | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/reminder/src/githubService.test.ts b/reminder/src/githubService.test.ts index 823d6ac..ac92195 100644 --- a/reminder/src/githubService.test.ts +++ b/reminder/src/githubService.test.ts @@ -6,7 +6,7 @@ function createRequestData(): IGitHubMergeRequestRequest { includeWorkInProgress: true, repos: [process.env.TEST_REPO as string], mandatoryLabels: [], - excludedLabels: [], + excludedLabels: ["dependencies"], } } @@ -16,7 +16,8 @@ function getAccessToken(): string { function assertMergeRequest(mergeRequest: IGitHubMergeRequest) { expect(mergeRequest.head.repo.full_name).toEqual('BottlecapDave/GitHub-Pull-Request-Reminder'); - expect(mergeRequest.user.login).toEqual('BottlecapDave'); + expect(mergeRequest.user.login === 'dependabot[bot]' || mergeRequest.user.login === 'BottlecapDave').toEqual(true); + expect(mergeRequest.html_url.startsWith("https://github.com/BottlecapDave/GitHub-Pull-Request-Reminder/pull/")).toEqual(true); } function assertMergeRequests(mergeRequests: IGitHubMergeRequest[], includeWip: boolean, includeDraft: boolean) { diff --git a/reminder/src/githubService.ts b/reminder/src/githubService.ts index c41e72a..93b6d68 100644 --- a/reminder/src/githubService.ts +++ b/reminder/src/githubService.ts @@ -19,7 +19,7 @@ export interface IGitHubMergeRequest { }; created_at: string; user: IGitHubAuthor; - url: string; + html_url: string; labels: IGitHubLabel[]; draft: boolean; } diff --git a/reminder/src/notifiers/slackService.test.ts b/reminder/src/notifiers/slackService.test.ts index 9e644b9..9ff2245 100644 --- a/reminder/src/notifiers/slackService.test.ts +++ b/reminder/src/notifiers/slackService.test.ts @@ -21,7 +21,7 @@ function createMergeRequests(): IGitHubMergeRequest[] { }, }, title: "Merge request with mandatory labels", - url: "https://gitlab.com/test/github-pull-request-reminder-test/-/merge_requests/1", + html_url: "https://gitlab.com/test/github-pull-request-reminder-test/-/merge_requests/1", draft: false, }, { @@ -36,7 +36,7 @@ function createMergeRequests(): IGitHubMergeRequest[] { }, }, title: "wip: Merge request ", - url: "https://gitlab.com/test/github-pull-request-reminder-test/-/merge_requests/2", + html_url: "https://gitlab.com/test/github-pull-request-reminder-test/-/merge_requests/2", draft: false, }] } diff --git a/reminder/src/notifiers/slackService.ts b/reminder/src/notifiers/slackService.ts index d0d29d3..7108bd9 100644 --- a/reminder/src/notifiers/slackService.ts +++ b/reminder/src/notifiers/slackService.ts @@ -26,7 +26,7 @@ export class SlackService { type: "section", text: { type: "mrkdwn", - text: `*<${request.url}|(${request.head.repo.full_name}) ${request.title}>*\n${request.user.login} | opened ${formatDistance(request.created_at, new Date())}` + text: `*<${request.html_url}|(${request.head.repo.full_name}) ${request.title}>*\n${request.user.login} | opened ${formatDistance(request.created_at, new Date())}` } }) }