Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add test for first and last name in elasticsearch

fowczarekbaf481a70abb
diff --git a/tests/cassettes/test_dashboard_search_user_name_without_address.yaml b/tests/cassettes/test_dashboard_search_user_name_without_address.yaml
new file mode 100644
index 0000000000..b9bd241320
--- /dev/null
+++ b/tests/cassettes/test_dashboard_search_user_name_without_address.yaml
@@ -0,0 +1,46 @@
+interactions:
+- request:
+ body: '{"query": {"multi_match": {"fields": ["name", "title", "description"],
+ "query": "Brett", "type": "cross_fields"}}, "sort": ["_score"], "_source": {"excludes":
+ ["*"]}}'
+ headers:
+ connection: [keep-alive]
+ content-type: [application/json]
+ method: GET
+ uri: http://search:9200/storefront/product_document/_search
+ response:
+ body: {string: '{"took":2,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}
+ headers:
+ content-length: ['122']
+ content-type: [application/json; charset=UTF-8]
+ status: {code: 200, message: OK}
+- request:
+ body: '{"query": {"multi_match": {"fields": ["user", "email", "first_name", "last_name"],
+ "query": "Brett", "type": "cross_fields", "operator": "and"}}, "_source": {"excludes":
+ ["*"]}}'
+ headers:
+ connection: [keep-alive]
+ content-type: [application/json]
+ method: GET
+ uri: http://search:9200/users/user_document/_search
+ response:
+ body: {string: '{"took":23,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":2.730029,"hits":[{"_index":"users","_type":"user_document","_id":"22","_score":2.730029,"_source":{}}]}}'}
+ headers:
+ content-length: ['211']
+ content-type: [application/json; charset=UTF-8]
+ status: {code: 200, message: OK}
+- request:
+ body: '{"query": {"multi_match": {"fields": ["user", "discount_name"], "query":
+ "Brett"}}, "_source": {"excludes": ["*"]}}'
+ headers:
+ connection: [keep-alive]
+ content-type: [application/json]
+ method: GET
+ uri: http://search:9200/orders/order_document/_search
+ response:
+ body: {string: '{"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}'}
+ headers:
+ content-length: ['122']
+ content-type: [application/json; charset=UTF-8]
+ status: {code: 200, message: OK}
+version: 1
diff --git a/tests/test_elasticsearch.py b/tests/test_elasticsearch.py
index 7a27f3fad2..863d03194a 100644
--- a/tests/test_elasticsearch.py
+++ b/tests/test_elasticsearch.py
@@ -132,10 +132,13 @@ NON_EXISTING_EMAIL = '[email protected]'
USER_WITH_ORDER = '[email protected]'
EXISTING_NAME = 'Rhonda'
EXISTING_NAME_FULL = '[email protected]'
+EXISTING_NAME_WITHOUT_ADDRESS = 'Brett'
+EXISTING_NAME_FULL_WITHOUT_ADDRESS = '[email protected]'
USERS = {EXISTING_EMAIL: 9,
NON_EXISTING_EMAIL: 870,
USER_WITH_ORDER: 666,
- EXISTING_NAME_FULL: 6}
+ EXISTING_NAME_FULL: 6,
+ EXISTING_NAME_FULL_WITHOUT_ADDRESS: 22}
ORDERS = {USER_WITH_ORDER: {18, 19}}
@@ -159,6 +162,15 @@ def test_dashboard_search_user_name(db, admin_client, customers):
assert USERS[EXISTING_NAME_FULL] in users
[email protected](record_mode='once', match_on=MATCH_SEARCH_REQUEST)
+def test_dashboard_search_user_name_without_address(db, admin_client,
+ customers):
+ _, users, _ = execute_dashboard_search(
+ admin_client, EXISTING_NAME_WITHOUT_ADDRESS)
+ assert USERS[EXISTING_NAME_FULL_WITHOUT_ADDRESS] in users
+
+
@pytest.fixture
def orders(db, address):
all_pks = set()