fix sms
This commit is contained in:
1 parent
1dea3509a7
commit
e3a6d1f9d4
42 files changed
+33086
-15779
No files matched your search
+89
-1
@@ -4,7 +4,7 @@
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from admin_panel.models import Article, Customer, PhoneNumber
|
||||
from admin_panel.models import Article, Customer, Factor, PhoneNumber
|
||||
|
||||
from .factories import login_superuser, make_customer, make_user
|
||||
|
||||
@@ -55,6 +55,94 @@ class CustomerCrudTests(TestCase):
|
||||
self.assertEqual(phones[0].phone_number, '09120009999')
|
||||
|
||||
|
||||
class CustomerInfoCardUITests(TestCase):
|
||||
"""کارت پروفایل مشتری (ستون راست): ساختار حرفهای، ویرایش و تعیین شمارهٔ اصلی.
|
||||
|
||||
این تستها قرارداد ویوها/قالبها را قفل میکنند تا بازطراحی UI به ویرایش مشتری
|
||||
یا تعیین «شمارهٔ اصلی پیامک» آسیب نزند.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.user = login_superuser(self.client, 'cardUser')
|
||||
|
||||
def _customer_page(self, customer):
|
||||
return self.client.get(
|
||||
reverse('admin_panel:customer', kwargs={'c_id': customer.id}),
|
||||
).content.decode('utf-8')
|
||||
|
||||
def test_profile_card_structure_is_rendered(self):
|
||||
customer = make_customer('مشتری کارت', phones=['09120000000'])
|
||||
html = self._customer_page(customer)
|
||||
for needle in ('has-background-white brad5', 'id="formcsEdit"',
|
||||
'dynamic-phones-edit', 'شمارههای تماس', 'لغو بازدید'):
|
||||
self.assertIn(needle, html, msg=needle)
|
||||
|
||||
def test_template_comments_never_leak_into_the_page(self):
|
||||
"""رگرسیون: کامنت چندخطی {# #} جنگو معتبر نیست و بهصورت متن چاپ میشود.
|
||||
|
||||
قالب کارت پروفایل باید از ``{% comment %}`` استفاده کند؛ این تست تضمین میکند
|
||||
هیچ متن کامنتی در HTML نهایی دیده نشود.
|
||||
"""
|
||||
customer = make_customer('مشتری کامنت', phones=['09120000000'])
|
||||
html = self._customer_page(customer)
|
||||
for leaked in ('تکمنبع', 'DRY', 'شناسههای موردنیاز', 'کارت پروفایل مشتری —'):
|
||||
self.assertNotIn(leaked, html, msg=f'متن کامنت در صفحه لو رفته: {leaked}')
|
||||
|
||||
def test_edit_controls_present_and_single_form(self):
|
||||
customer = make_customer('مشتری ویرایشکارت', phones=['09120000000'])
|
||||
html = self._customer_page(customer)
|
||||
for needle in ('id="formcsEdit"', 'id="enEdit"', 'id="editCs"',
|
||||
'id="cancelEdit"', 'id="showUserDT"'):
|
||||
self.assertIn(needle, html, msg=needle)
|
||||
# نباید فرم تودرتو ساخته شود؛ فقط یک فرم ویرایش در ستون وجود دارد.
|
||||
self.assertEqual(html.count('id="formcsEdit"'), 1)
|
||||
|
||||
def test_primary_toggle_present_next_to_phone(self):
|
||||
customer = make_customer('مشتری اصلیکارت')
|
||||
PhoneNumber.objects.create(customer=customer, phone_number='09120000000')
|
||||
html = self._customer_page(customer)
|
||||
self.assertIn('sms-primary-toggle', html)
|
||||
self.assertIn('data-phone="09120000000"', html)
|
||||
self.assertIn(
|
||||
'data-url="%s"' % reverse('admin_panel:sms_primary_toggle',
|
||||
kwargs={'c_id': customer.id}),
|
||||
html,
|
||||
)
|
||||
|
||||
def test_card_also_renders_on_legacy_base_page(self):
|
||||
"""صفحهٔ جزئیات فاکتور (customerFactor) از customerBase.html استفاده میکند."""
|
||||
factor = Factor.objects.create(customer=make_customer('مشتری فاکتورکارت'),
|
||||
amount=1000, pay_status='unpaid')
|
||||
html = self.client.get(
|
||||
reverse('admin_panel:customerFactor',
|
||||
kwargs={'c_id': factor.customer_id, 'f_id': factor.id}),
|
||||
).content.decode('utf-8')
|
||||
self.assertIn('has-background-white brad5', html)
|
||||
self.assertIn('id="formcsEdit"', html)
|
||||
|
||||
def test_edit_persists_phones_and_primary_selection(self):
|
||||
"""ویرایش مشتری با markup جدید باید شمارهها و انتخاب «اصلی» را ذخیره کند."""
|
||||
customer = make_customer('مشتری ویرایشنهایی', phones=['09120000001'])
|
||||
url = reverse('admin_panel:customerEdit', kwargs={'c_id': customer.id})
|
||||
response = self.client.post(url, {
|
||||
'an_name': 'مشتری ویرایشنهایی', 'an_address': 'قم',
|
||||
'installDate': '1401/02/03', 'idnCode': '555',
|
||||
'laghv_bazdid': 'true', 'notes': 'یادداشت',
|
||||
'phone_titles': ['موبایل'], 'phones': ['09120009999'],
|
||||
'phone_primary': ['0'],
|
||||
})
|
||||
self.assertIn(response.status_code, (200, 302))
|
||||
customer.refresh_from_db()
|
||||
self.assertEqual(customer.name_family, 'مشتری ویرایشنهایی')
|
||||
self.assertTrue(customer.laghv_bazdid)
|
||||
self.assertEqual(customer.notes, 'یادداشت')
|
||||
phones = list(PhoneNumber.objects.filter(customer=customer))
|
||||
self.assertEqual(len(phones), 1)
|
||||
self.assertEqual(phones[0].phone_number, '09120009999')
|
||||
# شمارهٔ تیکخورده بهعنوان «اصلی» ذخیره شده است.
|
||||
self.assertEqual(customer.sms_primary_phones, '+989120009999')
|
||||
|
||||
|
||||
class InactiveCustomerHiddenTests(TestCase):
|
||||
"""مشتری غیرفعال (is_active=False) در فهرست و در جستجو دیده نمیشود."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user