link view ticket for staff

This commit is contained in:
javad committed 2026-10-13 16:09:45 +03:30
1 parent 6b546aad76
commit 089db0afa4
13 files changed
+412 -3

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
from django.urls import reverse
from playwright.sync_api import expect
from tests.e2e.pages.base import BasePage
class StaffShortLinkPage(BasePage):
def open_and_login(self, path, staff, password, ticket):
self.goto(path)
expect(self.page.get_by_role("heading", name="ورود کارشناسان")).to_be_visible()
self.page.locator('input[name="username"]').fill(staff.username)
self.page.locator('input[name="password"]').fill(password)
self.page.get_by_role("button", name="ورود به میز کار").click()
expect(self.page).to_have_url(self.url(reverse("staff_tickets:detail", args=[ticket.public_id])))
expect(self.page.get_by_text(ticket.subject, exact=True).first).to_be_visible()
@@ -0,0 +1,36 @@
import pytest
from django.urls import reverse
from apps.accounts.models import User
from apps.staff.models import OrganizationalUnit, StaffProfile
from apps.tickets.models import StaffTicketShortLink, TicketCategory
from apps.tickets.services import create_ticket
from apps.tickets.short_links import append_supervisor_ticket_link
from tests.e2e.pages.staff_short_link import StaffShortLinkPage
from tests.e2e.pages.tickets import TicketConversationPage
pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)]
def test_supervisor_short_link_login_and_reply(live_server, browser_page):
password = "E2e-short-link-password-2026"
unit = OrganizationalUnit.objects.create(
name="واحد لینک مرورگر", slug="e2e-short-unit", supervisor_sms_ticket_link_enabled=True,
)
category = TicketCategory.objects.create(unit=unit, title="درخواست مرورگر", slug="e2e-short-category")
customer = User.objects.create_user(username="e2e-short-customer", mobile="09121112340", account_type="CUSTOMER")
staff = User.objects.create_user(
username="e2e-short-staff", mobile="09121112341", password=password, account_type="STAFF",
)
StaffProfile.objects.create(user=staff, primary_unit=unit, display_name="کارشناس مرورگر")
ticket = create_ticket(
customer=customer, category=category, selected_expert=staff,
subject="درخواست پاسخ از لینک کوتاه", body="پیام مشتری در مرورگر",
)
append_supervisor_ticket_link(ticket, "اعلان")
link = StaffTicketShortLink.objects.get(ticket=ticket)
path = reverse("staff_ticket_short_link", args=[link.token])
with browser_page() as page:
StaffShortLinkPage(page, live_server.url).open_and_login(path, staff, password, ticket)
TicketConversationPage(page, live_server.url).send_reply("پاسخ کارشناس از لینک پیامک")