feat(medusa-js, medusa-react, medusa): Prepare API for admin implementations (#3110)
********What********
Add `joinSalesChannels util to stock locations
Add the following endpoints to medusa-react
- inventory items
- mutations
- update
- delete
- update location level
- delete location level
- create location level
- queries
- list inventory items
- get inventory item
- list location levels
- Stock locations
- mutations
- create stock location
- update stock location
- delete stock location
- queries
- list stock locations
- get stock locatoin
- Variants
- queries
- get inventory
- Reservations
- mutations
- create reservation
- update reservation
- delete reservation
- queries
- list reservations
- get reservation
- sales channels
- mutations
- associate location with sc
- remove location association
**Why**
- Update clients to reflect new api endpoints in the core with inventory modules
Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
This commit is contained in:
co-authored by
Philip Korsholm
parent
121b42acfe
commit
12d304307a
@@ -1,4 +1,4 @@
|
||||
import { useAdminVariants } from "../../../../src"
|
||||
import { useAdminVariants, useAdminVariantsInventory } from "../../../../src"
|
||||
import { renderHook } from "@testing-library/react-hooks"
|
||||
import { fixtures } from "../../../../mocks/data"
|
||||
import { createWrapper } from "../../../utils"
|
||||
@@ -16,3 +16,29 @@ describe("useAdminVariants hook", () => {
|
||||
expect(result.current.variants).toEqual(variants)
|
||||
})
|
||||
})
|
||||
|
||||
describe("useAdminVariants hook", () => {
|
||||
test("returns a variant with saleschannel locations", async () => {
|
||||
const variant = fixtures.get("product_variant")
|
||||
const { result, waitFor } = renderHook(
|
||||
() => useAdminVariantsInventory(variant.id),
|
||||
{
|
||||
wrapper: createWrapper(),
|
||||
}
|
||||
)
|
||||
|
||||
await waitFor(() => result.current.isSuccess)
|
||||
|
||||
expect(result.current.response.status).toEqual(200)
|
||||
expect(result.current.variant).toEqual({
|
||||
...variant,
|
||||
sales_channel_availability: [
|
||||
{
|
||||
channel_name: "default channel",
|
||||
channel_id: "1",
|
||||
available_quantity: 10,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user