Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
integrations/github: Add fixtures for issue edited events.
Pritesh-300b48eee81605
diff --git a/zerver/webhooks/github/fixtures/issues__edited_body.json b/zerver/webhooks/github/fixtures/issues__edited_body.jsonnew file mode 100644index 00000000000..5c31242f492--- /dev/null+++ b/zerver/webhooks/github/fixtures/issues__edited_body.json@@ -0,0 +1,202 @@+{+ "action": "edited",+ "issue": {+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6",+ "repository_url": "https://api.github.com/repos/Pritesh-30/test-repo",+ "labels_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/labels{/name}",+ "comments_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/comments",+ "events_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/events",+ "html_url": "https://github.com/Pritesh-30/test-repo/issues/6",+ "id": 3779542785,+ "node_id": "I_kwDOQwktts7hRz8B",+ "number": 6,+ "title": "New Issue edited",+ "user": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ },+ "labels": [],+ "state": "open",+ "locked": false,+ "assignee": null,+ "assignees": [],+ "milestone": null,+ "comments": 0,+ "created_at": "2026-01-04T19:02:47Z",+ "updated_at": "2026-01-17T11:36:36Z",+ "closed_at": null,+ "author_association": "OWNER",+ "active_lock_reason": null,+ "sub_issues_summary": {+ "total": 0,+ "completed": 0,+ "percent_completed": 0+ },+ "issue_dependencies_summary": {+ "blocked_by": 0,+ "total_blocked_by": 0,+ "blocking": 0,+ "total_blocking": 0+ },+ "body": "The body of the issue is edited.",+ "reactions": {+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/reactions",+ "total_count": 0,+ "+1": 0,+ "-1": 0,+ "laugh": 0,+ "hooray": 0,+ "confused": 0,+ "heart": 0,+ "rocket": 0,+ "eyes": 0+ },+ "timeline_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/timeline",+ "performed_via_github_app": null,+ "state_reason": null+ },+ "changes": {+ "body": {+ "from": "The body of the issue is edited"+ }+ },+ "repository": {+ "id": 1124674998,+ "node_id": "R_kgDOQwkttg",+ "name": "test-repo",+ "full_name": "Pritesh-30/test-repo",+ "private": false,+ "owner": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ },+ "html_url": "https://github.com/Pritesh-30/test-repo",+ "description": null,+ "fork": false,+ "url": "https://api.github.com/repos/Pritesh-30/test-repo",+ "forks_url": "https://api.github.com/repos/Pritesh-30/test-repo/forks",+ "keys_url": "https://api.github.com/repos/Pritesh-30/test-repo/keys{/key_id}",+ "collaborators_url": "https://api.github.com/repos/Pritesh-30/test-repo/collaborators{/collaborator}",+ "teams_url": "https://api.github.com/repos/Pritesh-30/test-repo/teams",+ "hooks_url": "https://api.github.com/repos/Pritesh-30/test-repo/hooks",+ "issue_events_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/events{/number}",+ "events_url": "https://api.github.com/repos/Pritesh-30/test-repo/events",+ "assignees_url": "https://api.github.com/repos/Pritesh-30/test-repo/assignees{/user}",+ "branches_url": "https://api.github.com/repos/Pritesh-30/test-repo/branches{/branch}",+ "tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/tags",+ "blobs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/blobs{/sha}",+ "git_tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/tags{/sha}",+ "git_refs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/refs{/sha}",+ "trees_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/trees{/sha}",+ "statuses_url": "https://api.github.com/repos/Pritesh-30/test-repo/statuses/{sha}",+ "languages_url": "https://api.github.com/repos/Pritesh-30/test-repo/languages",+ "stargazers_url": "https://api.github.com/repos/Pritesh-30/test-repo/stargazers",+ "contributors_url": "https://api.github.com/repos/Pritesh-30/test-repo/contributors",+ "subscribers_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscribers",+ "subscription_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscription",+ "commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/commits{/sha}",+ "git_commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/commits{/sha}",+ "comments_url": "https://api.github.com/repos/Pritesh-30/test-repo/comments{/number}",+ "issue_comment_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/comments{/number}",+ "contents_url": "https://api.github.com/repos/Pritesh-30/test-repo/contents/{+path}",+ "compare_url": "https://api.github.com/repos/Pritesh-30/test-repo/compare/{base}...{head}",+ "merges_url": "https://api.github.com/repos/Pritesh-30/test-repo/merges",+ "archive_url": "https://api.github.com/repos/Pritesh-30/test-repo/{archive_format}{/ref}",+ "downloads_url": "https://api.github.com/repos/Pritesh-30/test-repo/downloads",+ "issues_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues{/number}",+ "pulls_url": "https://api.github.com/repos/Pritesh-30/test-repo/pulls{/number}",+ "milestones_url": "https://api.github.com/repos/Pritesh-30/test-repo/milestones{/number}",+ "notifications_url": "https://api.github.com/repos/Pritesh-30/test-repo/notifications{?since,all,participating}",+ "labels_url": "https://api.github.com/repos/Pritesh-30/test-repo/labels{/name}",+ "releases_url": "https://api.github.com/repos/Pritesh-30/test-repo/releases{/id}",+ "deployments_url": "https://api.github.com/repos/Pritesh-30/test-repo/deployments",+ "created_at": "2025-12-29T12:22:21Z",+ "updated_at": "2026-01-04T19:06:22Z",+ "pushed_at": "2026-01-04T19:06:51Z",+ "git_url": "git://github.com/Pritesh-30/test-repo.git",+ "ssh_url": "[email protected]:Pritesh-30/test-repo.git",+ "clone_url": "https://github.com/Pritesh-30/test-repo.git",+ "svn_url": "https://github.com/Pritesh-30/test-repo",+ "homepage": null,+ "size": 1,+ "stargazers_count": 0,+ "watchers_count": 0,+ "language": "CSS",+ "has_issues": true,+ "has_projects": true,+ "has_downloads": true,+ "has_wiki": true,+ "has_pages": false,+ "has_discussions": false,+ "forks_count": 0,+ "mirror_url": null,+ "archived": false,+ "disabled": false,+ "open_issues_count": 7,+ "license": null,+ "allow_forking": true,+ "is_template": false,+ "web_commit_signoff_required": false,+ "topics": [],+ "visibility": "public",+ "forks": 0,+ "open_issues": 7,+ "watchers": 0,+ "default_branch": "feature"+ },+ "sender": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ }+}diff --git a/zerver/webhooks/github/fixtures/issues__edited_title.json b/zerver/webhooks/github/fixtures/issues__edited_title.jsonnew file mode 100644index 00000000000..a4a385b32e9--- /dev/null+++ b/zerver/webhooks/github/fixtures/issues__edited_title.json@@ -0,0 +1,205 @@+{+ "action": "edited",+ "issue": {+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6",+ "repository_url": "https://api.github.com/repos/Pritesh-30/test-repo",+ "labels_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/labels{/name}",+ "comments_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/comments",+ "events_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/events",+ "html_url": "https://github.com/Pritesh-30/test-repo/issues/6",+ "id": 3779542785,+ "node_id": "I_kwDOQwktts7hRz8B",+ "number": 6,+ "title": "This is a very long issue title used to exceed Zulip's maximum topic length so that truncation logic is exercised when the issue title is edited via the GitHub webhook",+ "user": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ },+ "labels": [],+ "state": "open",+ "locked": false,+ "assignee": null,+ "assignees": [],+ "milestone": null,+ "comments": 0,+ "created_at": "2026-01-04T19:02:47Z",+ "updated_at": "2026-01-17T19:24:53Z",+ "closed_at": null,+ "author_association": "OWNER",+ "active_lock_reason": null,+ "sub_issues_summary": {+ "total": 0,+ "completed": 0,+ "percent_completed": 0+ },+ "issue_dependencies_summary": {+ "blocked_by": 0,+ "total_blocked_by": 0,+ "blocking": 0,+ "total_blocking": 0+ },+ "body": "The body of the issue is edited.",+ "reactions": {+ "url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/reactions",+ "total_count": 0,+ "+1": 0,+ "-1": 0,+ "laugh": 0,+ "hooray": 0,+ "confused": 0,+ "heart": 0,+ "rocket": 0,+ "eyes": 0+ },+ "timeline_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/6/timeline",+ "performed_via_github_app": null,+ "state_reason": null+ },+ "changes": {+ "body": {+ "from": ""+ },+ "title": {+ "from": "New Issue edited"+ }+ },+ "repository": {+ "id": 1124674998,+ "node_id": "R_kgDOQwkttg",+ "name": "test-repo",+ "full_name": "Pritesh-30/test-repo",+ "private": false,+ "owner": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ },+ "html_url": "https://github.com/Pritesh-30/test-repo",+ "description": null,+ "fork": false,+ "url": "https://api.github.com/repos/Pritesh-30/test-repo",+ "forks_url": "https://api.github.com/repos/Pritesh-30/test-repo/forks",+ "keys_url": "https://api.github.com/repos/Pritesh-30/test-repo/keys{/key_id}",+ "collaborators_url": "https://api.github.com/repos/Pritesh-30/test-repo/collaborators{/collaborator}",+ "teams_url": "https://api.github.com/repos/Pritesh-30/test-repo/teams",+ "hooks_url": "https://api.github.com/repos/Pritesh-30/test-repo/hooks",+ "issue_events_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/events{/number}",+ "events_url": "https://api.github.com/repos/Pritesh-30/test-repo/events",+ "assignees_url": "https://api.github.com/repos/Pritesh-30/test-repo/assignees{/user}",+ "branches_url": "https://api.github.com/repos/Pritesh-30/test-repo/branches{/branch}",+ "tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/tags",+ "blobs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/blobs{/sha}",+ "git_tags_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/tags{/sha}",+ "git_refs_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/refs{/sha}",+ "trees_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/trees{/sha}",+ "statuses_url": "https://api.github.com/repos/Pritesh-30/test-repo/statuses/{sha}",+ "languages_url": "https://api.github.com/repos/Pritesh-30/test-repo/languages",+ "stargazers_url": "https://api.github.com/repos/Pritesh-30/test-repo/stargazers",+ "contributors_url": "https://api.github.com/repos/Pritesh-30/test-repo/contributors",+ "subscribers_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscribers",+ "subscription_url": "https://api.github.com/repos/Pritesh-30/test-repo/subscription",+ "commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/commits{/sha}",+ "git_commits_url": "https://api.github.com/repos/Pritesh-30/test-repo/git/commits{/sha}",+ "comments_url": "https://api.github.com/repos/Pritesh-30/test-repo/comments{/number}",+ "issue_comment_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues/comments{/number}",+ "contents_url": "https://api.github.com/repos/Pritesh-30/test-repo/contents/{+path}",+ "compare_url": "https://api.github.com/repos/Pritesh-30/test-repo/compare/{base}...{head}",+ "merges_url": "https://api.github.com/repos/Pritesh-30/test-repo/merges",+ "archive_url": "https://api.github.com/repos/Pritesh-30/test-repo/{archive_format}{/ref}",+ "downloads_url": "https://api.github.com/repos/Pritesh-30/test-repo/downloads",+ "issues_url": "https://api.github.com/repos/Pritesh-30/test-repo/issues{/number}",+ "pulls_url": "https://api.github.com/repos/Pritesh-30/test-repo/pulls{/number}",+ "milestones_url": "https://api.github.com/repos/Pritesh-30/test-repo/milestones{/number}",+ "notifications_url": "https://api.github.com/repos/Pritesh-30/test-repo/notifications{?since,all,participating}",+ "labels_url": "https://api.github.com/repos/Pritesh-30/test-repo/labels{/name}",+ "releases_url": "https://api.github.com/repos/Pritesh-30/test-repo/releases{/id}",+ "deployments_url": "https://api.github.com/repos/Pritesh-30/test-repo/deployments",+ "created_at": "2025-12-29T12:22:21Z",+ "updated_at": "2026-01-04T19:06:22Z",+ "pushed_at": "2026-01-04T19:06:51Z",+ "git_url": "git://github.com/Pritesh-30/test-repo.git",+ "ssh_url": "[email protected]:Pritesh-30/test-repo.git",+ "clone_url": "https://github.com/Pritesh-30/test-repo.git",+ "svn_url": "https://github.com/Pritesh-30/test-repo",+ "homepage": null,+ "size": 1,+ "stargazers_count": 0,+ "watchers_count": 0,+ "language": "CSS",+ "has_issues": true,+ "has_projects": true,+ "has_downloads": true,+ "has_wiki": true,+ "has_pages": false,+ "has_discussions": false,+ "forks_count": 0,+ "mirror_url": null,+ "archived": false,+ "disabled": false,+ "open_issues_count": 7,+ "license": null,+ "allow_forking": true,+ "is_template": false,+ "web_commit_signoff_required": false,+ "topics": [],+ "visibility": "public",+ "forks": 0,+ "open_issues": 7,+ "watchers": 0,+ "default_branch": "feature"+ },+ "sender": {+ "login": "Pritesh-30",+ "id": 190011583,+ "node_id": "U_kgDOC1NYvw",+ "avatar_url": "https://avatars.githubusercontent.com/u/190011583?v=4",+ "gravatar_id": "",+ "url": "https://api.github.com/users/Pritesh-30",+ "html_url": "https://github.com/Pritesh-30",+ "followers_url": "https://api.github.com/users/Pritesh-30/followers",+ "following_url": "https://api.github.com/users/Pritesh-30/following{/other_user}",+ "gists_url": "https://api.github.com/users/Pritesh-30/gists{/gist_id}",+ "starred_url": "https://api.github.com/users/Pritesh-30/starred{/owner}{/repo}",+ "subscriptions_url": "https://api.github.com/users/Pritesh-30/subscriptions",+ "organizations_url": "https://api.github.com/users/Pritesh-30/orgs",+ "repos_url": "https://api.github.com/users/Pritesh-30/repos",+ "events_url": "https://api.github.com/users/Pritesh-30/events{/privacy}",+ "received_events_url": "https://api.github.com/users/Pritesh-30/received_events",+ "type": "User",+ "user_view_type": "public",+ "site_admin": false+ }+}diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex e88579662b9..c7302b7582a 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -2,6 +2,7 @@ from unittest.mock import patchimport orjson+from zerver.lib.message import truncate_topicfrom zerver.lib.test_classes import WebhookTestCasefrom zerver.lib.webhooks.git import COMMITS_LIMIT@@ -149,6 +150,17 @@ class GitHubWebhookTest(WebhookTestCase):expected_message = "baxterandthehackers forked [public-repo](https://github.com/baxterandthehackers/public-repo)."self.check_webhook("fork", TOPIC_REPO, expected_message)+ def test_issues_edited_body(self) -> None:+ expected_topic_name = "test-repo / issue #6 New Issue edited"+ expected_message = "Pritesh-30 edited [issue #6](https://github.com/Pritesh-30/test-repo/issues/6):\n\n~~~ quote\nThe body of the issue is edited.\n~~~"+ self.check_webhook("issues__edited_body", expected_topic_name, expected_message)++ def test_issues_edited_title(self) -> None:+ long_title = "This is a very long issue title used to exceed Zulip's maximum topic length so that truncation logic is exercised when the issue title is edited via the GitHub webhook"+ expected_topic_name = truncate_topic(f"test-repo / issue #6 {long_title}")+ expected_message = "Pritesh-30 edited [issue #6](https://github.com/Pritesh-30/test-repo/issues/6):\n\n~~~ quote\nThe body of the issue is edited.\n~~~"+ self.check_webhook("issues__edited_title", expected_topic_name, expected_message)+def test_issue_comment_msg(self) -> None:expected_message = "baxterthehacker [commented](https://github.com/baxterthehacker/public-repo/issues/2#issuecomment-99262140) on [issue #2](https://github.com/baxterthehacker/public-repo/issues/2):\n\n~~~ quote\nYou are totally right! I'll get this fixed right away.\n~~~"self.check_webhook("issue_comment", TOPIC_ISSUE, expected_message)