Repository: getsentry/sentry

Issue:
Change Slack Linked Team Message
Right now when we link a team to a Slack channel we get the message "<Team> will now receive issue alert notifications ...".
Change it to "<Team> will now receive issue alert and workflow notifications ..." (behind the feature flag)

<img width="746" alt="Screenshot 2023-10-25 at 8 55 42 AM" src="https://github.com/getsentry/sentry/assets/116035587/5f81ab16-b889-43aa-ab82-f74f00cc157f">
<img width="606" alt="Screenshot 2023-10-26 at 10 02 18 AM" src="https://github.com/getsentry/sentry/assets/116035587/c8819e04-062f-443a-b4f8-5c597240b7b4">



Discussion:

Resolving patch:
diff --git a/src/sentry/integrations/slack/views/link_team.py b/src/sentry/integrations/slack/views/link_team.py
--- a/src/sentry/integrations/slack/views/link_team.py
+++ b/src/sentry/integrations/slack/views/link_team.py
@@ -8,7 +8,7 @@
 from django.utils.decorators import method_decorator
 from rest_framework.request import Request
 
-from sentry import analytics
+from sentry import analytics, features
 from sentry.models.integrations.external_actor import ExternalActor
 from sentry.models.integrations.integration import Integration
 from sentry.models.organizationmember import OrganizationMember
@@ -33,9 +33,7 @@
 ALREADY_LINKED_TITLE = "Already linked"
 ALREADY_LINKED_MESSAGE = "The {slug} team has already been linked to a Slack channel."
 SUCCESS_LINKED_TITLE = "Team linked"
-SUCCESS_LINKED_MESSAGE = (
-    "The {slug} team will now receive issue alert notifications in the {channel_name} channel."
-)
+SUCCESS_LINKED_MESSAGE = "The {slug} team will now receive issue alert{workflow_addon} notifications in the {channel_name} channel."
 
 
 def build_team_linking_url(
@@ -202,7 +200,13 @@ def handle(self, request: Request, signed_params: str) -> HttpResponse:
             actor=RpcActor(id=team.id, actor_type=ActorType.TEAM),
             organization_id_for_team=team.organization_id,
         )
-        message = SUCCESS_LINKED_MESSAGE.format(slug=team.slug, channel_name=channel_name)
+        message = SUCCESS_LINKED_MESSAGE.format(
+            slug=team.slug,
+            workflow_addon=" and workflow"
+            if features.has("organizations:team-workflow-notifications", team.organization)
+            else "",
+            channel_name=channel_name,
+        )
         integration_service.send_message(
             integration_id=integration.id,
             organization_id=team.organization_id,


Test patch:
diff --git a/tests/sentry/integrations/slack/test_link_team.py b/tests/sentry/integrations/slack/test_link_team.py
--- a/tests/sentry/integrations/slack/test_link_team.py
+++ b/tests/sentry/integrations/slack/test_link_team.py
@@ -17,6 +17,7 @@
 from sentry.silo import SiloMode
 from sentry.testutils.cases import TestCase
 from sentry.testutils.helpers import add_identity, get_response_text, install_slack, link_team
+from sentry.testutils.helpers.features import with_feature
 from sentry.testutils.silo import assume_test_silo_mode, region_silo_test
 from sentry.types.integrations import ExternalProviders
 from sentry.utils import json
@@ -228,6 +229,19 @@ def test_link_team_multiple_organizations(self):
             )
             assert len(external_actors) == 1
 
+    @responses.activate
+    @with_feature("organizations:team-workflow-notifications")
+    def test_message_includes_workflow(self):
+        self.get_success_response(data={"team": self.team.id})
+        external_actors = self.get_linked_teams()
+
+        assert len(responses.calls) >= 1
+        data = json.loads(str(responses.calls[0].request.body.decode("utf-8")))
+        assert (
+            f"The {self.team.slug} team will now receive issue alert and workflow notifications in the {external_actors[0].external_name} channel."
+            in get_response_text(data)
+        )
+
 
 @region_silo_test(stable=True)
 class SlackIntegrationUnlinkTeamTest(SlackIntegrationLinkTeamTestBase):