chore: Remove typeORM (#9005)
* chore: rename js files to txt * chore: rename ts files to txt * chore: delete environment helpers * chore: convert global setup & teardown to txt * chore: rename helper js/ts files to txt * chore: rename seeder js/ts files to txt * chore: remove typeorm * chore: reintroduce used helpers
This commit is contained in:
-211
@@ -1,211 +0,0 @@
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
simpleProductFactory,
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
"x-medusa-access-token": "test_token",
|
||||
},
|
||||
}
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: true,
|
||||
}
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe.skip("POST /admin/price-lists/:id/prices/batch", () => {
|
||||
let appContainer
|
||||
let product
|
||||
let variant
|
||||
let pricingModuleService: IPricingModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
pricingModuleService = appContainer.resolve("pricingModuleService")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
product = await simpleProductFactory(dbConnection, {
|
||||
id: "test-product-with-variant",
|
||||
variants: [
|
||||
{
|
||||
options: [{ option_id: "test-product-option-1", value: "test" }],
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-product-option-1",
|
||||
title: "Test option 1",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
variant = product.variants[0]
|
||||
})
|
||||
|
||||
it("should update money amounts if variant id is present in prices", async () => {
|
||||
const [priceList] = await pricingModuleService.createPriceLists([
|
||||
{
|
||||
title: "test price list",
|
||||
description: "test",
|
||||
ends_at: new Date().toISOString(),
|
||||
starts_at: new Date().toISOString(),
|
||||
status: PriceListStatus.ACTIVE,
|
||||
type: PriceListType.OVERRIDE,
|
||||
},
|
||||
])
|
||||
|
||||
await createVariantPriceSet({
|
||||
container: appContainer,
|
||||
variantId: variant.id,
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const data = {
|
||||
prices: [
|
||||
{
|
||||
variant_id: variant.id,
|
||||
amount: 5000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
{
|
||||
amount: 6000,
|
||||
region_id: "test-region",
|
||||
variant_id: variant.id,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
await api.post(
|
||||
`admin/price-lists/${priceList.id}/prices/batch`,
|
||||
data,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const response = await api.get(
|
||||
`/admin/price-lists/${priceList.id}`,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.price_list).toEqual(
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
name: "test price list",
|
||||
description: "test",
|
||||
type: "override",
|
||||
status: "active",
|
||||
starts_at: expect.any(String),
|
||||
ends_at: expect.any(String),
|
||||
customer_groups: [],
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
currency_code: "usd",
|
||||
amount: 5000,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
price_list_id: expect.any(String),
|
||||
region_id: null,
|
||||
variant: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
title: expect.any(String),
|
||||
product_id: expect.any(String),
|
||||
sku: null,
|
||||
barcode: null,
|
||||
ean: null,
|
||||
upc: null,
|
||||
variant_rank: 0,
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
manage_inventory: true,
|
||||
hs_code: null,
|
||||
origin_country: null,
|
||||
mid_code: null,
|
||||
material: null,
|
||||
weight: null,
|
||||
length: null,
|
||||
height: null,
|
||||
width: null,
|
||||
metadata: null,
|
||||
}),
|
||||
variant_id: expect.any(String),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
currency_code: "usd",
|
||||
amount: 6000,
|
||||
min_quantity: null,
|
||||
max_quantity: null,
|
||||
price_list_id: expect.any(String),
|
||||
region_id: "test-region",
|
||||
variant: expect.objectContaining({
|
||||
id: expect.any(String),
|
||||
created_at: expect.any(String),
|
||||
updated_at: expect.any(String),
|
||||
deleted_at: null,
|
||||
title: expect.any(String),
|
||||
product_id: expect.any(String),
|
||||
sku: null,
|
||||
barcode: null,
|
||||
ean: null,
|
||||
upc: null,
|
||||
variant_rank: 0,
|
||||
inventory_quantity: 10,
|
||||
allow_backorder: false,
|
||||
manage_inventory: true,
|
||||
hs_code: null,
|
||||
origin_country: null,
|
||||
mid_code: null,
|
||||
material: null,
|
||||
weight: null,
|
||||
length: null,
|
||||
height: null,
|
||||
width: null,
|
||||
metadata: null,
|
||||
}),
|
||||
variant_id: expect.any(String),
|
||||
}),
|
||||
],
|
||||
})
|
||||
)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
import {
|
||||
simpleProductFactory,
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
"x-medusa-access-token": "test_token",
|
||||
},
|
||||
}
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: true,
|
||||
}
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe.skip("DELETE /admin/price-lists/:id/products/:productId/batch", () => {
|
||||
let appContainer
|
||||
let product
|
||||
let variant1
|
||||
let priceSet
|
||||
let priceListId
|
||||
let pricingModuleService: IPricingModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
pricingModuleService = appContainer.resolve("pricingModuleService")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
product = await simpleProductFactory(dbConnection, {
|
||||
id: "test-product-with-variant",
|
||||
variants: [
|
||||
{
|
||||
options: [{ option_id: "test-product-option-1", value: "test" }],
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-product-option-1",
|
||||
title: "Test option 1",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
variant1 = product.variants[0]
|
||||
|
||||
priceSet = await createVariantPriceSet({
|
||||
container: appContainer,
|
||||
variantId: variant1.id,
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const data = {
|
||||
name: "test price list",
|
||||
description: "test",
|
||||
type: "override",
|
||||
customer_groups: [],
|
||||
status: "active",
|
||||
prices: [
|
||||
{
|
||||
amount: 400,
|
||||
variant_id: variant1.id,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const priceListResult = await api.post(
|
||||
`admin/price-lists`,
|
||||
data,
|
||||
adminHeaders
|
||||
)
|
||||
priceListId = priceListResult.data.price_list.id
|
||||
})
|
||||
|
||||
it("should delete prices in batch based on product ids", async () => {
|
||||
let prices = await pricingModuleService.listPrices({
|
||||
price_set_id: [priceSet.id],
|
||||
})
|
||||
expect(prices.length).toEqual(2)
|
||||
|
||||
const deleteRes = await api.delete(
|
||||
`/admin/price-lists/${priceListId}/products/prices/batch`,
|
||||
{
|
||||
headers: adminHeaders.headers,
|
||||
data: {
|
||||
product_ids: [product.id],
|
||||
},
|
||||
}
|
||||
)
|
||||
expect(deleteRes.status).toEqual(200)
|
||||
|
||||
prices = await pricingModuleService.listPrices({
|
||||
price_set_id: [priceSet.id],
|
||||
})
|
||||
|
||||
expect(prices.length).toEqual(1)
|
||||
expect(prices).toEqual([
|
||||
expect.objectContaining({
|
||||
price_list: null,
|
||||
}),
|
||||
])
|
||||
})
|
||||
|
||||
it("should delete prices based on single product id", async () => {
|
||||
let prices = await pricingModuleService.listPrices({
|
||||
price_set_id: [priceSet.id],
|
||||
})
|
||||
expect(prices.length).toEqual(2)
|
||||
|
||||
const deleteRes = await api.delete(
|
||||
`/admin/price-lists/${priceListId}/products/${product.id}/prices`,
|
||||
adminHeaders
|
||||
)
|
||||
expect(deleteRes.status).toEqual(200)
|
||||
|
||||
prices = await pricingModuleService.listPrices({
|
||||
price_set_id: [priceSet.id],
|
||||
})
|
||||
|
||||
expect(prices.length).toEqual(1)
|
||||
expect(prices).toEqual([
|
||||
expect.objectContaining({
|
||||
price_list: null,
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
-113
@@ -1,113 +0,0 @@
|
||||
import {
|
||||
simpleProductFactory,
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
"x-medusa-access-token": "test_token",
|
||||
},
|
||||
}
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: true,
|
||||
}
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe.skip("DELETE /admin/price-lists/:id/variants/:variantId/prices", () => {
|
||||
let appContainer
|
||||
let product
|
||||
let variant
|
||||
let pricingModuleService: IPricingModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
pricingModuleService = appContainer.resolve("pricingModuleService")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
product = await simpleProductFactory(dbConnection, {
|
||||
id: "test-product-with-variant",
|
||||
variants: [
|
||||
{
|
||||
options: [{ option_id: "test-product-option-1", value: "test" }],
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-product-option-1",
|
||||
title: "Test option 1",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
variant = product.variants[0]
|
||||
})
|
||||
|
||||
it("should delete all prices based on product variant ids", async () => {
|
||||
const priceSet = await createVariantPriceSet({
|
||||
container: appContainer,
|
||||
variantId: variant.id,
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const data = {
|
||||
name: "test price list",
|
||||
description: "test",
|
||||
type: "override",
|
||||
customer_groups: [],
|
||||
status: "active",
|
||||
prices: [
|
||||
{
|
||||
amount: 400,
|
||||
variant_id: variant.id,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const result = await api.post(`admin/price-lists`, data, adminHeaders)
|
||||
const priceListId = result.data.price_list.id
|
||||
|
||||
let prices = await pricingModuleService.listPrices({
|
||||
price_list_id: [priceListId],
|
||||
})
|
||||
expect(prices.length).toEqual(1)
|
||||
|
||||
const deleteRes = await api.delete(
|
||||
`/admin/price-lists/${priceListId}/variants/${variant.id}/prices`,
|
||||
adminHeaders
|
||||
)
|
||||
expect(deleteRes.status).toEqual(200)
|
||||
|
||||
prices = await pricingModuleService.listPrices({
|
||||
price_list_id: [priceListId],
|
||||
})
|
||||
expect(prices.length).toEqual(0)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -1,127 +0,0 @@
|
||||
import {
|
||||
simpleProductFactory,
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
|
||||
import { IPricingModuleService } from "@medusajs/types"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
"x-medusa-access-token": "test_token",
|
||||
},
|
||||
}
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: true,
|
||||
}
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe.skip("DELETE /admin/price-lists/:id", () => {
|
||||
let appContainer
|
||||
let product
|
||||
let variant
|
||||
let pricingModuleService: IPricingModuleService
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
pricingModuleService = appContainer.resolve("pricingModuleService")
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
|
||||
product = await simpleProductFactory(dbConnection, {
|
||||
id: "test-product-with-variant",
|
||||
variants: [
|
||||
{
|
||||
options: [{ option_id: "test-product-option-1", value: "test" }],
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-product-option-1",
|
||||
title: "Test option 1",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
variant = product.variants[0]
|
||||
})
|
||||
|
||||
it("should delete price list prices by money amount ids", async () => {
|
||||
await createVariantPriceSet({
|
||||
container: appContainer,
|
||||
variantId: variant.id,
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const data = {
|
||||
name: "test price list",
|
||||
description: "test",
|
||||
type: "override",
|
||||
status: "active",
|
||||
prices: [
|
||||
{
|
||||
amount: 400,
|
||||
variant_id: variant.id,
|
||||
currency_code: "usd",
|
||||
},
|
||||
{
|
||||
amount: 4000,
|
||||
variant_id: variant.id,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const res = await api.post(`admin/price-lists`, data, adminHeaders)
|
||||
|
||||
const priceListId = res.data.price_list.id
|
||||
let prices = await pricingModuleService.listPrices(
|
||||
{
|
||||
price_list_id: [priceListId],
|
||||
},
|
||||
{}
|
||||
)
|
||||
|
||||
expect(prices.length).toEqual(2)
|
||||
|
||||
const deletePrice = prices[0]
|
||||
const deleteRes = await api.delete(
|
||||
`/admin/price-lists/${priceListId}/prices/batch`,
|
||||
{
|
||||
data: {
|
||||
price_ids: [deletePrice?.id],
|
||||
},
|
||||
...adminHeaders,
|
||||
}
|
||||
)
|
||||
expect(deleteRes.status).toEqual(200)
|
||||
|
||||
prices = await pricingModuleService.listPrices({
|
||||
price_list_id: [priceListId],
|
||||
})
|
||||
expect(prices.length).toEqual(1)
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -1,13 +1,7 @@
|
||||
import { PriceListStatus, PriceListType } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import {
|
||||
simpleCustomerFactory,
|
||||
simpleCustomerGroupFactory,
|
||||
simpleProductFactory,
|
||||
simpleRegionFactory,
|
||||
} from "../../../../factories"
|
||||
import { createAdminUser } from "../../../../helpers/create-admin-user"
|
||||
import { createVariantPriceSet } from "../../../helpers/create-variant-price-set"
|
||||
import { getProductFixture } from "../../../../helpers/fixtures"
|
||||
|
||||
jest.setTimeout(50000)
|
||||
|
||||
@@ -28,7 +22,7 @@ medusaIntegrationTestRunner({
|
||||
let appContainer
|
||||
let product
|
||||
let variant
|
||||
let priceSetId
|
||||
let region
|
||||
|
||||
beforeAll(async () => {
|
||||
appContainer = getContainer()
|
||||
@@ -37,48 +31,40 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, appContainer)
|
||||
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "test-region",
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
tax_rate: 0,
|
||||
})
|
||||
region = (
|
||||
await api.post(
|
||||
"/admin/regions",
|
||||
{
|
||||
name: "Test Region",
|
||||
currency_code: "usd",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.region
|
||||
|
||||
product = await simpleProductFactory(dbConnection, {
|
||||
id: "test-product-with-variant",
|
||||
status: "published",
|
||||
variants: [
|
||||
{
|
||||
options: [{ option_id: "test-product-option-1", value: "test" }],
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
id: "test-product-option-1",
|
||||
title: "Test option 1",
|
||||
},
|
||||
],
|
||||
})
|
||||
product = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
getProductFixture({
|
||||
title: "test1",
|
||||
status: "published",
|
||||
variants: [
|
||||
{
|
||||
title: "Test taxes",
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "eur",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}),
|
||||
adminHeaders
|
||||
)
|
||||
).data.product
|
||||
|
||||
variant = product.variants[0]
|
||||
|
||||
const priceSet = await createVariantPriceSet({
|
||||
container: appContainer,
|
||||
variantId: variant.id,
|
||||
prices: [
|
||||
{
|
||||
amount: 3000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
{
|
||||
amount: 4000,
|
||||
currency_code: "usd",
|
||||
},
|
||||
],
|
||||
rules: [],
|
||||
})
|
||||
|
||||
priceSetId = priceSet.id
|
||||
})
|
||||
|
||||
it("should get product and its prices from price-list created through the price list workflow", async () => {
|
||||
@@ -132,9 +118,16 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should not list prices from price-list with customer groups if not logged in", async () => {
|
||||
const { id: customerGroupId } = await simpleCustomerGroupFactory(
|
||||
dbConnection
|
||||
)
|
||||
const customerGroup = (
|
||||
await api.post(
|
||||
"/admin/customer-groups",
|
||||
{
|
||||
name: "VIP",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.customer_group
|
||||
const customerGroupId = customerGroup.id
|
||||
|
||||
const priceListResponse = await api.post(
|
||||
`/admin/price-lists`,
|
||||
@@ -179,16 +172,17 @@ medusaIntegrationTestRunner({
|
||||
})
|
||||
|
||||
it("should list prices from price-list with customer groups", async () => {
|
||||
await simpleCustomerFactory(dbConnection, {
|
||||
id: "test-customer-5-pl",
|
||||
email: "test5@email-pl.com",
|
||||
first_name: "John",
|
||||
last_name: "Deere",
|
||||
password_hash:
|
||||
"c2NyeXB0AAEAAAABAAAAAVMdaddoGjwU1TafDLLlBKnOTQga7P2dbrfgf3fB+rCD/cJOMuGzAvRdKutbYkVpuJWTU39P7OpuWNkUVoEETOVLMJafbI8qs8Qx/7jMQXkN", // password matching "test"
|
||||
has_account: true,
|
||||
groups: [{ id: "customer-group-1" }],
|
||||
})
|
||||
const customer = (
|
||||
await api.post(
|
||||
"/admin/customers",
|
||||
{
|
||||
email: "test5@email-pl.com",
|
||||
first_name: "John",
|
||||
last_name: "Deere",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.customer_group
|
||||
|
||||
const authResponse = await api.post("/store/auth", {
|
||||
email: "test5@email-pl.com",
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
import { simpleCartFactory, simpleRegionFactory } from "../../../factories"
|
||||
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { medusaIntegrationTestRunner } from "medusa-test-utils"
|
||||
import { createAdminUser } from "../../../helpers/create-admin-user"
|
||||
|
||||
jest.setTimeout(5000000)
|
||||
|
||||
const DB_HOST = process.env.DB_HOST
|
||||
const DB_USERNAME = process.env.DB_USERNAME
|
||||
const DB_PASSWORD = process.env.DB_PASSWORD
|
||||
const DB_NAME = process.env.DB_TEMP_NAME
|
||||
const DB_URL = `postgres://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}`
|
||||
|
||||
const adminHeaders = {
|
||||
headers: {
|
||||
"x-medusa-access-token": "test_token",
|
||||
},
|
||||
}
|
||||
|
||||
const env = {
|
||||
MEDUSA_FF_MEDUSA_V2: true,
|
||||
}
|
||||
|
||||
medusaIntegrationTestRunner({
|
||||
env,
|
||||
testSuite: ({ dbConnection, getContainer, api }) => {
|
||||
describe.skip("Link Modules", () => {
|
||||
let medusaContainer
|
||||
|
||||
beforeAll(async () => {
|
||||
medusaContainer = getContainer()
|
||||
})
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, medusaContainer)
|
||||
await simpleRegionFactory(dbConnection, {
|
||||
id: "region-1",
|
||||
currency_code: "usd",
|
||||
})
|
||||
})
|
||||
|
||||
describe("get product price", () => {
|
||||
let ruleType
|
||||
let priceSet
|
||||
let productId
|
||||
const cartId = "test-cart"
|
||||
beforeEach(async () => {
|
||||
const pricingModuleService = medusaContainer.resolve(
|
||||
ModuleRegistrationName.PRICING
|
||||
)
|
||||
|
||||
await simpleCartFactory(dbConnection, {
|
||||
id: cartId,
|
||||
region: "region-1",
|
||||
})
|
||||
|
||||
const payload = {
|
||||
title: "Test",
|
||||
description: "test-product-description",
|
||||
images: ["test-image.png", "test-image-2.png"],
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
prices: [],
|
||||
options: [],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const response = await api.post(
|
||||
"/admin/products",
|
||||
payload,
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
productId = response.data.product.id
|
||||
const variant = response.data.product.variants[0]
|
||||
|
||||
priceSet = await pricingModuleService.createPriceSets({
|
||||
prices: [
|
||||
{
|
||||
amount: 1000,
|
||||
currency_code: "usd",
|
||||
rules: { region_id: "region-1" },
|
||||
},
|
||||
{
|
||||
amount: 900,
|
||||
currency_code: "usd",
|
||||
rules: { region_id: "region-2" },
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const remoteLink = medusaContainer.resolve("remoteLink") as any
|
||||
|
||||
await remoteLink.create({
|
||||
productService: {
|
||||
variant_id: variant.id,
|
||||
},
|
||||
pricingService: {
|
||||
price_set_id: priceSet.id,
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it("Should get prices declared in pricing module", async () => {
|
||||
const response = await api.get(
|
||||
`/store/products/${productId}?cart_id=${cartId}`
|
||||
)
|
||||
|
||||
expect(response.data.product.variants[0].prices).toEqual([
|
||||
expect.objectContaining({
|
||||
amount: 1000,
|
||||
currency_code: "usd",
|
||||
}),
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -32,8 +32,7 @@
|
||||
"@medusajs/workflow-engine-inmemory": "workspace:*",
|
||||
"faker": "^5.5.3",
|
||||
"medusa-test-utils": "workspace:*",
|
||||
"pg": "^8.11.3",
|
||||
"typeorm": "^0.3.16"
|
||||
"pg": "^8.11.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/types": "workspace:^",
|
||||
|
||||
Reference in New Issue
Block a user