fix UI UX

This commit is contained in:
javad committed 2026-10-06 12:08:16 +03:30
1 parent 1cbbbbd0dc
commit d99e47ecce
11 files changed
+333 -32

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
from playwright.sync_api import expect
from .base import BasePage
class CustomerProfilePage(BasePage):
def open(self):
self.goto('/profile/')
expect(self.page.get_by_role('heading', name='پروفایل من', exact=True)).to_be_visible()
def edit_details(self):
self.page.get_by_label('نام:', exact=True).fill('مریم')
self.page.get_by_label('نام خانوادگی:', exact=True).fill('رضایی')
self.page.get_by_label('نوع مشتری:', exact=True).select_option('PERSON')
expect(self.page.locator('#profile-province-options option')).not_to_have_count(0)
self.page.get_by_label('استان:', exact=True).fill('تهران')
expect(self.page.get_by_label('شهر:', exact=True)).to_be_enabled()
self.page.get_by_label('شهر:', exact=True).fill('تهران')
def assert_validation_and_save(self):
self.page.get_by_label('رمز عبور جدید:', exact=True).fill('short')
self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click()
expect(self.page.get_by_label('رمز عبور جدید:', exact=True)).to_be_focused()
assert self.page.get_by_label('رمز عبور جدید:', exact=True).evaluate('(input) => input.validity.tooShort')
self.page.get_by_label('رمز عبور جدید:', exact=True).fill('')
self.page.get_by_label('شهر:', exact=True).fill('رشت')
self.page.get_by_label('شهر:', exact=True).press('Tab')
self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click()
expect(self.page.get_by_role('alert')).to_contain_text('اطلاعات مشخص‌شده را بررسی')
expect(self.page.get_by_label('نام:', exact=True)).to_have_value('مریم')
expect(self.page.get_by_label('شهر:', exact=True)).to_have_attribute('aria-invalid', 'true')
expect(self.page.locator('#profile-city-options option[value="تهران"]')).to_have_count(1)
self.page.get_by_label('شهر:', exact=True).fill('تهران')
self.page.get_by_label('شهر:', exact=True).press('Tab')
self.page.get_by_role('button', name='ذخیره تغییرات', exact=True).click()
expect(self.page.locator('.flash')).to_contain_text('پروفایل شما ذخیره شد.')
expect(self.page.get_by_label('نام:', exact=True)).to_have_value('مریم')
expect(self.page.get_by_label('شهر:', exact=True)).to_have_value('تهران')
+39
View File
@@ -0,0 +1,39 @@
from django.urls import reverse
from playwright.sync_api import expect
from .base import BasePage
class CustomerTicketsPage(BasePage):
def assert_dock(self, active):
dock = self.page.get_by_role('navigation', name='دسترسی سریع مشتری')
expect(dock.get_by_role('link')).to_have_count(3)
for name in ('خدمات', 'درخواست‌ها', 'پروفایل'):
expect(dock.get_by_role('link', name=name, exact=True)).to_be_visible()
expect(dock.locator('[aria-current]')).to_have_text(active)
for link in dock.get_by_role('link').all():
box = link.bounding_box()
assert box['width'] >= 44 and box['height'] >= 44
def follow_dock(self, name, destination):
self.page.get_by_role('navigation', name='دسترسی سریع مشتری').get_by_role(
'link', name=name, exact=True
).click()
expect(self.page).to_have_url(self.url(reverse(destination)))
def assert_history(self, subject=None):
expect(self.page.get_by_role('heading', name='درخواست‌های من', exact=True)).to_be_visible()
if subject:
card = self.page.locator('.tickets-list-card').filter(has_text=subject)
expect(card.get_by_role('heading', name=subject, exact=True)).to_be_visible()
expect(card).to_contain_text('مشاهده و پیگیری')
else:
expect(self.page.get_by_role('heading', name='هنوز درخواستی ثبت نشده')).to_be_visible()
expect(self.page.get_by_role('link', name='ثبت اولین درخواست')).to_be_visible()
assert self.page.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth + 1')
def start_request(self):
self.page.get_by_role('link', name='ثبت درخواست جدید', exact=True).click()
expect(self.page).to_have_url(self.url(reverse('tickets:new')))
expect(self.page.locator('.ticket-wizard-page')).to_be_visible()
+38
View File
@@ -0,0 +1,38 @@
import pytest
from apps.accounts.models import User
from tests.e2e.pages.auth import AuthenticationPage
from tests.e2e.pages.customer_profile import CustomerProfilePage
from tests.e2e.pages.customer_tickets import CustomerTicketsPage
pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)]
@pytest.mark.parametrize('width', [320, 393, 1440])
def test_profile_design_navigation_validation_and_save(live_server, browser_page, width):
password = 'Profile-design-2026!'
customer = User.objects.create_user(
username='profile-design', mobile='09120008892', password=password, account_type='CUSTOMER'
)
with browser_page() as page:
page.set_viewport_size({'width': width, 'height': 856})
AuthenticationPage(page, live_server.url).login_customer(customer, password)
navigation = CustomerTicketsPage(page, live_server.url)
profile = CustomerProfilePage(page, live_server.url)
if width < 640:
navigation.follow_dock('پروفایل', 'accounts:profile')
navigation.assert_dock('پروفایل')
else:
profile.open()
profile.edit_details()
profile.assert_validation_and_save()
assert page.evaluate('document.documentElement.scrollWidth <= innerWidth + 1')
if width < 640:
navigation.assert_dock('پروفایل')
navigation.follow_dock('درخواست‌ها', 'tickets:list')
navigation.assert_dock('درخواست‌ها')
navigation.follow_dock('خدمات', 'payments:home')
navigation.assert_dock('خدمات')
customer.customer_profile.refresh_from_db()
assert customer.customer_profile.first_name == 'مریم'
assert customer.customer_profile.city == 'تهران'
+42
View File
@@ -0,0 +1,42 @@
import pytest
from apps.accounts.models import User
from apps.tickets.models import TicketCategory
from apps.tickets.services import create_ticket
from tests.e2e.pages.auth import AuthenticationPage
from tests.e2e.pages.customer_tickets import CustomerTicketsPage
pytestmark = [pytest.mark.e2e, pytest.mark.django_db(transaction=True)]
@pytest.mark.parametrize('width', [320, 393, 1440])
@pytest.mark.parametrize('has_ticket', [False, True], ids=['empty', 'history'])
def test_customer_history_and_composer_share_chaharsu_navigation(live_server, browser_page, width, has_ticket):
password = 'Design-test-2026!'
customer = User.objects.create_user(
username='customer-design', mobile='09120008891', password=password, account_type='CUSTOMER'
)
subject = 'پیگیری سفارش و هماهنگی ارسال کالا با کارشناسان فروش برای تحویل در محل مشتری'
if has_ticket:
category = TicketCategory.objects.create(title='هماهنگی ارسال', slug='design-shipping')
create_ticket(customer=customer, category=category, subject=subject, body='شرح درخواست')
with browser_page() as page:
page.set_viewport_size({'width': width, 'height': 856})
AuthenticationPage(page, live_server.url).login_customer(customer, password)
history = CustomerTicketsPage(page, live_server.url)
history.goto('/chaharsu/')
if width < 640:
history.assert_dock('خدمات')
history.follow_dock('درخواست‌ها', 'tickets:list')
else:
history.goto('/tickets/')
history.assert_history(subject if has_ticket else None)
if width < 640:
history.assert_dock('درخواست‌ها')
history.start_request()
if width < 640:
history.assert_dock('درخواست‌ها')
history.follow_dock('درخواست‌ها', 'tickets:list')
history.assert_history(subject if has_ticket else None)
history.follow_dock('خدمات', 'payments:home')
history.assert_dock('خدمات')