feat: add a line item to an order edit (#2243)
**What**
- Implement adding a line item to order (edit)
**How**
- _by implementing the following "flow"_
- generate a line item
- computing line item adjustments for that line item
- creating tax lines
- creating a change record
**Testing**
- **_integration tests_**
- check if line item and order item change objects are created (with correct tax lines)
- line item adjustments are generated if
- fixed discount is applied to cart
- percentage discount is applied
- **_unit tests_**
- ensure that methods from Inventory, LineItem, LineItemAdjustment etc. services are called
---
RESOLVES CORE-495
This commit is contained in:
@@ -6,6 +6,8 @@ import {
|
||||
useAdminDeleteOrderEditItemChange,
|
||||
useAdminOrderEditUpdateLineItem,
|
||||
useAdminRequestOrderEditConfirmation,
|
||||
useAdminOrderEditLineItem,
|
||||
useAdminCancelOrderEdit,
|
||||
useAdminUpdateOrderEdit,
|
||||
} from "../../../../src/"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
@@ -163,6 +165,36 @@ describe("useAdminRequestOrderEditConfirmation hook", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminOrderEditLineItem hook", () => {
|
||||
test("Created an order edit line item", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminOrderEditLineItem(fixtures.get("order_edit").id),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
const payload = {
|
||||
variant_id: "var_1",
|
||||
quantity: 2,
|
||||
}
|
||||
|
||||
result.current.mutate(payload)
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.data.response.status).toEqual(200)
|
||||
expect(result.current.data).toEqual(
|
||||
expect.objectContaining({
|
||||
order_edit: {
|
||||
...fixtures.get("order_edit"),
|
||||
...payload,
|
||||
},
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminCancelOrderEdit hook", () => {
|
||||
test("cancel an order edit", async () => {
|
||||
const { result, waitFor } = renderHook(
|
||||
|
||||
Reference in New Issue
Block a user