Files
2026-10-04 16:42:19 +03:30

58 lines
3.6 KiB
Python

from django.urls import reverse
from playwright.sync_api import expect
from tests.e2e.pages.base import BasePage
class StaffSharingPage(BasePage):
def share_message(self, ticket, message, recipient, note):
self.goto(reverse("staff_tickets:detail", args=[ticket.public_id]))
controls = self.page.locator(f'[data-share-message="{message.public_id}"]')
expect(controls.locator("form")).to_be_hidden()
controls.locator("summary").first.focus()
controls.locator("summary").first.press("Enter")
expect(controls.locator("form")).to_be_visible()
controls.get_by_label("کارشناس گیرنده").select_option(str(recipient.staff_profile.pk))
controls.locator(".staff-share-note-field > summary").click()
controls.get_by_label("توضیح برای گیرنده").fill(note)
controls.get_by_role("button", name="اشتراک پیام و پیوست‌هایش").click()
expect(self.page.get_by_text("فقط همین پیام و پیوست‌های آن در صندوق اشتراک‌های کارشناس قرار گرفت.")).to_be_visible()
def open_received_message(self, ticket):
self.goto(reverse("staff_tickets:shares"))
expect(self.page.locator('[data-share-unread-count]').first).to_contain_text("1")
self.page.locator("a.staff-ticket").first.click()
expect(self.page.get_by_role("heading", name=ticket.subject, exact=True)).to_be_visible()
expect(self.page.locator('.received-share-attribution')).to_contain_text("کارشناس sender")
expect(self.page.locator('[data-share-unread-count]').first).to_be_hidden()
expect(self.page.locator('[data-ticket-composer]')).to_have_count(0)
expect(self.page.get_by_role("button", name="عملیات تیکت", exact=True)).to_be_visible()
if self.page.viewport_size["width"] < 768:
self.page.get_by_role("button", name="اطلاعات مشتری", exact=True).click()
expect(self.page.locator('#customer-info')).to_contain_text(ticket.customer.mobile)
expect(self.page.locator('#customer-info')).to_be_visible()
if self.page.viewport_size["width"] < 768:
self.page.locator('#customer-info [data-close-panel]').click()
def expect_isolated_content(self, selected_text, forbidden_texts):
expect(self.page.get_by_text(selected_text, exact=True)).to_be_visible()
for text in forbidden_texts:
expect(self.page.get_by_text(text, exact=True)).to_have_count(0)
def expect_opened_and_revoke(self, ticket, recipient_name):
self.goto(reverse("staff_tickets:detail", args=[ticket.public_id]))
controls = self.page.locator("[data-share-message]").filter(has=self.page.locator(".share-audit-row").filter(has_text=recipient_name))
controls.locator("summary").first.click()
row = controls.locator(".share-audit-row").filter(has_text=recipient_name)
expect(row).to_contain_text("دیده‌شده")
expect(row.get_by_role("button", name="لغو اشتراک پیام")).to_be_hidden()
row.locator("summary").click()
expect(row).to_contain_text("اولین مشاهده")
controls.locator(".staff-inline-share-history > summary").click()
expect(controls.locator(".share-event-row").filter(has_text="مشاهده پیام اشتراکی")).to_be_visible()
row.get_by_role("button", name="لغو اشتراک پیام").click()
def expect_revoked_link_denied(self, url):
self.goto(url)
expect(self.page.get_by_text("403 Forbidden", exact=False)).to_be_visible()