Skip to content

Commit 24c17a5

Browse files
authored
Merge pull request #7284 from akatsoulas/zd-segmentation-tags
Add segmentation tags for Enterprise
2 parents 5638a1e + 94b052a commit 24c17a5

File tree

3 files changed

+112
-1
lines changed

3 files changed

+112
-1
lines changed

kitsune/customercare/forms.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@
4242
("not_sure", "Not sure / Need help selecting"),
4343
]
4444

45+
UPDATE_CHANNEL_TAGS = {
46+
"esr": "seg-rel-esr",
47+
"rapid_release": "seg-rel-rapid-release",
48+
"full_release": "seg-rel-full-release",
49+
"beta": "seg-rel-beta",
50+
"other": "seg-rel-channel-other",
51+
}
52+
53+
POLICY_DISTRIBUTION_TAGS = {
54+
"group_policy_admx": "seg-policy-windows-gpo",
55+
"windows_mdm": "seg-policy-windows-mdm",
56+
"macos_config_profiles": "seg-policy-macos-config-profiles",
57+
"policies_json": "seg-policy-json",
58+
"autoconfig": "seg-policy-autoconfig",
59+
"not_sure": "seg-policy-dist-other",
60+
}
61+
4562
ZENDESK_PRODUCT_SLUGS = {v: k for k, v in PRODUCT_SLUG_ALIASES.items()}
4663

4764

@@ -178,6 +195,14 @@ def send(self, user, product):
178195
else:
179196
zendesk_tags.append(tag_value)
180197

198+
if update_channel := self.cleaned_data.get("update_channel"):
199+
if tag := UPDATE_CHANNEL_TAGS.get(update_channel):
200+
zendesk_tags.append(tag)
201+
202+
if policy_distribution := self.cleaned_data.get("policy_distribution"):
203+
if tag := POLICY_DISTRIBUTION_TAGS.get(policy_distribution):
204+
zendesk_tags.append(tag)
205+
181206
if settings.STAGE:
182207
zendesk_tags.append("stage")
183208

kitsune/customercare/tests/test_forms.py

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
from django.contrib.auth.models import AnonymousUser
44

5-
from kitsune.customercare.forms import ZendeskForm
5+
from kitsune.customercare.forms import (
6+
POLICY_DISTRIBUTION_TAGS,
7+
UPDATE_CHANNEL_TAGS,
8+
ZendeskForm,
9+
)
610
from kitsune.customercare.models import SupportTicket
711
from kitsune.products.tests import (
812
ProductFactory,
@@ -512,3 +516,72 @@ def test_send_stores_deployment_fields(self, mock_task):
512516
self.assertEqual(submission.update_channel, "esr")
513517
self.assertEqual(submission.policy_distribution, "group_policy_admx")
514518
mock_task.assert_called_once_with(submission.id)
519+
520+
@patch("kitsune.customercare.tasks.zendesk_submission_classifier.delay")
521+
def test_send_appends_update_channel_segmentation_tag(self, mock_task):
522+
"""Test that update_channel value is mapped to its segmentation tag."""
523+
self.vpn_zendesk.enable_deployment_fields = True
524+
self.vpn_zendesk.save()
525+
526+
for channel, expected_tag in UPDATE_CHANNEL_TAGS.items():
527+
with self.subTest(channel=channel):
528+
form = ZendeskForm(
529+
data={
530+
"email": "test@example.com",
531+
"category": "vpn-connection-issues",
532+
"subject": "Test subject",
533+
"description": "Test description",
534+
"update_channel": channel,
535+
"policy_distribution": "group_policy_admx",
536+
},
537+
product=self.vpn_product,
538+
user=self.user,
539+
)
540+
self.assertTrue(form.is_valid())
541+
submission = form.send(self.user, self.vpn_product)
542+
self.assertIn(expected_tag, submission.zendesk_tags)
543+
544+
@patch("kitsune.customercare.tasks.zendesk_submission_classifier.delay")
545+
def test_send_appends_policy_distribution_segmentation_tag(self, mock_task):
546+
"""Test that policy_distribution value is mapped to its segmentation tag."""
547+
self.vpn_zendesk.enable_deployment_fields = True
548+
self.vpn_zendesk.save()
549+
550+
for distribution, expected_tag in POLICY_DISTRIBUTION_TAGS.items():
551+
with self.subTest(distribution=distribution):
552+
form = ZendeskForm(
553+
data={
554+
"email": "test@example.com",
555+
"category": "vpn-connection-issues",
556+
"subject": "Test subject",
557+
"description": "Test description",
558+
"update_channel": "esr",
559+
"policy_distribution": distribution,
560+
},
561+
product=self.vpn_product,
562+
user=self.user,
563+
)
564+
self.assertTrue(form.is_valid())
565+
submission = form.send(self.user, self.vpn_product)
566+
self.assertIn(expected_tag, submission.zendesk_tags)
567+
568+
@patch("kitsune.customercare.tasks.zendesk_submission_classifier.delay")
569+
def test_send_no_deployment_tags_when_fields_empty(self, mock_task):
570+
"""Test that no deployment segmentation tags are added when fields are empty."""
571+
form = ZendeskForm(
572+
data={
573+
"email": "test@example.com",
574+
"category": "vpn-connection-issues",
575+
"subject": "Test subject",
576+
"description": "Test description",
577+
},
578+
product=self.vpn_product,
579+
user=self.user,
580+
)
581+
self.assertTrue(form.is_valid())
582+
submission = form.send(self.user, self.vpn_product)
583+
584+
for tag in UPDATE_CHANNEL_TAGS.values():
585+
self.assertNotIn(tag, submission.zendesk_tags)
586+
for tag in POLICY_DISTRIBUTION_TAGS.values():
587+
self.assertNotIn(tag, submission.zendesk_tags)

kitsune/tags/migrations/0002_auto_20241115_0241.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@
180180
("VPN::Unsupported::No OS Named", "seg-vpn-unsup-none"),
181181
("VPN::Unsupported::Hardware", "seg-vpn-unsup-hrdware"),
182182
("VPN::Unsupported::Windows", "seg-vpn-unsup-win"),
183+
# Update Channel segmentation tags
184+
("Release channel: ESR", "seg-rel-esr"),
185+
("Release channel: Rapid Release", "seg-rel-rapid-release"),
186+
("Release channel: Full Release", "seg-rel-full-release"),
187+
("Release channel: Beta", "seg-rel-beta"),
188+
("Release channel: Other", "seg-rel-channel-other"),
189+
# Policy Distribution segmentation tags
190+
("Policy distribution: Windows Group Policy (ADMX)", "seg-policy-windows-gpo"),
191+
("Policy distribution: Windows MDM", "seg-policy-windows-mdm"),
192+
("Policy distribution: macOS Configuration Profiles", "seg-policy-macos-config-profiles"),
193+
("Policy distribution: policies.json", "seg-policy-json"),
194+
("Policy distribution: Autoconfig", "seg-policy-autoconfig"),
195+
("Policy distribution: Not sure / Need help selecting", "seg-policy-dist-other"),
183196
]
184197

185198

0 commit comments

Comments
 (0)