Files
customerTicket/tests/e2e/test_payment_links_e2e.py
T
2026-10-06 10:03:22 +03:30

42 lines
2.4 KiB
Python

from urllib.parse import urlsplit
import pytest
from playwright.sync_api import expect
from apps.core.models import SiteBranding
from apps.payments.access import issue_payment_link
from apps.payments import services
from tests.e2e.pages.payment_link import PaymentLinkPage
from tests.e2e.test_payments_e2e import payment_case, PNG
pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)]
@pytest.mark.parametrize('width,linked', [(1440, True), (320, True), (390, False)])
def test_sms_payment_without_login_preserves_copy_and_submission(live_server, browser_page, payment_case, width, linked):
customer, account, reviewers = payment_case
notice = services.issue_notice(reviewers[0], {'customer': customer, 'account': account,
'subject': 'اعلامیه بدون ورود', 'amount': 12345, 'deposit_id': '000123', 'description': 'اطلاعات کامل اعلامیه'})
_, url = issue_payment_link(notice=notice)
branding = SiteBranding.load()
branding.developer_credit_text = 'امضای ثابت توسعه‌دهنده'
branding.save()
with browser_page() as page:
page.set_viewport_size({'width': width, 'height': 900})
view = PaymentLinkPage(page, live_server.url)
view.open_link(urlsplit(url).path)
expect(page.locator('.pay-deposit-required dd')).to_have_text('000123')
expect(page.get_by_text('واریز بدون این شناسه معتبر نخواهد بود.', exact=False)).to_be_visible()
expect(page.locator('.cs-footer')).to_have_text(branding.developer_credit_text)
expect(page.get_by_role('link', name='پروفایل من')).to_have_count(0)
assert page.locator('.pay-deposit-required dd').evaluate('(element) => getComputedStyle(element).color') == 'rgb(159, 31, 31)'
view.copy_all()
view.open_receipt_form(linked)
view.show_required_errors()
view.submit_payment(PNG, account_id=account.pk if not linked else None)
expect(page.get_by_text('در انتظار بررسی', exact=False).first).to_be_visible()
expect(page.get_by_role('button', name='ثبت تأیید من', exact=True)).to_have_count(0)
if not linked:
expect(page.get_by_text('واریز مستقل', exact=True)).to_be_visible()
assert page.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1')