share ticket and ticket message
This commit is contained in:
1 parent
39e64854b8
commit
79fe1cddbb
35 files changed
+1742
-95
No files matched your search
@@ -0,0 +1,57 @@
|
||||
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()
|
||||
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
|
||||
from tests.e2e.pages.auth import AuthenticationPage
|
||||
from tests.e2e.pages.sharing import StaffSharingPage
|
||||
from tests.test_staff_sharing import make_sharing_case
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("viewport", [{"width": 1280, "height": 900}, {"width": 390, "height": 844}])
|
||||
def test_staff_can_share_one_message_track_opening_and_revoke(live_server, browser_page, viewport):
|
||||
case = make_sharing_case()
|
||||
password = "SharingTest123!"
|
||||
with browser_page() as page:
|
||||
page.set_viewport_size(viewport)
|
||||
AuthenticationPage(page, live_server.url).login_staff(case["sender"], password)
|
||||
StaffSharingPage(page, live_server.url).share_message(case["ticket"], case["selected"], case["recipient"], "بررسی رسید توسط مالی")
|
||||
with browser_page() as page:
|
||||
page.set_viewport_size(viewport)
|
||||
AuthenticationPage(page, live_server.url).login_staff(case["recipient"], password)
|
||||
sharing = StaffSharingPage(page, live_server.url)
|
||||
sharing.open_received_message(case["ticket"])
|
||||
sharing.expect_isolated_content(case["selected"].body, ["مکاتبه محرمانه قبل", "مکاتبه محرمانه بعد"])
|
||||
shared_url = page.url
|
||||
with browser_page() as page:
|
||||
page.set_viewport_size(viewport)
|
||||
AuthenticationPage(page, live_server.url).login_staff(case["sender"], password)
|
||||
StaffSharingPage(page, live_server.url).expect_opened_and_revoke(case["ticket"], "کارشناس recipient")
|
||||
with browser_page() as page:
|
||||
page.set_viewport_size(viewport)
|
||||
AuthenticationPage(page, live_server.url).login_staff(case["recipient"], password)
|
||||
StaffSharingPage(page, live_server.url).expect_revoked_link_denied(shared_url)
|
||||
Reference in new issue
Block a user