feat: Implement missing methods in product module and make more tests pass (#6650)
The 2 bigger remaining tasks are: 1. handling prices for variants 2. Handling options (breaking change) After that all tests should pass on both v1 and v2
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils/dist"
|
||||
import productSeeder from "../../../../helpers/product-seeder"
|
||||
import { createDefaultRuleTypes } from "../../../helpers/create-default-rule-types"
|
||||
import { simpleSalesChannelFactory } from "../../../../factories"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
@@ -26,13 +29,13 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, medusaContainer)
|
||||
|
||||
// await productSeeder(dbConnection)
|
||||
// await createDefaultRuleTypes(medusaContainer)
|
||||
// await simpleSalesChannelFactory(dbConnection, {
|
||||
// name: "Default channel",
|
||||
// id: "default-channel",
|
||||
// is_default: true,
|
||||
// })
|
||||
await productSeeder(dbConnection)
|
||||
await createDefaultRuleTypes(medusaContainer)
|
||||
await simpleSalesChannelFactory(dbConnection, {
|
||||
name: "Default channel",
|
||||
id: "default-channel",
|
||||
is_default: true,
|
||||
})
|
||||
})
|
||||
|
||||
describe("POST /admin/products", () => {
|
||||
@@ -40,29 +43,29 @@ medusaIntegrationTestRunner({
|
||||
const payload = {
|
||||
title: "Test",
|
||||
description: "test-product-description",
|
||||
// type: { value: "test-type" },
|
||||
type: { value: "test-type" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
// collection_id: "test-collection",
|
||||
// tags: [{ value: "123" }, { value: "456" }],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
// options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
inventory_quantity: 10,
|
||||
// prices: [
|
||||
// {
|
||||
// currency_code: "usd",
|
||||
// amount: 100,
|
||||
// },
|
||||
// {
|
||||
// currency_code: "eur",
|
||||
// amount: 45,
|
||||
// },
|
||||
// {
|
||||
// currency_code: "dkk",
|
||||
// amount: 30,
|
||||
// },
|
||||
// ],
|
||||
prices: [
|
||||
{
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
},
|
||||
{
|
||||
currency_code: "eur",
|
||||
amount: 45,
|
||||
},
|
||||
{
|
||||
currency_code: "dkk",
|
||||
amount: 30,
|
||||
},
|
||||
],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
@@ -219,16 +222,16 @@ medusaIntegrationTestRunner({
|
||||
title: "Test",
|
||||
discountable: false,
|
||||
description: "test-product-description",
|
||||
// type: { value: "test-type" },
|
||||
type: { value: "test-type" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
// collection_id: "test-collection",
|
||||
// tags: [{ value: "123" }, { value: "456" }],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
// options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
inventory_quantity: 10,
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
@@ -252,22 +255,22 @@ medusaIntegrationTestRunner({
|
||||
const payload = {
|
||||
title: "Test product - 1",
|
||||
description: "test-product-description 1",
|
||||
// type: { value: "test-type 1" },
|
||||
type: { value: "test-type 1" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
// collection_id: "test-collection",
|
||||
// tags: [{ value: "123" }, { value: "456" }],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
// options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant 1",
|
||||
inventory_quantity: 10,
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
{
|
||||
title: "Test variant 2",
|
||||
inventory_quantity: 10,
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
@@ -316,7 +319,7 @@ medusaIntegrationTestRunner({
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "100" }],
|
||||
},
|
||||
],
|
||||
@@ -344,22 +347,22 @@ medusaIntegrationTestRunner({
|
||||
{
|
||||
title: "Test product - 1",
|
||||
description: "test-product-description 1",
|
||||
// type: { value: "test-type 1" },
|
||||
type: { value: "test-type 1" },
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
// collection_id: "test-collection",
|
||||
// tags: [{ value: "123" }, { value: "456" }],
|
||||
collection_id: "test-collection",
|
||||
tags: [{ value: "123" }, { value: "456" }],
|
||||
// options: [{ title: "size" }, { title: "color" }],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant 1",
|
||||
inventory_quantity: 10,
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
{
|
||||
title: "Test variant 2",
|
||||
inventory_quantity: 10,
|
||||
// prices: [{ currency_code: "usd", amount: 100 }],
|
||||
prices: [{ currency_code: "usd", amount: 100 }],
|
||||
// options: [{ value: "large" }, { value: "green" }],
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user