Skip to content

Commit ac86178

Browse files
committed
Cleanup ZD topics and obsolete code
1 parent 2a3f1c5 commit ac86178

7 files changed

Lines changed: 327 additions & 310 deletions

File tree

kitsune/customercare/__init__.py

Lines changed: 0 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -1,252 +0,0 @@
1-
from typing import TypedDict
2-
3-
4-
class TagsDict(TypedDict):
5-
legacy: str
6-
tiers: list[str]
7-
automation: str | None
8-
segmentation: str | None
9-
10-
11-
class CategoryDict(TypedDict):
12-
slug: str
13-
topic: str
14-
tags: TagsDict
15-
16-
17-
BASE_CATEGORIES: dict[str, CategoryDict] = {
18-
"payments": {
19-
"slug": "payments",
20-
"topic": "I need help with a billing or subscription question",
21-
"tags": {
22-
"legacy": "payments",
23-
"tiers": ["t1-billing-and-subscriptions"],
24-
"automation": None,
25-
"segmentation": None,
26-
},
27-
},
28-
"accounts_signin": {
29-
"slug": "account-signin",
30-
"topic": "I can't sign in to my Mozilla account or subscription",
31-
"tags": {
32-
"legacy": "accounts",
33-
"tiers": ["t1-passwords-and-sign-in", "t2-sign-in", "t3-sign-in-failure"],
34-
"automation": "ssa-sign-in-failure-automation",
35-
"segmentation": None,
36-
},
37-
},
38-
"general": {
39-
"slug": "general",
40-
"topic": "I want to share feedback or suggest a feature",
41-
"tags": {
42-
"legacy": "general",
43-
"tiers": ["general"],
44-
"automation": None,
45-
"segmentation": None,
46-
},
47-
},
48-
"not_listed": {
49-
"slug": "not-listed",
50-
"topic": "My issue isn't listed here",
51-
"tags": {
52-
"legacy": "not_listed",
53-
"tiers": ["not_listed"],
54-
"automation": None,
55-
"segmentation": None,
56-
},
57-
},
58-
}
59-
60-
ZENDESK_CATEGORIES = {
61-
"mozilla-vpn": [
62-
{
63-
"slug": "vpn-connection-issues",
64-
"topic": "I can't connect to Mozilla VPN",
65-
"tags": {
66-
"legacy": "technical",
67-
"tiers": [
68-
"t1-performance-and-connectivity",
69-
"t2-connectivity",
70-
"t3-connection-failure",
71-
],
72-
"automation": "ssa-connection-issues-automation",
73-
"segmentation": None,
74-
},
75-
},
76-
{
77-
"slug": "vpn-installation-updates",
78-
"topic": "I need help installing or updating Mozilla VPN",
79-
"tags": {
80-
"legacy": "technical",
81-
"tiers": ["t1-installation-and-updates"],
82-
"automation": None,
83-
"segmentation": None,
84-
},
85-
},
86-
{
87-
"slug": "vpn-server-selection",
88-
"topic": "I can't choose a VPN location",
89-
"tags": {
90-
"legacy": "technical",
91-
"tiers": [
92-
"t1-performance-and-connectivity",
93-
"t2-connectivity",
94-
"t3-cant-select-server",
95-
],
96-
"automation": None,
97-
"segmentation": None,
98-
},
99-
},
100-
*BASE_CATEGORIES.values(),
101-
],
102-
"relay": [
103-
{
104-
"slug": "relay-email-forwarding",
105-
"topic": "I'm not receiving emails to my Relay mask",
106-
"tags": {
107-
"legacy": "technical",
108-
"tiers": ["t1-privacy-and-security", "t2-masking", "t3-email-masking"],
109-
"automation": None,
110-
"segmentation": "seg-relay-no-fwd-deliver",
111-
},
112-
},
113-
{
114-
"slug": "relay-domain-change",
115-
"topic": "I want to change my Relay email domain",
116-
"tags": {
117-
"legacy": "technical",
118-
"tiers": ["t1-privacy-and-security", "t2-masking", "t3-email-masking"],
119-
"automation": None,
120-
"segmentation": "seg-relay-chg-domain",
121-
},
122-
},
123-
*BASE_CATEGORIES.values(),
124-
],
125-
"pocket": [
126-
BASE_CATEGORIES["not_listed"],
127-
BASE_CATEGORIES["accounts_signin"],
128-
],
129-
"mozilla-account": [
130-
{
131-
"slug": "mozilla-account-sync",
132-
"topic": "I need help with Firefox Sync",
133-
"tags": {
134-
"legacy": "accounts",
135-
"tiers": ["t1-backup-recovery-and-sync"],
136-
"automation": "ssa-sync-data-automation",
137-
"segmentation": None,
138-
},
139-
},
140-
{
141-
"slug": "mozilla-account-delete",
142-
"topic": "I want to delete my Mozilla account",
143-
"tags": {
144-
"legacy": "accounts",
145-
"tiers": ["t1-accounts", "t2-account-management"],
146-
"automation": None,
147-
"segmentation": "seg-acct-delete",
148-
},
149-
},
150-
*BASE_CATEGORIES.values(),
151-
],
152-
"monitor": [
153-
{
154-
"slug": "monitor-data-removal",
155-
"topic": "My data removal is taking too long",
156-
"tags": {
157-
"legacy": "technical",
158-
"tiers": ["t1-privacy-and-security", "t2-data-removal", "t3-data-brokers"],
159-
"automation": None,
160-
"segmentation": "seg-mntor-slow-remove",
161-
},
162-
},
163-
{
164-
"slug": "monitor-wrong-results",
165-
"topic": "I'm seeing results that don't belong to me",
166-
"tags": {
167-
"legacy": "technical",
168-
"tiers": [
169-
"t1-privacy-and-security",
170-
"t2-data-removal",
171-
"t3-privacy-protection-scan",
172-
],
173-
"automation": None,
174-
"segmentation": "seg-mntor-wrong-scan-result",
175-
},
176-
},
177-
*BASE_CATEGORIES.values(),
178-
],
179-
"mdn-plus": [
180-
*BASE_CATEGORIES.values(),
181-
],
182-
}
183-
184-
ZENDESK_CATEGORIES_LOGINLESS = {
185-
"mozilla-account": [
186-
{
187-
"slug": "fxa-2fa-lockout",
188-
"topic": "My security code isn't working or is lost",
189-
"tags": {
190-
"legacy": "accounts",
191-
"tiers": [
192-
"t1-passwords-and-sign-in",
193-
"t2-two-factor-authentication",
194-
"t3-two-factor-lockout",
195-
],
196-
"automation": "ssa-2fa-automation",
197-
"segmentation": None,
198-
},
199-
},
200-
{
201-
"slug": "fxa-emailverify-lockout",
202-
"topic": "I can't recover my account using email",
203-
"tags": {
204-
"legacy": "accounts",
205-
"tiers": ["t1-passwords-and-sign-in", "t2-sign-in", "t3-email-verify-lockout"],
206-
"automation": "ssa-pwrdreset-automation",
207-
"segmentation": None,
208-
},
209-
},
210-
{
211-
"slug": "fxa-reset-password",
212-
"topic": "I forgot my password",
213-
"tags": {
214-
"legacy": "accounts",
215-
"tiers": ["t1-passwords-and-sign-in", "t2-reset-passwords"],
216-
"automation": "ssa-emailverify-automation",
217-
"segmentation": None,
218-
},
219-
},
220-
{
221-
"slug": "fxa-remove3rdprtylogin",
222-
"topic": "I'm having issues signing in with my Google or Apple ID",
223-
"tags": {
224-
"legacy": "accounts",
225-
"tiers": ["t1-passwords-and-sign-in", "t2-sign-in", "t3-3rd-party-sign-in"],
226-
"automation": None,
227-
"segmentation": None,
228-
},
229-
},
230-
]
231-
}
232-
233-
234-
ZENDESK_LEGACY_MAPPING: dict[str, set] = {
235-
"accounts": {
236-
"t1-accounts",
237-
"t1-passwords-and-sign-in",
238-
},
239-
"technical": {
240-
"t1-accessibility",
241-
"t1-backup-recovery-and-sync",
242-
"t1-browse",
243-
"t1-download-and-save",
244-
"t1-email-and-messaging",
245-
"t1-installation-and-updates",
246-
"t1-performance-and-connectivity",
247-
"t1-privacy-and-security",
248-
"t1-search-tag-and-share",
249-
"t1-settings",
250-
},
251-
"payment": {"t1-billing-and-subscriptions"},
252-
}

