from django.urls import reverse from playwright.sync_api import expect from .base import BasePage class StaffPaymentsPage(BasePage): @property def daily_summary(self): return self.page.get_by_role('region', name='وضعیت امروز') def open_summary_definitions(self): self.daily_summary.locator('summary').click() 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)