From 1d3cff0b635f6ba31adde9877b6e6c26e1c3cd5a Mon Sep 17 00:00:00 2001 From: javad Date: Tue, 15 Sep 2026 12:05:24 +0330 Subject: [PATCH] fix bug sms --- apps/tickets/services.py | 2 +- tests/test_domain.py | 10 +++++++--- tests/test_organizational_ticketing.py | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/tickets/services.py b/apps/tickets/services.py index 4e462e4..2edba9a 100644 --- a/apps/tickets/services.py +++ b/apps/tickets/services.py @@ -41,7 +41,7 @@ def create_ticket(*,customer,category,subject,selected_expert=None,body="",files enqueue(NotificationJob.Channel.SMS,"CUSTOMER_TICKET_CREATED",ticket,f"ticket:{ticket.pk}:customer-created",customer=customer) if owning_unit and owning_unit.bale_chat_id: enqueue(NotificationJob.Channel.BALE,"NEW_CUSTOMER_TICKET",ticket,f"ticket:{ticket.pk}:bale-group",payload={"ticket_number":ticket.ticket_number}) - enqueue_unit_supervisor_ticket_sms(ticket) + enqueue_unit_supervisor_ticket_sms(ticket) return ticket diff --git a/tests/test_domain.py b/tests/test_domain.py index 2b23db6..bcd9fac 100644 --- a/tests/test_domain.py +++ b/tests/test_domain.py @@ -275,7 +275,7 @@ def test_global_supervisor_sms_template_is_seeded_and_editable(): @pytest.mark.django_db -def test_staff_created_ticket_also_notifies_owning_unit_supervisors(category, customer): +def test_staff_created_ticket_notifies_customer_but_not_unit_supervisors(category, customer): category.unit.supervisor_mobile_1 = "09124445566" category.unit.save() staff = make_staff("a") @@ -289,8 +289,12 @@ def test_staff_created_ticket_also_notifies_owning_unit_supervisors(category, cu body="متن", ) - job = NotificationJob.objects.get(ticket=ticket, event_type="UNIT_SUPERVISOR_NEW_TICKET") - assert job.payload == {"recipient_mobile": "+989124445566"} + assert NotificationJob.objects.filter( + ticket=ticket, + event_type="UNIT_SUPERVISOR_NEW_TICKET", + ).count() == 0 + customer_job = NotificationJob.objects.get(ticket=ticket, event_type="STAFF_TICKET_CREATED") + assert customer_job.customer == customer @pytest.mark.django_db def test_customer_bale_replies_are_debounced_by_database_policy(category,customer): diff --git a/tests/test_organizational_ticketing.py b/tests/test_organizational_ticketing.py index 7fae5fb..deedfe2 100644 --- a/tests/test_organizational_ticketing.py +++ b/tests/test_organizational_ticketing.py @@ -46,7 +46,7 @@ def test_dispatch_owner_can_resolve_all_open_group_tickets_from_report_or_ticket assert report.context["open_ticket_count"] == 1 assert "حل‌شدن همه تیکت‌ها (1)" in report_text ticket_page = client.get(reverse("staff_tickets:detail", args=[tickets[0].public_id])) - assert "وابسته به ارسال گروهی" in ticket_page.content.decode() + assert "ارسال گروهی" in ticket_page.content.decode() assert dispatch.subject in ticket_page.content.decode() assert "حل‌شدن تمامی تیکت‌های گروه (1)" in ticket_page.content.decode()