|
11 | 11 | get_reactions, |
12 | 12 | toggle_reaction, |
13 | 13 | ) |
| 14 | +from helpdesk.mixins.mentions import HasMentions |
14 | 15 | from helpdesk.test_utils import create_agent |
15 | 16 |
|
16 | 17 |
|
@@ -299,6 +300,84 @@ def test_no_notification_for_self_reaction(self): |
299 | 300 |
|
300 | 301 | frappe.delete_doc("HD Ticket Comment", agent_comment.name, force=True) |
301 | 302 |
|
| 303 | + def test_if_repeated_notification_sent_on_mention_add(self): |
| 304 | + agent_one = self.agent_emails[0] |
| 305 | + frappe.set_user(agent_one) |
| 306 | + self.assign_agent(agent_one) |
| 307 | + |
| 308 | + agent_comment = frappe.get_doc( |
| 309 | + { |
| 310 | + "doctype": "HD Ticket Comment", |
| 311 | + "reference_ticket": self.test_ticket.name, |
| 312 | + "content": """ |
| 313 | + <p> |
| 314 | + Hello |
| 315 | + <span class="mention" |
| 316 | + data-type="mention" |
| 317 | + |
| 318 | + data-label="Test User Two"> |
| 319 | + @Test User Two |
| 320 | + </span> |
| 321 | + </p> |
| 322 | + """, |
| 323 | + "commented_by": agent_one, |
| 324 | + "owner": agent_one, |
| 325 | + } |
| 326 | + ) |
| 327 | + |
| 328 | + agent_comment.insert(ignore_permissions=True) |
| 329 | + print(agent_comment) |
| 330 | + |
| 331 | + notifications = frappe.get_all( |
| 332 | + "HD Notification", |
| 333 | + filters={ |
| 334 | + "reference_comment": agent_comment.name, |
| 335 | + "notification_type": "Mention", |
| 336 | + }, |
| 337 | + fields=["name", "user_to"], |
| 338 | + ) |
| 339 | + print(notifications) |
| 340 | + # notification one created should be equal to 1 |
| 341 | + self.assertEqual(len(notifications), 1) |
| 342 | + self. assertEqual( notifications[ 0]. user_to, "[email protected]") |
| 343 | + |
| 344 | + agent_comment.content = """ |
| 345 | + <p> |
| 346 | + Hello |
| 347 | + <span class="mention" |
| 348 | + data-type="mention" |
| 349 | + |
| 350 | + data-label="Test User Two"> |
| 351 | + @Test User Two |
| 352 | + </span> |
| 353 | + <span class="mention" |
| 354 | + data-type="mention" |
| 355 | + |
| 356 | + data-label="Test User One"> |
| 357 | + @Test User One |
| 358 | + </span> |
| 359 | + </p> |
| 360 | + """ |
| 361 | + |
| 362 | + agent_comment.save(ignore_permissions=True) |
| 363 | + agent_comment.reload() |
| 364 | + notifications_updated = frappe.get_all( |
| 365 | + "HD Notification", |
| 366 | + filters={ |
| 367 | + "reference_comment": agent_comment.name, |
| 368 | + "notification_type": "Mention", |
| 369 | + }, |
| 370 | + fields=["user_to"], |
| 371 | + ) |
| 372 | + print("notificationsnow", notifications_updated) |
| 373 | + print(agent_comment) |
| 374 | + |
| 375 | + user_emails = {n.user_to for n in notifications_updated} |
| 376 | + |
| 377 | + self.assertEqual(len(notifications_updated), 2) |
| 378 | + self. assertIn( "[email protected]", user_emails) |
| 379 | + self. assertIn( "[email protected]", user_emails) |
| 380 | + |
302 | 381 | def test_grouped_notifications(self): |
303 | 382 | test_users = self.agent_emails[3:6] |
304 | 383 |
|
|
0 commit comments