kitsune/customercare/tests/test_utils.py

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
generate_classification_tags,
99
send_support_ticket_to_zendesk,
1010
)
11-
from kitsune.products.tests import ProductFactory, TopicFactory
11+
from kitsune.products.tests import (
12+
ProductFactory,
13+
ProductSupportConfigFactory,
14+
TopicFactory,
15+
ZendeskConfigFactory,
16+
ZendeskTopicConfigurationFactory,
17+
ZendeskTopicFactory,
18+
)
1219
from kitsune.sumo.tests import TestCase
1320

1421

@@ -86,7 +93,7 @@ def test_single_tier_topic(self):
8693

8794
tags = generate_classification_tags(submission, result)
8895

89-
self.assertEqual(tags, ["t1-settings", "technical"])
96+
self.assertEqual(tags, ["t1-settings", "general"])
9097

9198
def test_two_tier_topic(self):
9299
"""Test generating tags for a tier 2 topic."""
@@ -100,7 +107,7 @@ def test_two_tier_topic(self):
100107

101108
tags = generate_classification_tags(submission, result)
102109

103-
self.assertEqual(tags, ["t1-settings", "t2-notifications", "technical"])
110+
self.assertEqual(tags, ["t1-settings", "t2-notifications", "general"])
104111

105112
def test_three_tier_topic(self):
106113
"""Test generating tags for a tier 3 topic."""
@@ -119,27 +126,32 @@ def test_three_tier_topic(self):
119126
tags = generate_classification_tags(submission, result)
120127

