fix sms and ticket user frindly
This commit is contained in:
1 parent
1ee83374fd
commit
b8b3aba855
30 files changed
+2220
-119
No files matched your search
@@ -3,15 +3,16 @@ import base64
|
||||
import pytest
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from apps.accounts.models import TicketMagicLink, User
|
||||
from apps.customers.models import ContactGroup, CustomerProfile
|
||||
from apps.core.models import PageTitle, SiteBranding
|
||||
from apps.notifications.models import SMSTemplate
|
||||
from apps.notifications.models import NotificationJob, SMSTemplate
|
||||
from apps.staff.models import OrganizationalUnit, StaffProfile
|
||||
from apps.tickets.models import TicketCategory
|
||||
from apps.tickets.services import create_ticket
|
||||
from apps.tickets.services import create_ticket, dispatch_group_tickets
|
||||
from tests.e2e.pages.auth import AuthenticationPage
|
||||
|
||||
|
||||
@@ -79,6 +80,20 @@ def test_staff_operations_pages_are_authorized_and_visually_styled(live_server,
|
||||
expect(page.locator(".staff-developer-credit")).to_contain_text("امضای مستقل sidebar E2E")
|
||||
expect(page.get_by_role("searchbox", name="جستجو")).to_be_visible()
|
||||
expect(page.locator('link[href*="dispatches.css"]')).to_have_count(1)
|
||||
expect(page.get_by_text("افزودن عکس از گالری")).to_be_visible()
|
||||
expect(page.locator('label[for="dispatch-file-input"]')).to_be_visible()
|
||||
tiny_png = base64.b64decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=")
|
||||
page.locator("#dispatch-gallery-input").set_input_files([
|
||||
{"name":"dispatch-first.png","mimeType":"image/png","buffer":tiny_png},
|
||||
{"name":"dispatch-second.png","mimeType":"image/png","buffer":tiny_png},
|
||||
])
|
||||
expect(page.locator(".dispatch-attachment-picker [data-file-preview] .file-chip")).to_have_count(2)
|
||||
expect(page.locator(".dispatch-attachment-picker [data-file-preview] img")).to_have_count(2)
|
||||
page.locator("#dispatch-file-input").set_input_files({"name":"dispatch-document.pdf","mimeType":"application/pdf","buffer":b"%PDF-1.4\n%%EOF"})
|
||||
expect(page.locator(".dispatch-attachment-picker [data-file-preview] .file-chip")).to_have_count(3)
|
||||
page.locator(".dispatch-attachment-picker [data-file-preview] .file-chip button").first.click()
|
||||
expect(page.locator(".dispatch-attachment-picker [data-file-preview] .file-chip")).to_have_count(2)
|
||||
assert page.locator('.dispatch-attachment-picker input[name="files"]').evaluate("input => input.files.length") == 2
|
||||
|
||||
page.goto(f"{live_server.url}{reverse('staff_tickets:sms_templates')}", wait_until="domcontentloaded")
|
||||
expect(page.get_by_text("الگوی عمومی سیستم").first).to_be_visible()
|
||||
@@ -105,7 +120,6 @@ def test_staff_operations_pages_are_authorized_and_visually_styled(live_server,
|
||||
expect(page.locator(f'input[name="groups"][value="{secondary_group.pk}"]')).to_be_checked()
|
||||
|
||||
page.goto(f"{live_server.url}{reverse('staff_tickets:create')}", wait_until="domcontentloaded")
|
||||
tiny_png = base64.b64decode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=")
|
||||
page.locator("#staff-ticket-gallery-input").set_input_files([
|
||||
{"name": "first.png", "mimeType": "image/png", "buffer": tiny_png},
|
||||
{"name": "second.png", "mimeType": "image/png", "buffer": tiny_png},
|
||||
@@ -115,3 +129,52 @@ def test_staff_operations_pages_are_authorized_and_visually_styled(live_server,
|
||||
page.locator("[data-file-preview] .file-chip button").first.click()
|
||||
expect(page.locator("[data-file-preview] .file-chip")).to_have_count(1)
|
||||
assert page.locator('input[name="files"]').evaluate("input => input.files.length") == 1
|
||||
|
||||
|
||||
def test_dispatch_report_presents_delivery_and_engagement_professionally(live_server, browser_page):
|
||||
from apps.core.templatetags.jalali import jalali_datetime
|
||||
|
||||
unit=OrganizationalUnit.objects.create(name="فروش گزارش E2E",slug="dispatch-report-e2e")
|
||||
unit.permissions.add(*Permission.objects.filter(content_type__app_label="tickets",codename__in=("view_ticket","dispatch_group_tickets")))
|
||||
staff=User.objects.create_user(username="dispatch-report-agent",password=PASSWORD,account_type=User.AccountType.STAFF)
|
||||
StaffProfile.objects.create(user=staff,display_name="کارشناس گزارش",primary_unit=unit)
|
||||
customer=User.objects.create_user(username="dispatch-report-customer",mobile="09120009131",account_type=User.AccountType.CUSTOMER)
|
||||
profile=CustomerProfile.objects.create(user=customer,first_name="مخاطب",last_name="آزمایشی")
|
||||
group=ContactGroup.objects.create(unit=unit,name="گروه گزارش حرفهای")
|
||||
profile.groups.add(group)
|
||||
category=TicketCategory.objects.create(unit=unit,title="استعلام گزارش",slug="dispatch-report-category-e2e")
|
||||
dispatch,tickets=dispatch_group_tickets(user=staff,unit=unit,contact_group=group,category=category,subject="استعلام حرفهای",body="این متن اولیه کارشناس باید بالای گزارش دیده شود.")
|
||||
ticket=tickets[0]
|
||||
job=NotificationJob.objects.get(ticket=ticket,event_type=SMSTemplate.Event.STAFF_TICKET_CREATED)
|
||||
NotificationJob.objects.filter(pk=job.pk).update(
|
||||
status=NotificationJob.Status.SENT,attempts=1,sent_at=timezone.now(),
|
||||
provider_message_id="1111182358",provider_status_code="1111182358",
|
||||
delivery_status=NotificationJob.DeliveryStatus.DELIVERED,delivery_status_code="5",
|
||||
delivery_description="0098SMS [کد 5]: پیامک به گوشی گیرنده رسیده است.",
|
||||
delivery_check_attempts=2,delivery_checked_at=timezone.now(),delivery_next_check_at=None,
|
||||
)
|
||||
links=[TicketMagicLink.issue_with_record(ticket,created_by=staff)[1] for _ in range(4)]
|
||||
links[0].view_count=2; links[0].used_at=timezone.now(); links[0].save(update_fields=["view_count","used_at"])
|
||||
|
||||
with browser_page() as page:
|
||||
AuthenticationPage(page,live_server.url).login_staff(staff,PASSWORD)
|
||||
page.goto(f"{live_server.url}{reverse('staff_tickets:dispatch_detail',args=[dispatch.public_id])}",wait_until="domcontentloaded")
|
||||
expect(page.get_by_role("heading",name="استعلام حرفهای",level=1)).to_be_visible()
|
||||
expect(page.get_by_text("این متن اولیه کارشناس باید بالای گزارش دیده شود.")).to_be_visible()
|
||||
expect(page.locator(".sms-state-card")).to_contain_text("تحویل به گوشی تأیید شد")
|
||||
expect(page.locator(".engagement-state")).to_contain_text("2 بازدید")
|
||||
expect(page.locator('[role="progressbar"]')).to_have_attribute("aria-valuenow","100")
|
||||
expect(page.locator(".delivery-progress-copy")).to_contain_text("100٪")
|
||||
assert float(page.locator(".sms-state-card strong").evaluate("node => parseFloat(getComputedStyle(node).fontSize)")) >= 12
|
||||
assert float(page.locator(".delivery-progress-track").evaluate("node => parseFloat(getComputedStyle(node).height)")) <= 8
|
||||
created_text=page.locator(".dispatch-meta-list time").inner_text()
|
||||
assert created_text == jalali_datetime(dispatch.created_at)
|
||||
assert "0 + 0" not in page.locator("body").inner_text()
|
||||
page.get_by_text("جزئیات فنی و رهگیری").click()
|
||||
expect(page.get_by_text("1111182358")).to_be_visible()
|
||||
expect(page.get_by_text("موفق در اولین تلاش")).to_be_visible()
|
||||
assert page.evaluate("document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1")
|
||||
|
||||
page.set_viewport_size({"width":390,"height":844})
|
||||
expect(page.locator(".dispatch-detail-table tbody tr").first).to_be_visible()
|
||||
assert page.evaluate("document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1")
|
||||
Reference in new issue
Block a user