fix(GitHubPullRequestTransformer): use sender (#1351)

This commit is contained in:
Jiralite authored and GitHub committed 2026-07-09 22:57:25 +02:00
1 parent dec7b63d07
commit d1aa49f4f9
2 files changed
+7 -5

No files matched your search

@@ -60,8 +60,8 @@ describe('GitHub Pull Request Transformer', () => {
expect(result?.url).toBe('https://github.com/org/repo/pull/42'); expect(result?.url).toBe('https://github.com/org/repo/pull/42');
expect(result?.color).toBe(0x098efc); expect(result?.color).toBe(0x098efc);
expect(result?.description).toContain('amazing feature'); expect(result?.description).toContain('amazing feature');
expect(result?.author?.name).toBe('prauthor'); expect(result?.author?.name).toBe('testuser');
expect(result?.author?.url).toBe('https://github.com/prauthor'); expect(result?.author?.url).toBe('https://github.com/testuser');
}); });
it('transforms a closed pull request', async () => { it('transforms a closed pull request', async () => {
const payload: GitHubWebhook = { const payload: GitHubWebhook = {
@@ -75,6 +75,7 @@ describe('GitHub Pull Request Transformer', () => {
expect(result?.title).toContain('Pull request closed'); expect(result?.title).toContain('Pull request closed');
expect(result?.color).toBe(0x000000); expect(result?.color).toBe(0x000000);
expect(result?.description).toBeUndefined(); expect(result?.description).toBeUndefined();
expect(result?.author?.name).toBe('testuser');
}); });
it('transforms a reopened pull request', async () => { it('transforms a reopened pull request', async () => {
const payload: GitHubWebhook = { const payload: GitHubWebhook = {
@@ -87,6 +88,7 @@ describe('GitHub Pull Request Transformer', () => {
expect(result).not.toBeNull(); expect(result).not.toBeNull();
expect(result?.title).toContain('Pull request reopened'); expect(result?.title).toContain('Pull request reopened');
expect(result?.color).toBe(0xfcbd1f); expect(result?.color).toBe(0xfcbd1f);
expect(result?.author?.name).toBe('testuser');
}); });
it('returns null for unsupported action types', async () => { it('returns null for unsupported action types', async () => {
const payload: GitHubWebhook = { const payload: GitHubWebhook = {
@@ -14,9 +14,9 @@ export async function transformPullRequest(body: GitHubWebhook): Promise<RichEmb
if (!(body.pull_request && body.action && body.repository)) { if (!(body.pull_request && body.action && body.repository)) {
return null; return null;
} }
const authorIconUrl = body.pull_request.user.avatar_url; const authorIconUrl = body.sender.avatar_url;
const authorName = body.pull_request.user.login; const authorName = body.sender.login;
const authorUrl = body.pull_request.user.html_url; const authorUrl = body.sender.html_url;
const repoName = body.repository.full_name; const repoName = body.repository.full_name;
const prNumber = body.pull_request.number; const prNumber = body.pull_request.number;
const prTitle = body.pull_request.title; const prTitle = body.pull_request.title;