* add "get-variant" endpoint * import from a different place * fix unit test * add changeset * inventory management for orders * add changeset * initial create-fulfillment * add changeset * type oas and admin * Move inv. creation and listing from admin repo * Fix location editing bug (CORE-1216) * Fix default warehouse on inventory table view * remove actions from each table line * Use feature flag hook instead of context directly * remove manage inventory action if inventory management is not enabled * Address review comments * fix queries made when inventorymodules are disabled * variant form changes for feature enabled * move exclamation icon into warning icon * ensure queries are not run unless feature is enabled for create-fulfillment --------- Co-authored-by: Philip Korsholm <philip.korsholm@hotmail.com> Co-authored-by: Philip Korsholm <88927411+pKorsholm@users.noreply.github.com>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import { useAdminVariant, useAdminVariants, useAdminVariantsInventory } from "../../../../src"
|
|
|
|
import { createWrapper } from "../../../utils"
|
|
import { fixtures } from "../../../../mocks/data"
|
|
import { renderHook } from "@testing-library/react-hooks"
|
|
|
|
describe("useAdminVariants hook", () => {
|
|
test("returns a list of variants", async () => {
|
|
const variants = fixtures.list("product_variant")
|
|
const { result, waitFor } = renderHook(() => useAdminVariants(), {
|
|
wrapper: createWrapper(),
|
|
})
|
|
|
|
await waitFor(() => result.current.isSuccess)
|
|
|
|
expect(result.current.response.status).toEqual(200)
|
|
expect(result.current.variants).toEqual(variants)
|
|
})
|
|
})
|
|
|
|
describe("useAdminVariant hook", () => {
|
|
test("returns a variant", async () => {
|
|
const variant = fixtures.get("product_variant")
|
|
const { result, waitFor } = renderHook(() => useAdminVariant(variant.id), {
|
|
wrapper: createWrapper(),
|
|
})
|
|
|
|
await waitFor(() => result.current.isSuccess)
|
|
|
|
expect(result.current.response.status).toEqual(200)
|
|
expect(result.current.variant).toEqual(variant)
|
|
})
|
|
})
|
|
|
|
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,
|
|
},
|
|
],
|
|
})
|
|
})
|
|
})
|