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('خدمات')