Files
customerTicket/tests/e2e/test_staff_ticket_short_links_e2e.py
T
2026-10-13 16:09:45 +03:30

37 lines
1.9 KiB
Python

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("پاسخ کارشناس از لینک پیامک")