import pytest from django.urls import reverse from apps.accounts.models import User from apps.core.models import PageTitle, SiteBranding from apps.customers.models import ContactGroup from apps.notifications.models import SMSTemplate from apps.staff.models import OrganizationalUnit from apps.tickets.models import GroupDispatch, TicketCategory @pytest.mark.django_db def test_login_uses_database_title_and_brand_without_login_card_copy(client): branding = SiteBranding.load() branding.header_title = "سامانه ارتباطات آزمایشی" branding.header_subtitle = "پیگیری یکپارچه" branding.login_intro_icon = "●" branding.login_intro_eyebrow = "ارتباط مستقیم آزمایشی" branding.login_intro_heading = "عنوان سطر اول\nعنوان سطر دوم" branding.login_intro_body = "توضیح قابل مدیریت از دیتابیس" branding.developer_credit_text = "توسعه: تیم آزمایشی | ۰۹۱۲۰۰۰۰۰۰۰" branding.save() PageTitle.objects.update_or_create(route_name="accounts:login", defaults={"title": "ورود سفارشی", "is_active": True}) response = client.get(reverse("accounts:login")) content = response.content.decode() assert "ورود سفارشی" in content assert "سامانه ارتباطات آزمایشی" in content # page header is database-backed assert '
سامانه ارتباطات آزمایشی' not in content assert "ارتباط مستقیم آزمایشی" in content assert "عنوان سطر اول
عنوان سطر دوم" in content assert "توضیح قابل مدیریت از دیتابیس" in content assert "توسعه: تیم آزمایشی | ۰۹۱۲۰۰۰۰۰۰۰" in content @pytest.mark.django_db def test_developer_credit_html_requires_explicit_trusted_html_switch(client): branding = SiteBranding.load() branding.developer_credit_html = '★ توسعه نمونه' branding.use_developer_credit_html = False branding.save() escaped = client.get(reverse("accounts:login")).content.decode() assert "https://example.com" not in escaped branding.use_developer_credit_html = True branding.save() rendered = client.get(reverse("accounts:login")).content.decode() assert '★ توسعه نمونه' in rendered @pytest.mark.django_db def test_customer_new_renders_developer_credit_once_directly_below_wizard(client): customer = User.objects.create_user( username="wizard-credit-customer", mobile="09120000404", account_type=User.AccountType.CUSTOMER ) branding = SiteBranding.load() branding.developer_credit_text = "برنامه نویسی و توسعه: محمد جواد فصاحت | 09202202129" branding.save() client.force_login(customer) content = client.get(reverse("tickets:new")).content.decode() assert content.count(branding.developer_credit_text) == 1 assert '