Skip to content

Commit 7ca60e3

Browse files
grichaclaude
andcommitted
test(integrations): Add ViewerContext test for Jira Server webhook
Verify that webhook_viewer_context sets the correct organization_id and actor_type during status change processing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 723dd2d commit 7ca60e3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/sentry/integrations/jira_server/test_webhooks.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
from sentry.integrations.services.integration.serial import serialize_integration
1010
from sentry.silo.base import SiloMode
1111
from sentry.testutils.cases import APITestCase
12+
from sentry.testutils.helpers.options import override_options
1213
from sentry.testutils.silo import assume_test_silo_mode
14+
from sentry.viewer_context import ActorType, get_viewer_context
1315

1416
from . import EXAMPLE_PAYLOAD, get_integration, link_group
1517

@@ -94,6 +96,27 @@ def test_post_update_status(self, mock_sync: MagicMock) -> None:
9496
},
9597
)
9698

99+
@override_options({"viewer-context.enabled": True})
100+
@patch.object(JiraServerIntegration, "sync_status_inbound")
101+
def test_post_update_status_sets_viewer_context(self, mock_sync: MagicMock) -> None:
102+
captured_contexts: list = []
103+
104+
def capture_context(*args: object, **kwargs: object) -> None:
105+
captured_contexts.append(get_viewer_context())
106+
107+
mock_sync.side_effect = capture_context
108+
109+
project = self.create_project()
110+
self.create_group(project=project)
111+
112+
self.get_success_response(self.jwt_token, **EXAMPLE_PAYLOAD)
113+
114+
assert len(captured_contexts) == 1
115+
vc = captured_contexts[0]
116+
assert vc is not None
117+
assert vc.organization_id == self.organization.id
118+
assert vc.actor_type == ActorType.INTEGRATION
119+
97120
@responses.activate
98121
def test_post_update_status_token_error(self) -> None:
99122
responses.add(

0 commit comments

Comments
 (0)