1
0
forked from erp-dev/erp

feat: haobuye

This commit is contained in:
2026-03-20 20:00:12 +08:00
parent 84dbb2ee10
commit 96cc67706a
10 changed files with 1162 additions and 0 deletions

View File

@@ -828,6 +828,31 @@ class CustomerAPITestCase(TestCase):
self.assertEqual(len(results), 1)
self.assertEqual(results[0]['id'], customer_a.id)
def test_filter_customers_by_visible_employee_name_excludes_unbound_customers(self):
"""测试 visible_employee_name 过滤不会返回没有绑定员工的客户"""
visible_employee = Employee.objects.create(
merchant=self.merchant,
name='李四业务',
)
unbound_customer = Customer.objects.create(
merchant=self.merchant,
name='未绑定客户',
created_by=self.employee,
)
bound_customer = Customer.objects.create(
merchant=self.merchant,
name='已绑定客户',
created_by=self.employee,
)
bound_customer.visible_employees.add(visible_employee)
response = self.client.get('/api/backend/customers/?visible_employee_name=李四')
self.assertEqual(response.status_code, status.HTTP_200_OK)
results = response.data['results'] if isinstance(response.data, dict) else response.data
returned_ids = {item['id'] for item in results}
self.assertIn(bound_customer.id, returned_ids)
self.assertNotIn(unbound_customer.id, returned_ids)
def test_filter_customers_by_visible_employee_name_returns_distinct_results(self):
"""测试 visible_employee_name 过滤不会因多名匹配员工导致客户重复"""
customer = Customer.objects.create(