Files
customerTicket/tests/e2e/pages/receipt_customer_details.py

43 lines
2.0 KiB
Python

from playwright.sync_api import expect
from .receipt_upload import ReceiptUploadPage
class ReceiptCustomerDetailsPage(ReceiptUploadPage):
def expect_payer(self, value):
expect(self.page.get_by_label('نام واریزکننده')).to_have_value(value)
def enter_payer(self, name):
self.page.get_by_label('نام واریزکننده').fill(name)
def expect_missing_payer(self):
expect(self.page.locator('#error-depositor_name')).to_contain_text('نام واریزکننده را وارد کنید')
def select_destination(self, account_id, bank=None, identifier=None):
self.page.locator('#id_destination_account').select_option(str(account_id))
warning = self.page.locator('#destination-deposit-warning')
if bank:
expect(warning).to_be_visible()
expect(warning).to_contain_text(bank)
expect(warning).to_contain_text(identifier)
expect(warning).to_contain_text('برگشت بخورد')
assert warning.evaluate('el => getComputedStyle(el).color') == 'rgb(180, 35, 24)'
else:
expect(warning).to_be_hidden()
def reject(self, reason, *, confirm):
expect(self.page.locator('#decision-help')).to_contain_text('با پیامک برای مشتری ارسال می‌شود')
self.page.locator('#decision-reason').fill(reason)
previews = []
def answer(dialog):
previews.append(dialog.message)
dialog.accept() if confirm else dialog.dismiss()
self.page.once('dialog', answer)
self.page.get_by_role('button', name='رد فیش', exact=True).click()
assert len(previews) == 1 and reason in previews[0] and 'برای مشتری ارسال' in previews[0]
if confirm:
expect(self.page.locator('.pay-status').first).to_have_text('رد شده')
else:
expect(self.page.get_by_role('button', name='رد فیش', exact=True)).to_be_visible()
expect(self.page.locator('#decision-reason')).to_have_value(reason)