test: remove snapshots usage (#12516)

* test: remove snapshots usage

* test: remove unneeded assertions

* Create plenty-poems-reply.md

* update tests

* update tests

---------

Co-authored-by: adrien2p <adrien.deperetti@gmail.com>
This commit is contained in:
Harminder Virk
2025-05-16 19:41:01 +05:30
committed by GitHub
parent d73cf66196
commit 5cd4ff6fe7
3 changed files with 431 additions and 509 deletions

View File

@@ -0,0 +1,5 @@
---
"integration-tests-http": patch
---
test: remove snapshots usage

View File

@@ -1,431 +0,0 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[` POST /admin/products/export should export a csv file containing the expected products 1`] = `
[
{
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description
test line 2",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description
test line 2",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "small",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 50,
"Variant Price EUR": 65,
"Variant Price USD": 200,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant 2",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "proposed-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "proposed",
"Product Subtitle": "",
"Product Tag 1": "new-tag",
"Product Tag 2": "",
"Product Thumbnail": "test-image.png",
"Product Title": "Proposed product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
]
`;
exports[` POST /admin/products/export should export a csv file filtered by specific products 1`] = `
[
{
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "proposed-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "proposed",
"Product Subtitle": "",
"Product Tag 1": "new-tag",
"Product Thumbnail": "test-image.png",
"Product Title": "Proposed product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
]
`;
exports[` POST /admin/products/export should export a csv file with categories 1`] = `
[
{
"Product Category 1": "<ID>",
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description
test line 2",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Category 1": "<ID>",
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description
test line 2",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "small",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 50,
"Variant Price EUR": 65,
"Variant Price USD": 200,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant 2",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
]
`;
exports[` POST /admin/products/export should export a csv file with region prices 1`] = `
[
{
"Product Collection Id": "<ID>",
"Product Created At": "<DateTime>",
"Product Deleted At": "<DateTime>",
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": "<ID>",
"Product Handle": "product-with-prices",
"Product Height": "",
"Product Hs Code": "",
"Product Id": "<ID>",
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Product with prices",
"Product Type Id": "<ID>",
"Product Updated At": "<DateTime>",
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": "<DateTime>",
"Variant Deleted At": "<DateTime>",
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": "<ID>",
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price Test Region [USD]": 45,
"Variant Price USD": 100,
"Variant Product Id": "<ID>",
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": "<DateTime>",
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
]
`;

View File

@@ -15,59 +15,6 @@ import { csv2json } from "json-2-csv"
jest.setTimeout(50000)
const EXPORTED_COLUMNS = [
"Product Collection Id",
"Product Created At",
"Product Deleted At",
"Product Description",
"Product Discountable",
"Product External Id",
"Product Handle",
"Product Height",
"Product Hs Code",
"Product Id",
"Product Image *",
"Product Is Giftcard",
"Product Length",
"Product Material",
"Product Mid Code",
"Product Origin Country",
"Product Status",
"Product Subtitle",
"Product Tag *",
"Product Thumbnail",
"Product Title",
"Product Type Id",
"Product Updated At",
"Product Weight",
"Product Width",
"Variant Allow Backorder",
"Variant Barcode",
"Variant Created At",
"Variant Deleted At",
"Variant Ean",
"Variant Height",
"Variant Hs Code",
"Variant Id",
"Variant Length",
"Variant Manage Inventory",
"Variant Material",
"Variant Metadata",
"Variant Mid Code",
"Variant Option * Name",
"Variant Option * Value",
"Variant Origin Country",
"Variant Price [ISO]",
"Variant Product Id",
"Variant Sku",
"Variant Title",
"Variant Upc",
"Variant Updated At",
"Variant Variant Rank",
"Variant Weight",
"Variant Width",
]
const getCSVContents = async (filePath: string) => {
const asLocalPath = filePath.replace("http://localhost:9000", process.cwd())
const fileContent = await fs.readFile(asLocalPath, { encoding: "utf-8" })
@@ -94,22 +41,6 @@ const getCSVContents = async (filePath: string) => {
}, [])
}
const assertExportedColumns = (rows: any[]) => {
rows.forEach((row) => {
EXPORTED_COLUMNS.forEach((column) => {
if (column.includes("[ISO]")) {
expect(
Object.keys(row).filter((rowCol) =>
rowCol.startsWith("Variant Price ")
).length
).toBeGreaterThanOrEqual(1)
} else {
expect(row).toHaveProperty(column.replace("*", "1"))
}
})
})
}
medusaIntegrationTestRunner({
testSuite: ({ dbConnection, getContainer, api }) => {
let baseProduct
@@ -329,8 +260,185 @@ medusaIntegrationTestRunner({
notifications[0].data.file.url
)
assertExportedColumns(exportedFileContents)
expect(exportedFileContents).toMatchSnapshot()
expect(exportedFileContents).toHaveLength(3)
expect(exportedFileContents).toEqual(
expect.arrayContaining([
{
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description\ntest line 2",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description\ntest line 2",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "small",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 50,
"Variant Price EUR": 65,
"Variant Price USD": 200,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant 2",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "proposed-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "proposed",
"Product Subtitle": "",
"Product Tag 1": "new-tag",
"Product Tag 2": "",
"Product Thumbnail": "test-image.png",
"Product Title": "Proposed product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
])
)
})
it("should export a csv file with categories", async () => {
@@ -357,8 +465,129 @@ medusaIntegrationTestRunner({
notifications[0].data.file.url
)
assertExportedColumns(exportedFileContents)
expect(exportedFileContents).toMatchSnapshot()
expect(exportedFileContents).toHaveLength(2)
expect(exportedFileContents).toEqual(
expect.arrayContaining([
{
"Product Category 1": expect.any(String),
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description\ntest line 2",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
{
"Product Category 1": expect.any(String),
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description\ntest line 2",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "base-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Base product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "small",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 50,
"Variant Price EUR": 65,
"Variant Price USD": 200,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant 2",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
])
)
})
it("should export a csv file with region prices", async () => {
@@ -418,9 +647,68 @@ medusaIntegrationTestRunner({
const exportedFileContents = await getCSVContents(
notifications[0].data.file.url
)
assertExportedColumns(exportedFileContents)
expect(exportedFileContents).toMatchSnapshot()
expect(exportedFileContents).toHaveLength(1)
expect(exportedFileContents).toEqual(
expect.arrayContaining([
{
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "product-with-prices",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "draft",
"Product Subtitle": "",
"Product Tag 1": "tag-123",
"Product Tag 2": "tag-456",
"Product Thumbnail": "test-image.png",
"Product Title": "Product with prices",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price Test Region [USD]": 45,
"Variant Price USD": 100,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
])
)
})
it("should export a csv file filtered by specific products", async () => {
@@ -450,8 +738,68 @@ medusaIntegrationTestRunner({
notifications[0].data.file.url
)
assertExportedColumns(exportedFileContents)
expect(exportedFileContents).toMatchSnapshot()
expect(exportedFileContents).toHaveLength(1)
expect(exportedFileContents).toEqual(
expect.arrayContaining([
{
"Product Collection Id": expect.any(String),
"Product Created At": expect.any(String),
"Product Deleted At": expect.any(String),
"Product Description": "test-product-description",
"Product Discountable": true,
"Product External Id": expect.any(String),
"Product Handle": "proposed-product",
"Product Height": "",
"Product Hs Code": "",
"Product Id": expect.any(String),
"Product Image 1": "test-image.png",
"Product Image 2": "test-image-2.png",
"Product Is Giftcard": false,
"Product Length": "",
"Product Material": "",
"Product Mid Code": "",
"Product Origin Country": "",
"Product Status": "proposed",
"Product Subtitle": "",
"Product Tag 1": "new-tag",
"Product Thumbnail": "test-image.png",
"Product Title": "Proposed product",
"Product Type Id": expect.any(String),
"Product Updated At": expect.any(String),
"Product Weight": "",
"Product Width": "",
"Variant Allow Backorder": false,
"Variant Barcode": "",
"Variant Created At": expect.any(String),
"Variant Deleted At": expect.any(String),
"Variant Ean": "",
"Variant Height": "",
"Variant Hs Code": "",
"Variant Id": expect.any(String),
"Variant Length": "",
"Variant Manage Inventory": true,
"Variant Material": "",
"Variant Metadata": "",
"Variant Mid Code": "",
"Variant Option 1 Name": "size",
"Variant Option 1 Value": "large",
"Variant Option 2 Name": "color",
"Variant Option 2 Value": "green",
"Variant Origin Country": "",
"Variant Price DKK": 30,
"Variant Price EUR": 45,
"Variant Price USD": 100,
"Variant Product Id": expect.any(String),
"Variant Sku": "",
"Variant Title": "Test variant",
"Variant Upc": "",
"Variant Updated At": expect.any(String),
"Variant Variant Rank": 0,
"Variant Weight": "",
"Variant Width": "",
},
])
)
})
})
},