some improve for sms delivery

This commit is contained in:
javad committed 2026-09-16 10:40:21 +03:30
1 parent 1d3cff0b63
commit ffc1ec0dcf
10 files changed
+134 -11

No files matched your search

+41 -1
View File
@@ -252,6 +252,42 @@ def test_staff_reply_feedback_and_new_reply_action_remain_available(client):
assert 'composer staff-composer is-collapsed' in content
assert 'accept="image/*"' in content and "data-gallery-input" in content and "data-document-input" in content
@pytest.mark.django_db
def test_staff_ticket_sms_status_is_compact_expandable_and_time_precise(client):
from apps.core.templatetags.jalali import jalali_datetime
from apps.notifications.models import NotificationJob
category=TicketCategory.objects.create(title="رهگیری پیامک",slug="sms-timeline")
customer=User.objects.create_user(username="sms-timeline-customer",mobile="09120000031",account_type="CUSTOMER")
expert=User.objects.create_user(username="sms-timeline-expert",mobile="09120000032",account_type="STAFF")
StaffProfile.objects.create(user=expert,display_name="کارشناس رهگیری")
expert.user_permissions.add(Permission.objects.get(content_type__app_label="tickets",codename="view_ticket"))
ticket=create_ticket(customer=customer,category=category,subject="نمایش دقیق وضعیت پیامک",selected_expert=expert,body="شرح")
job=NotificationJob.objects.get(ticket=ticket,event_type="CUSTOMER_TICKET_CREATED")
sent_at=timezone.now()-timedelta(minutes=4)
delivered_at=timezone.now()-timedelta(minutes=1)
NotificationJob.objects.filter(pk=job.pk).update(
status=NotificationJob.Status.SENT,
sent_at=sent_at,
provider_message_id="123456789",
delivery_status=NotificationJob.DeliveryStatus.DELIVERED,
delivery_status_code="5",
delivery_description="پیامک به گوشی گیرنده رسیده است.",
delivery_checked_at=delivered_at,
delivery_next_check_at=None,
)
client.force_login(expert)
content=client.get(reverse("staff_tickets:detail",args=[ticket.public_id])).content.decode()
assert 'class="sms-delivery-item"' in content
assert 'aria-label="نمایش جزئیات زمان‌بندی پیامک"' in content
for label in ("ثبت درخواست ارسال","پذیرش توسط درگاه پیامک","تأیید رسیدن به گوشی"):
assert label in content
assert jalali_datetime(sent_at) in content
assert jalali_datetime(delivered_at) in content
assert "123456789" in content
@pytest.mark.django_db
def test_staff_sidebar_hides_admin_link_and_shows_developer_credit(client):
expert=User.objects.create_superuser(username="sidebar-admin",mobile="09384999655",password="test-pass",account_type="STAFF")
@@ -392,7 +428,7 @@ def test_ticket_polling_is_versioned_incremental_and_permission_safe(client):
def test_ticket_polling_javascript_keeps_background_sync_and_recovers_reliably():
script=Path("static/js/conversation.js").read_text(encoding="utf-8")
for feature in ("visibilitychange","document.visibilityState==='visible'","AbortController","pollRunning","nextPollAt","pollHeartbeat","setInterval(startPolling,1000)","cache:'no-store'","const restartPolling=()=>{stopPolling();startPolling()}","window.addEventListener('pageshow',restartPolling)","window.addEventListener('online',restartPolling)","data-scroll-to-submit","scrollIntoView","submit-attention"):
for feature in ("visibilitychange","document.visibilityState==='visible'","AbortController","pollRunning","nextPollAt","pollHeartbeat","setInterval(startPolling,1000)","cache:'no-store'","const restartPolling=()=>{stopPolling();startPolling()}","window.addEventListener('pageshow',restartPolling)","window.addEventListener('online',restartPolling)","data-scroll-to-submit","scrollIntoView","submit-attention","keepLatestVisible","requestAnimationFrame"):
assert feature in script
assert "pollUrl&&navigator.onLine" not in script
assert "window.addEventListener('offline',stopPolling)" not in script
@@ -403,6 +439,10 @@ def test_ticket_polling_javascript_keeps_background_sync_and_recovers_reliably()
assert "scroller.scrollTo({top,behavior:'smooth'})" in script
assert "data-message-id" in Path("templates/tickets/_messages.html").read_text(encoding="utf-8")
assert "acknowledgeVisibleMessages" in script and "document.visibilityState!=='visible'" in script
source_css=Path("static/src/tailwind.css").read_text(encoding="utf-8")
assert ".staff-ticket-workspace .composer.is-collapsed{position:fixed" not in source_css
assert ".staff-ticket-workspace .composer:not(.is-collapsed){position:fixed" not in source_css
assert "max-height:min(45dvh,28rem)" in source_css
for menu_feature in ("data-message-menu","data-message-menu-close","closeMessageMenu","event.key==='Escape'","!menu.contains(event.target)"):
assert menu_feature in script or menu_feature in Path("templates/tickets/_messages.html").read_text(encoding="utf-8")