fix payment
This commit is contained in:
1 parent
4f7486152c
commit
bb3ddd1610
47 files changed
+2137
-51
No files matched your search
@@ -4,6 +4,31 @@ from .payments import PaymentsPage
|
||||
|
||||
|
||||
class PaymentLinkPage(PaymentsPage):
|
||||
def prepare_copy(self, manual=False):
|
||||
self.manual_copy = manual
|
||||
if manual:
|
||||
self.page.add_init_script("Object.defineProperty(navigator, 'clipboard', {value: {writeText: async () => {throw new Error('Clipboard unavailable');}}});")
|
||||
else:
|
||||
self.page.context.grant_permissions(['clipboard-read', 'clipboard-write'])
|
||||
|
||||
def copied_text(self, button_name):
|
||||
self.page.get_by_role('button', name=button_name, exact=True).click()
|
||||
if button_name == 'کپی لینک کوتاه این صفحه برای ارسال به دیگران':
|
||||
expect(self.page.locator('.pay-share-feedback')).to_contain_text('لینک آماده است')
|
||||
if self.manual_copy:
|
||||
dialog = self.page.get_by_role('dialog')
|
||||
expect(dialog).to_be_visible()
|
||||
value = dialog.locator('textarea').input_value()
|
||||
dialog.get_by_role('button', name='بستن', exact=True).click()
|
||||
return value
|
||||
expect(self.page.get_by_text('کپی شد', exact=True)).to_be_visible()
|
||||
return self.page.evaluate('navigator.clipboard.readText()')
|
||||
|
||||
def copy_short_link(self):
|
||||
value = self.copied_text('کپی لینک کوتاه این صفحه برای ارسال به دیگران')
|
||||
expect(self.page.locator('.pay-share-feedback')).to_contain_text('لینک آماده است')
|
||||
return value
|
||||
|
||||
def open_link(self, path):
|
||||
self.goto(path)
|
||||
expect(self.page.get_by_role('heading', name='جزئیات واریز', exact=True)).to_be_visible()
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from .base import BasePage
|
||||
|
||||
|
||||
class ReceiptUploadPage(BasePage):
|
||||
def control_transport(self):
|
||||
"""Pause the browser transport while keeping the final POST real."""
|
||||
self.page.add_init_script("""(() => {
|
||||
const Native = window.XMLHttpRequest;
|
||||
window.receiptTransport = {count: 0};
|
||||
window.XMLHttpRequest = class extends Native {
|
||||
open(method, url, ...rest) {
|
||||
this.receiptRequest = method === 'POST' && /payment-receipt|receipts/.test(url);
|
||||
super.open(method, url, ...rest);
|
||||
}
|
||||
send(payload) {
|
||||
if (!this.receiptRequest) return super.send(payload);
|
||||
window.receiptTransport.count++;
|
||||
window.receiptTransport.current = this;
|
||||
this.release = () => super.send(payload);
|
||||
this.upload.dispatchEvent(new ProgressEvent('progress', {
|
||||
lengthComputable: true, loaded: 524288, total: 1048576
|
||||
}));
|
||||
}
|
||||
};
|
||||
})();""")
|
||||
|
||||
def fill_receipt(self, account_id, png):
|
||||
self.page.locator('#id_paid_amount').fill('۱۲۳۴۵')
|
||||
self.page.locator('#id_destination_account').select_option(str(account_id))
|
||||
self.page.get_by_role('button', name='امروز', exact=True).click()
|
||||
self.page.locator('#id_receipt_image').set_input_files({'name': 'receipt.png', 'mimeType': 'image/png', 'buffer': png})
|
||||
|
||||
def submit(self):
|
||||
self.page.get_by_role('button', name='ثبت و ارسال فیش', exact=True).click()
|
||||
|
||||
def assert_uploading(self):
|
||||
expect(self.page.locator('#receipt-upload')).to_be_visible()
|
||||
expect(self.page.locator('#receipt-upload-percent')).to_have_text('۵۰٪')
|
||||
expect(self.page.locator('#receipt-upload-bytes')).to_have_text('ارسالشده: ۵۱۲ کیلوبایت از ۱ مگابایت')
|
||||
expect(self.page.locator('#receipt-upload-time')).to_contain_text('دیگر برای ارسال')
|
||||
expect(self.page.locator('#submit-receipt')).to_be_disabled()
|
||||
expect(self.page.locator('#id_receipt_image')).to_be_disabled()
|
||||
|
||||
def repeat_submission(self):
|
||||
self.page.locator('#receipt-form').evaluate("form => {form.requestSubmit(); form.requestSubmit();}")
|
||||
assert self.page.evaluate('window.receiptTransport.count') == 1
|
||||
|
||||
def processing(self):
|
||||
self.page.evaluate("window.receiptTransport.current.upload.dispatchEvent(new Event('load'))")
|
||||
expect(self.page.locator('#receipt-upload-percent')).to_have_text('۱۰۰٪')
|
||||
expect(self.page.locator('#receipt-upload-title')).to_contain_text('در حال بررسی و ثبت فیش')
|
||||
expect(self.page.locator('#submit-receipt')).to_be_disabled()
|
||||
|
||||
def fail_network(self):
|
||||
self.page.evaluate("window.receiptTransport.current.dispatchEvent(new Event('error'))")
|
||||
expect(self.page.locator('#receipt-errors')).to_contain_text('ارتباط با سرور قطع شد')
|
||||
expect(self.page.locator('#submit-receipt')).to_be_enabled()
|
||||
expect(self.page.locator('#id_receipt_image')).to_be_enabled()
|
||||
assert self.page.locator('#id_receipt_image').evaluate('input => input.files.length') == 1
|
||||
|
||||
def reject_fields(self):
|
||||
self.page.evaluate("""() => {
|
||||
const request = window.receiptTransport.current;
|
||||
Object.defineProperty(request, 'status', {value: 422});
|
||||
Object.defineProperty(request, 'response', {value: {errors: {
|
||||
paid_amount: [{message: 'مبلغ با پرداخت مطابقت ندارد.'}],
|
||||
__all__: [{message: 'اطلاعات بانکی را دوباره بررسی کنید.'}]
|
||||
}}});
|
||||
request.dispatchEvent(new Event('load'));
|
||||
}""")
|
||||
expect(self.page.locator('#receipt-errors')).to_contain_text('اطلاعات بانکی را دوباره بررسی کنید.')
|
||||
expect(self.page.locator('#error-paid_amount')).to_have_text('مبلغ با پرداخت مطابقت ندارد.')
|
||||
expect(self.page.locator('#submit-receipt')).to_be_enabled()
|
||||
|
||||
def finish(self, revision=False):
|
||||
self.page.evaluate('window.receiptTransport.current.release()')
|
||||
expect(self.page.locator('.flash')).to_contain_text('نسخه اصلاحی ثبت شد' if revision else 'فیش ثبت شد و در انتظار بررسی است.')
|
||||
@@ -0,0 +1,44 @@
|
||||
from django.urls import reverse
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from .base import BasePage
|
||||
|
||||
|
||||
class StaffPaymentsPage(BasePage):
|
||||
def open_desk(self, parameters=''):
|
||||
self.goto(reverse('staff_payments:desk') + parameters)
|
||||
|
||||
def assert_action_tab(self):
|
||||
expect(self.page.get_by_role('link', name='نیازمند اقدام من', exact=True)).to_have_attribute('aria-current', 'page')
|
||||
expect(self.page.get_by_role('heading', name='فیشهای نیازمند اقدام شما')).to_be_visible()
|
||||
|
||||
def search(self, query):
|
||||
self.page.locator('[name=q]').fill(query)
|
||||
self.page.get_by_role('button', name='جستوجو', exact=True).click()
|
||||
|
||||
def next_page(self):
|
||||
pagination = self.page.get_by_role('navigation', name='صفحهبندی', exact=True)
|
||||
expect(pagination).to_contain_text('صفحه 1 از 2')
|
||||
pagination.get_by_role('link', name='بعدی', exact=True).click()
|
||||
expect(pagination).to_contain_text('صفحه 2 از 2')
|
||||
|
||||
def open_notice(self, public_id):
|
||||
self.goto(reverse('staff_payments:notice_detail', args=[public_id]))
|
||||
|
||||
def inspect_history(self):
|
||||
panel = self.page.locator('.pay-sms-panel')
|
||||
expect(panel).to_contain_text('رسیده به گوشی')
|
||||
expect(panel).to_contain_text('پذیرفتهشده توسط سرویس پیامک')
|
||||
expect(panel).to_contain_text('اعتبار پنل کافی نیست')
|
||||
for details in panel.locator('details').all():
|
||||
details.locator('summary').click()
|
||||
expect(panel).to_contain_text('old-delivered-id')
|
||||
expect(panel).to_contain_text('کد پاسخ سرویس: -19')
|
||||
|
||||
def resend_sms(self):
|
||||
button = self.page.get_by_role('button', name='ارسال مجدد پیامک اعلامیه واریز', exact=True)
|
||||
expect(button).to_be_enabled()
|
||||
button.click()
|
||||
expect(self.page.locator('.flash')).to_contain_text('درخواست ارسال مجدد پیامک در صف ثبت شد')
|
||||
expect(button).to_be_disabled()
|
||||
expect(self.page.locator('.pay-sms-history .pay-sms-record')).to_have_count(3)
|
||||
Reference in new issue
Block a user