Skip to content

Commit

Permalink
chore: Move fixture inside module test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl committed Mar 22, 2024
1 parent fd4204d commit ed840b4
Showing 1 changed file with 49 additions and 44 deletions.
93 changes: 49 additions & 44 deletions integration-tests/api/__tests__/admin/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,50 +32,8 @@ let {

jest.setTimeout(50000)

const productFixture = {
title: "Test fixture",
description: "test-product-description",
type: { value: "test-type" },
images: ["test-image.png", "test-image-2.png"],
tags: [{ value: "123" }, { value: "456" }],
options: breaking(
() => [{ title: "size" }, { title: "color" }],
() => [
{ title: "size", values: ["large"] },
{ title: "color", values: ["green"] },
]
),
variants: [
{
title: "Test variant",
inventory_quantity: 10,
prices: [
{
currency_code: "usd",
amount: 100,
},
{
currency_code: "eur",
amount: 45,
},
{
currency_code: "dkk",
amount: 30,
},
],
options: breaking(
() => [{ value: "large" }, { value: "green" }],
() => ({
size: "large",
color: "green",
})
),
},
],
}

medusaIntegrationTestRunner({
env: { MEDUSA_FF_PRODUCT_CATEGORIES: true },
env: { MEDUSA_FF_PRODUCT_CATEGORIES: true, MEDUSA_FF_MEDUSA_V2: true },
testSuite: ({ dbConnection, getContainer, api }) => {
let v2Product
let pricingService
Expand Down Expand Up @@ -110,6 +68,48 @@ medusaIntegrationTestRunner({
container = getContainer()
await createAdminUser(dbConnection, adminHeaders, container)

const productFixture = {
title: "Test fixture",
description: "test-product-description",
type: { value: "test-type" },
images: ["test-image.png", "test-image-2.png"],
tags: [{ value: "123" }, { value: "456" }],
options: breaking(
() => [{ title: "size" }, { title: "color" }],
() => [
{ title: "size", values: ["large"] },
{ title: "color", values: ["green"] },
]
),
variants: [
{
title: "Test variant",
inventory_quantity: 10,
prices: [
{
currency_code: "usd",
amount: 100,
},
{
currency_code: "eur",
amount: 45,
},
{
currency_code: "dkk",
amount: 30,
},
],
options: breaking(
() => [{ value: "large" }, { value: "green" }],
() => ({
size: "large",
color: "green",
})
),
},
],
}

// We want to seed another product for v2 that has pricing correctly wired up for all pricing-related tests.
v2Product = (
await breaking(
Expand Down Expand Up @@ -1190,14 +1190,19 @@ medusaIntegrationTestRunner({
])
})

it("should return products filtered by sales_channel_id", async () => {
it.only("should return products filtered by sales_channel_id", async () => {
const { salesChannel, product } = await breaking(
async () => {
const product = await simpleProductFactory(dbConnection, {
id: "product_1",
title: "test title",
})

await simpleProductFactory(dbConnection, {
id: "product_2",
title: "test title 2",
})

const salesChannel = await simpleSalesChannelFactory(
dbConnection,
{
Expand Down

0 comments on commit ed840b4

Please sign in to comment.