Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
test_unable_to_void_order_marked_as_paid (#14255)
Renatafbdb068e029b
diff --git a/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py b/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.pynew file mode 100644index 0000000000..9ac360ad2d--- /dev/null+++ b/saleor/tests/e2e/orders/test_unable_to_void_order_marked_as_paid.py@@ -0,0 +1,120 @@+import pytest++from .. import DEFAULT_ADDRESS+from ..product.utils.preparing_product import prepare_product+from ..shop.utils.preparing_shop import prepare_shop+from ..utils import assign_permissions+from .utils import (+ draft_order_complete,+ draft_order_create,+ draft_order_update,+ mark_order_paid,+ order_lines_create,+ order_query,+ raw_order_void,+)+++def prepare_order_marked_as_paid(e2e_staff_api_client):+ price = 10++ (+ warehouse_id,+ channel_id,+ _channel_slug,+ shipping_method_id,+ ) = prepare_shop(e2e_staff_api_client)++ _product_id, product_variant_id, _product_variant_price = prepare_product(+ e2e_staff_api_client,+ warehouse_id,+ channel_id,+ price,+ )++ draft_order_input = {+ "channelId": channel_id,+ "userEmail": "[email protected]",+ "shippingAddress": DEFAULT_ADDRESS,+ "billingAddress": DEFAULT_ADDRESS,+ }+ data = draft_order_create(+ e2e_staff_api_client,+ draft_order_input,+ )+ order_id = data["order"]["id"]++ lines = [+ {+ "variantId": product_variant_id,+ "quantity": 1,+ }+ ]+ order_lines_create(+ e2e_staff_api_client,+ order_id,+ lines,+ )++ input = {"shippingMethod": shipping_method_id}+ draft_order_update(+ e2e_staff_api_client,+ order_id,+ input,+ )++ draft_order_complete(+ e2e_staff_api_client,+ order_id,+ )++ data = mark_order_paid(+ e2e_staff_api_client,+ order_id,+ )+ payment_id = data["order"]["payments"][0]["id"]++ return order_id, payment_id+++def test_unable_to_void_order_marked_as_paid_CORE_0211(+ e2e_staff_api_client,+ permission_manage_products,+ permission_manage_channels,+ permission_manage_product_types_and_attributes,+ permission_manage_shipping,+ permission_manage_orders,+):+ # Before+ permissions = [+ permission_manage_products,+ permission_manage_channels,+ permission_manage_shipping,+ permission_manage_product_types_and_attributes,+ permission_manage_orders,+ ]+ assign_permissions(e2e_staff_api_client, permissions)++ order_id, payment_id = prepare_order_marked_as_paid(e2e_staff_api_client)++ # Step 1 - Check the order is marked as paid+ order_data = order_query(+ e2e_staff_api_client,+ order_id,+ )+ assert order_data["isPaid"] is True+ assert order_data["payments"][0]["id"] == payment_id+ assert order_data["payments"][0]["gateway"] == "manual"+ assert order_data["paymentStatus"] == "FULLY_CHARGED"+ assert order_data["status"] == "UNFULFILLED"++ # Step 2 - Void the payment+ order = raw_order_void(+ e2e_staff_api_client,+ order_id,+ )+ error = order["errors"][0]+ assert error["message"] == "Cannot find successful auth transaction."+ assert error["code"] == "PAYMENT_ERROR"+ assert error["field"] == "payment"diff --git a/saleor/tests/e2e/orders/utils/order_mark_as_paid.py b/saleor/tests/e2e/orders/utils/order_mark_as_paid.pyindex 7b7b8c7550..64029137c3 100644--- a/saleor/tests/e2e/orders/utils/order_mark_as_paid.py+++ b/saleor/tests/e2e/orders/utils/order_mark_as_paid.py@@ -7,6 +7,14 @@ mutation OrderMarkAsPaid($id: ID!, $transactionReference: String) {idisPaidpaymentStatus+ payments {+ id+ gateway+ paymentMethodType+ transactions {+ kind+ }+ }paymentStatusDisplaystatusstatusDisplaydiff --git a/saleor/tests/e2e/orders/utils/order_query.py b/saleor/tests/e2e/orders/utils/order_query.pyindex 92faf105e1..96d03fe874 100644--- a/saleor/tests/e2e/orders/utils/order_query.py+++ b/saleor/tests/e2e/orders/utils/order_query.py@@ -1,20 +1,27 @@from saleor.graphql.tests.utils import get_graphql_contentORDER_QUERY = """-query OrderDetails($id:ID!) {- order(id:$id) {+query OrderDetails($id: ID!) {+ order(id: $id) {availableShippingMethods {idactive}paymentStatusisPaid+ payments {+ id+ gateway+ paymentMethodType+ chargeStatus+ token+ }events {type}channel {- id- name+ id+ name}updatedAtfulfillments {@@ -47,10 +54,11 @@ query OrderDetails($id:ID!) {statusDisplaystatustransactions {- id+ id}}}+"""