|
4 | 4 | ContainerRegistrationKeys, |
5 | 5 | Modules, |
6 | 6 | OrderChangeStatus, |
| 7 | + OrderEditWorkflowEvents, |
7 | 8 | ProductStatus, |
8 | 9 | PromotionStatus, |
9 | 10 | PromotionType, |
@@ -1083,6 +1084,81 @@ medusaIntegrationTestRunner({ |
1083 | 1084 | OrderChangeStatus.CONFIRMED |
1084 | 1085 | ) |
1085 | 1086 | }) |
| 1087 | + |
| 1088 | + it("should store no_notification on the order change and pass it to the order edit events", async () => { |
| 1089 | + const eventBus = container.resolve(Modules.EVENT_BUS) |
| 1090 | + const requestedSubscriber = jest.fn() |
| 1091 | + const confirmedSubscriber = jest.fn() |
| 1092 | + |
| 1093 | + eventBus.subscribe( |
| 1094 | + OrderEditWorkflowEvents.REQUESTED, |
| 1095 | + requestedSubscriber |
| 1096 | + ) |
| 1097 | + eventBus.subscribe( |
| 1098 | + OrderEditWorkflowEvents.CONFIRMED, |
| 1099 | + confirmedSubscriber |
| 1100 | + ) |
| 1101 | + |
| 1102 | + const orderId = order.id |
| 1103 | + |
| 1104 | + await api.post( |
| 1105 | + "/admin/order-edits", |
| 1106 | + { order_id: orderId, description: "Test" }, |
| 1107 | + adminHeaders |
| 1108 | + ) |
| 1109 | + |
| 1110 | + await api.post( |
| 1111 | + `/admin/order-edits/${orderId}/shipping-method`, |
| 1112 | + { shipping_option_id: shippingOption.id, custom_amount: 5 }, |
| 1113 | + adminHeaders |
| 1114 | + ) |
| 1115 | + |
| 1116 | + const requestResult = await api.post( |
| 1117 | + `/admin/order-edits/${orderId}/request`, |
| 1118 | + { no_notification: true }, |
| 1119 | + adminHeaders |
| 1120 | + ) |
| 1121 | + |
| 1122 | + expect(requestResult.data.order_preview.order_change).toEqual( |
| 1123 | + expect.objectContaining({ no_notification: true }) |
| 1124 | + ) |
| 1125 | + |
| 1126 | + await api.post( |
| 1127 | + `/admin/order-edits/${orderId}/confirm`, |
| 1128 | + {}, |
| 1129 | + adminHeaders |
| 1130 | + ) |
| 1131 | + |
| 1132 | + const orderChangesResult = await api.get( |
| 1133 | + `/admin/orders/${orderId}/changes?change_type=edit`, |
| 1134 | + adminHeaders |
| 1135 | + ) |
| 1136 | + |
| 1137 | + expect(orderChangesResult.data.order_changes[0]).toEqual( |
| 1138 | + expect.objectContaining({ no_notification: true }) |
| 1139 | + ) |
| 1140 | + |
| 1141 | + await new Promise((resolve) => setTimeout(resolve, 100)) |
| 1142 | + |
| 1143 | + expect(requestedSubscriber.mock.calls[0][0].data).toMatchObject({ |
| 1144 | + order_id: orderId, |
| 1145 | + no_notification: true, |
| 1146 | + }) |
| 1147 | + |
| 1148 | + expect(confirmedSubscriber.mock.calls[0][0].data).toMatchObject({ |
| 1149 | + order_id: orderId, |
| 1150 | + no_notification: true, |
| 1151 | + }) |
| 1152 | + |
| 1153 | + eventBus.unsubscribe( |
| 1154 | + OrderEditWorkflowEvents.REQUESTED, |
| 1155 | + requestedSubscriber |
| 1156 | + ) |
| 1157 | + eventBus.unsubscribe( |
| 1158 | + OrderEditWorkflowEvents.CONFIRMED, |
| 1159 | + confirmedSubscriber |
| 1160 | + ) |
| 1161 | + }) |
1086 | 1162 | }) |
1087 | 1163 |
|
1088 | 1164 | describe("Order Edit Payment Collection", () => { |
|
0 commit comments