feat(medusa): Implement premises of the creation flow of an order edit (#2187)

**What**
- Implements the admin create end point 
- Service implementation of the create method and the retrieveActive as well as the totals computation
- Improve compute line items
- client
  - medusa-js api
  - medusa-react mutations hooks

**Tests**
- Unit tests of the create end points
- Unit tests of the service create method
- Integration tests for admin that also take into account totals computations
- client
  - medusa-js tests
  - medusa-react hooks tests

FIXES CORE-491
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2022-09-16 08:29:40 +00:00
1 parent 6132711eef
commit f7177c9033
20 files changed
+745 -115

No files matched your search

@@ -1,7 +1,10 @@
import { useAdminDeleteOrderEdit } from "../../../../src/"
import {
useAdminCreateOrderEdit,
useAdminDeleteOrderEdit,
} from "../../../../src/"
import { renderHook } from "@testing-library/react-hooks"
import { fixtures } from "../../../../mocks/data"
import { createWrapper } from "../../../utils"
import { fixtures } from "../../../../mocks/data"
describe("useAdminDelete hook", () => {
test("Deletes an order edit", async () => {
@@ -11,7 +14,6 @@ describe("useAdminDelete hook", () => {
})
result.current.mutate()
await waitFor(() => result.current.isSuccess)
expect(result.current.data.response.status).toEqual(200)
@@ -24,3 +26,30 @@ describe("useAdminDelete hook", () => {
)
})
})
describe("useAdminCreateOrderEdit hook", () => {
test("Created an order edit", async () => {
const { result, waitFor } = renderHook(() => useAdminCreateOrderEdit(), {
wrapper: createWrapper(),
})
const payload = {
order_id: "ord_1",
internal_note: "This is an internal note",
}
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,
},
})
)
})
})