From defc18ea406fe54a15cf6962933b13c97ad5a443 Mon Sep 17 00:00:00 2001 From: Sabrina Demagny Date: Fri, 17 Jan 2025 19:40:05 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(backend)=20fix=20flaky=20test=20wi?= =?UTF-8?q?th=20search=20contact?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes emails generated by faker in data field match search. So it's necessary to create contacts with empty data field to search contacts by full_name in tests. --- CHANGELOG.md | 1 + src/backend/core/api/client/viewsets.py | 2 -- .../core/tests/contacts/test_core_api_contacts_list.py | 8 ++++---- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 037666c..4cecfab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to ### Fixed +- 🐛(backend) fix flaky test with search contact #605 - 🐛(backend) fix flaky test with team access #646 - 🧑‍💻(dimail) remove 'NoneType: None' log in debug mode - 🐛(frontend) fix flaky e2e test #636 diff --git a/src/backend/core/api/client/viewsets.py b/src/backend/core/api/client/viewsets.py index 95a1ef1..f40f86b 100644 --- a/src/backend/core/api/client/viewsets.py +++ b/src/backend/core/api/client/viewsets.py @@ -25,8 +25,6 @@ from core.api import permissions from core.api.client import serializers from core.utils.raw_sql import gen_sql_filter_json_array -SIMILARITY_THRESHOLD = 0.04 - class NestedGenericViewSet(viewsets.GenericViewSet): """ diff --git a/src/backend/core/tests/contacts/test_core_api_contacts_list.py b/src/backend/core/tests/contacts/test_core_api_contacts_list.py index f3abe26..c01ed22 100644 --- a/src/backend/core/tests/contacts/test_core_api_contacts_list.py +++ b/src/backend/core/tests/contacts/test_core_api_contacts_list.py @@ -102,10 +102,10 @@ def test_api_contacts_list_authenticated_by_full_name(): """ user = factories.UserFactory(name="Prudence Crandall") - dave = factories.BaseContactFactory(full_name="David Bowman") - nicole = factories.BaseContactFactory(full_name="Nicole Foole") - frank = factories.BaseContactFactory(full_name="Frank Poole") - factories.BaseContactFactory(full_name="Heywood Floyd") + dave = factories.BaseContactFactory(full_name="David Bowman", data={}) + nicole = factories.BaseContactFactory(full_name="Nicole Foole", data={}) + frank = factories.BaseContactFactory(full_name="Frank Poole", data={}) + factories.BaseContactFactory(full_name="Heywood Floyd", data={}) # Full query should work client = APIClient()