Skip to content

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

Add commented out test with order sorting

Michał Sipa01c1c82a7e01
diff --git a/tests/api/pagination/test_order.py b/tests/api/pagination/test_order.py
index 33d8c3ecff..8e1c8baa95 100644
--- a/tests/api/pagination/test_order.py
+++ b/tests/api/pagination/test_order.py
@@ -523,3 +523,67 @@ def test_draft_orders_query_pagination_with_filter_search_by_id(
)
content = get_graphql_content(response)
assert content["data"]["draftOrders"]["totalCount"] == 1
+
+
+# Currently sorting is not working properly for orders.
+# We should uncomment this test after fixing
+# @pytest.mark.parametrize(
+# "order_sort, result_order",
+# [
+# ({"field": "NUMBER", "direction": "ASC"}, [0, 1, 2]),
+# ({"field": "NUMBER", "direction": "DESC"}, [2, 1, 0]),
+# ({"field": "CREATION_DATE", "direction": "ASC"}, [1, 0, 2]),
+# ({"field": "CREATION_DATE", "direction": "DESC"}, [2, 0, 1]),
+# ({"field": "CUSTOMER", "direction": "ASC"}, [2, 0, 1]),
+# ({"field": "CUSTOMER", "direction": "DESC"}, [1, 0, 2]),
+# ({"field": "FULFILLMENT_STATUS", "direction": "ASC"}, [2, 1, 0]),
+# ({"field": "FULFILLMENT_STATUS", "direction": "DESC"}, [0, 1, 2]),
+# ({"field": "TOTAL", "direction": "ASC"}, [0, 2, 1]),
+# ({"field": "TOTAL", "direction": "DESC"}, [1, 2, 0]),
+# ],
+# )
+# def test_query_orders_pagination_with_sort(
+# order_sort, result_order, staff_api_client, permission_manage_orders, address
+# ):
+# created_orders = []
+# with freeze_time("2017-01-14"):
+# created_orders.append(
+# Order.objects.create(
+# token=str(uuid.uuid4()),
+# billing_address=address,
+# status=OrderStatus.PARTIALLY_FULFILLED,
+# total=TaxedMoney(net=Money(10, "USD"), gross=Money(13, "USD")),
+# )
+# )
+# with freeze_time("2012-01-14"):
+# address2 = address.get_copy()
+# address2.first_name = "Walter"
+# address2.save()
+# created_orders.append(
+# Order.objects.create(
+# token=str(uuid.uuid4()),
+# billing_address=address2,
+# status=OrderStatus.FULFILLED,
+# total=TaxedMoney(net=Money(100, "USD"), gross=Money(130, "USD")),
+# )
+# )
+# address3 = address.get_copy()
+# address3.last_name = "Alice"
+# address3.save()
+# created_orders.append(
+# Order.objects.create(
+# token=str(uuid.uuid4()),
+# billing_address=address3,
+# status=OrderStatus.CANCELED,
+# total=TaxedMoney(net=Money(20, "USD"), gross=Money(26, "USD")),
+# )
+# )
+# page_size = 2
+# variables = {"first": page_size, "after": None, "sort_by": order_sort}
+# staff_api_client.user.user_permissions.add(permission_manage_orders)
+# response = staff_api_client.post_graphql(QUERY_ORDERS_WITH_PAGINATION, variables)
+# content = get_graphql_content(response)
+# orders = content["data"]["orders"]["edges"]
+
+# for order, order_number in enumerate(result_order):
+# assert orders[order]["node"]["number"] == str(created_orders[order_number].pk)