fix: Use region name in product pricing exports (#8373)
* fix:Bug fixes to product import * fix:Add an export failed notification if an export fails * fix: Use region name in product export prices
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Product Id,Product Title,Product Subtitle,Product Status,Product External Id,Product Description,Product Handle,Product Is Giftcard,Product Discountable,Product Thumbnail,Product Collection Id,Product Type Id,Product Weight,Product Length,Product Height,Product Width,Product Hs Code,Product Origin Country,Product Mid Code,Product Material,Product Created At,Product Updated At,Product Deleted At,Product Image 1,Product Image 2,Product Tag 1,Product Tag 2,Variant Id,Variant Title,Variant Sku,Variant Barcode,Variant Ean,Variant Upc,Variant Allow Backorder,Variant Manage Inventory,Variant Hs Code,Variant Origin Country,Variant Mid Code,Variant Material,Variant Weight,Variant Length,Variant Height,Variant Width,Variant Metadata,Variant Variant Rank,Variant Product Id,Variant Created At,Variant Updated At,Variant Deleted At,Variant Price USD,Variant Price Test Region [USD],Variant Option 1 Name,Variant Option 1 Value,Variant Option 2 Name,Variant Option 2 Value
|
||||
prod_01J44BH2MFG9MM3EPEQ1SEBDCV,Product with prices,,draft,,test-product-description,product-with-prices,false,true,test-image.png,,,,,,,,,,,2024-07-31T12:16:37.517Z,2024-07-31T12:16:37.517Z,,test-image.png,test-image-2.png,123,456,variant_01J44BH2MXDYM80A5VCAMX17XH,Test variant,,,,,false,true,,,,,,,,,,0,prod_01J44BH2MFG9MM3EPEQ1SEBDCV,2024-07-31T12:16:37.533Z,2024-07-31T12:16:37.533Z,,100,45,size,large,color,green
|
||||
|
@@ -17,6 +17,7 @@ const compareCSVs = async (filePath, expectedFilePath) => {
|
||||
let fixturesContent = await fs.readFile(expectedFilePath, {
|
||||
encoding: "utf-8",
|
||||
})
|
||||
await fs.rm(path.dirname(asLocalPath), { recursive: true, force: true })
|
||||
|
||||
// Normalize csv data to get rid of dynamic data
|
||||
const idsToReplace = ["prod_", "pcol_", "variant_", "ptyp_"]
|
||||
@@ -47,6 +48,7 @@ medusaIntegrationTestRunner({
|
||||
let publishedCollection
|
||||
|
||||
let baseType
|
||||
let baseRegion
|
||||
|
||||
let eventBus: IEventBusModuleService
|
||||
beforeAll(async () => {
|
||||
@@ -56,6 +58,17 @@ medusaIntegrationTestRunner({
|
||||
beforeEach(async () => {
|
||||
await createAdminUser(dbConnection, adminHeaders, getContainer())
|
||||
|
||||
baseRegion = (
|
||||
await api.post(
|
||||
"/admin/regions",
|
||||
{
|
||||
name: "Test region",
|
||||
currency_code: "USD",
|
||||
},
|
||||
adminHeaders
|
||||
)
|
||||
).data.region
|
||||
|
||||
baseCollection = (
|
||||
await api.post(
|
||||
"/admin/collections",
|
||||
@@ -196,10 +209,64 @@ medusaIntegrationTestRunner({
|
||||
notifications[0].data.file.url,
|
||||
path.join(__dirname, "__fixtures__", "exported-products-comma.csv")
|
||||
)
|
||||
await fs.rm(path.dirname(notifications[0].data.file.url), {
|
||||
force: true,
|
||||
recursive: true,
|
||||
})
|
||||
})
|
||||
|
||||
it("should export a csv file with region prices", async () => {
|
||||
const subscriberExecution = TestEventUtils.waitSubscribersExecution(
|
||||
"notification.notification.created",
|
||||
eventBus
|
||||
)
|
||||
|
||||
const productWithRegionPrices = (
|
||||
await api.post(
|
||||
"/admin/products",
|
||||
getProductFixture({
|
||||
title: "Product with prices",
|
||||
variants: [
|
||||
{
|
||||
title: "Test variant",
|
||||
prices: [
|
||||
{
|
||||
currency_code: "usd",
|
||||
amount: 100,
|
||||
},
|
||||
{
|
||||
currency_code: "usd",
|
||||
rules: {
|
||||
region_id: baseRegion.id,
|
||||
},
|
||||
amount: 45,
|
||||
},
|
||||
],
|
||||
options: {
|
||||
size: "large",
|
||||
color: "green",
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
adminHeaders
|
||||
)
|
||||
).data.product
|
||||
|
||||
const batchJobRes = await api.post(
|
||||
"/admin/products/export?id=" + productWithRegionPrices.id,
|
||||
{},
|
||||
adminHeaders
|
||||
)
|
||||
|
||||
const transactionId = batchJobRes.data.transaction_id
|
||||
expect(transactionId).toBeTruthy()
|
||||
|
||||
await subscriberExecution
|
||||
const notifications = (
|
||||
await api.get("/admin/notifications", adminHeaders)
|
||||
).data.notifications
|
||||
|
||||
await compareCSVs(
|
||||
notifications[0].data.file.url,
|
||||
path.join(__dirname, "__fixtures__", "prices-with-region.csv")
|
||||
)
|
||||
})
|
||||
|
||||
it("should export a csv file filtered by specific products", async () => {
|
||||
@@ -229,11 +296,6 @@ medusaIntegrationTestRunner({
|
||||
notifications[0].data.file.url,
|
||||
path.join(__dirname, "__fixtures__", "filtered-products.csv")
|
||||
)
|
||||
|
||||
await fs.rm(path.dirname(notifications[0].data.file.url), {
|
||||
force: true,
|
||||
recursive: true,
|
||||
})
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
@@ -654,7 +654,7 @@ medusaIntegrationTestRunner({
|
||||
title: "Test variant",
|
||||
sku: "test-sku-1-1",
|
||||
barcode: "test-barcode-1-1",
|
||||
allow_backorder: true,
|
||||
allow_backorder: false,
|
||||
manage_inventory: true,
|
||||
prices: [
|
||||
expect.objectContaining({
|
||||
|
||||
Reference in New Issue
Block a user