121128
self.assertEqual(
122-
tags, ["t1-settings", "t2-addons-extensions-and-themes", "t3-extensions", "technical"]
129+
tags, ["t1-settings", "t2-addons-extensions-and-themes", "t3-extensions", "general"]
123130
)
124131

125-
@patch("kitsune.customercare.utils.ZENDESK_CATEGORIES")
126-
def test_automation_tag_included_when_matched(self, mock_categories):
132+
def test_automation_tag_included_when_matched(self):
127133
"""Test that automation tag is included when tier tags match a category."""
128-
mock_categories.get.return_value = [
129-
{
130-
"slug": "accounts-signin",
131-
"tags": {
132-
"tiers": ["t1-passwords-and-sign-in", "t2-sign-in"],
133-
"automation": "ssa-sign-in-failure-automation",
134-
},
135-
}
136-
]
137-
138134
tier1 = TopicFactory(title="Passwords and sign in", parent=None, is_archived=False)
139135
tier1.products.add(self.product)
140136
tier2 = TopicFactory(title="Sign in", parent=tier1, is_archived=False)
141137
tier2.products.add(self.product)
142138

139+
# Create ZendeskConfig and ZendeskTopic with matching tier tags
140+
zendesk_config = ZendeskConfigFactory(name="Test Config")
141+
zendesk_topic = ZendeskTopicFactory(
142+
slug="accounts-signin",
143+
topic="I can't sign in",
144+
tier_tags=["t1-passwords-and-sign-in", "t2-sign-in"],
145+
automation_tag="ssa-sign-in-failure-automation",
146+
legacy_tag="accounts",
147+
)
148+
ZendeskTopicConfigurationFactory(
149+
zendesk_config=zendesk_config, zendesk_topic=zendesk_topic
150+
)
151+
ProductSupportConfigFactory(
152+
product=self.product, zendesk_config=zendesk_config, is_active=True
153+
)
154+
143155
submission = Mock(product=self.product)
144156
result = {"topic_result": {"topic": "Sign in"}}
145157

@@ -150,28 +162,33 @@ def test_automation_tag_included_when_matched(self, mock_categories):
150162
self.assertIn("t2-sign-in", tags)
151163
self.assertIn("accounts", tags)
152164

153-
@patch("kitsune.customercare.utils.ZENDESK_CATEGORIES")
154-
def test_no_automation_tag_when_not_matched(self, mock_categories):
165+
def test_no_automation_tag_when_not_matched(self):
155166
"""Test that no automation tag is included when tier tags don't match."""
156-
mock_categories.get.return_value = [
157-
{
158-
"slug": "different-category",
159-
"tags": {
160-
"tiers": ["t1-different"],
161-
"automation": "some-automation",
162-
},
163-
}
164-
]
165-
166167
tier1 = TopicFactory(title="Billing and subscriptions", parent=None, is_archived=False)
167168
tier1.products.add(self.product)
168169

170+
# Create ZendeskConfig with a ZendeskTopic that has different tier tags
171+
zendesk_config = ZendeskConfigFactory(name="Test Config")
172+
zendesk_topic = ZendeskTopicFactory(
173+
slug="different-category",
174+
topic="Different topic",
175+
tier_tags=["t1-different"],
176+
automation_tag="some-automation",
177+
legacy_tag="",
178+
)
179+
ZendeskTopicConfigurationFactory(
180+
zendesk_config=zendesk_config, zendesk_topic=zendesk_topic
181+
)
182+
ProductSupportConfigFactory(
183+
product=self.product, zendesk_config=zendesk_config, is_active=True
184+
)
185+
169186
submission = Mock(product=self.product)
170187
result = {"topic_result": {"topic": "Billing and subscriptions"}}
171188

172189
tags = generate_classification_tags(submission, result)
173190

174-
self.assertEqual(tags, ["t1-billing-and-subscriptions", "payment"])
191+
self.assertEqual(tags, ["t1-billing-and-subscriptions", "general"])
175192
self.assertNotIn("some-automation", tags)
176193

177194
def test_product_reassignment_includes_other_tag(self):
@@ -189,7 +206,7 @@ def test_product_reassignment_includes_other_tag(self):
189206

190207
self.assertIn("other", tags)
191208
self.assertIn("t1-settings", tags)
192-
self.assertIn("technical", tags)
209+
self.assertIn("general", tags)
193210

194211
def test_archived_topic_returns_undefined(self):
195212
"""Test that archived topics are not found and return ['undefined', 'general']."""

0 commit comments

Comments
 (0)