From 5cd4ff6fe75c6be4ac33820a2e22654fc2508b4e Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Fri, 16 May 2025 19:41:01 +0530 Subject: [PATCH] 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 --- .changeset/plenty-poems-reply.md | 5 + .../__snapshots__/product-export.spec.ts.snap | 431 --------------- .../product/admin/product-export.spec.ts | 504 +++++++++++++++--- 3 files changed, 431 insertions(+), 509 deletions(-) create mode 100644 .changeset/plenty-poems-reply.md delete mode 100644 integration-tests/http/__tests__/product/admin/__snapshots__/product-export.spec.ts.snap diff --git a/.changeset/plenty-poems-reply.md b/.changeset/plenty-poems-reply.md new file mode 100644 index 0000000000..3f9c785a75 --- /dev/null +++ b/.changeset/plenty-poems-reply.md @@ -0,0 +1,5 @@ +--- +"integration-tests-http": patch +--- + +test: remove snapshots usage diff --git a/integration-tests/http/__tests__/product/admin/__snapshots__/product-export.spec.ts.snap b/integration-tests/http/__tests__/product/admin/__snapshots__/product-export.spec.ts.snap deleted file mode 100644 index e556622132..0000000000 --- a/integration-tests/http/__tests__/product/admin/__snapshots__/product-export.spec.ts.snap +++ /dev/null @@ -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": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description -test line 2", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "base-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant", - "Variant Upc": "", - "Variant Updated At": "", - "Variant Variant Rank": 0, - "Variant Weight": "", - "Variant Width": "", - }, - { - "Product Collection Id": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description -test line 2", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "base-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant 2", - "Variant Upc": "", - "Variant Updated At": "", - "Variant Variant Rank": 0, - "Variant Weight": "", - "Variant Width": "", - }, - { - "Product Collection Id": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "proposed-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant", - "Variant Upc": "", - "Variant Updated At": "", - "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": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "proposed-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant", - "Variant Upc": "", - "Variant Updated At": "", - "Variant Variant Rank": 0, - "Variant Weight": "", - "Variant Width": "", - }, -] -`; - -exports[` POST /admin/products/export should export a csv file with categories 1`] = ` -[ - { - "Product Category 1": "", - "Product Collection Id": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description -test line 2", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "base-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant", - "Variant Upc": "", - "Variant Updated At": "", - "Variant Variant Rank": 0, - "Variant Weight": "", - "Variant Width": "", - }, - { - "Product Category 1": "", - "Product Collection Id": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description -test line 2", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "base-product", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant 2", - "Variant Upc": "", - "Variant Updated At": "", - "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": "", - "Product Created At": "", - "Product Deleted At": "", - "Product Description": "test-product-description", - "Product Discountable": true, - "Product External Id": "", - "Product Handle": "product-with-prices", - "Product Height": "", - "Product Hs Code": "", - "Product 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": "", - "Product Updated At": "", - "Product Weight": "", - "Product Width": "", - "Variant Allow Backorder": false, - "Variant Barcode": "", - "Variant Created At": "", - "Variant Deleted At": "", - "Variant Ean": "", - "Variant Height": "", - "Variant Hs Code": "", - "Variant 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": "", - "Variant Sku": "", - "Variant Title": "Test variant", - "Variant Upc": "", - "Variant Updated At": "", - "Variant Variant Rank": 0, - "Variant Weight": "", - "Variant Width": "", - }, -] -`; diff --git a/integration-tests/http/__tests__/product/admin/product-export.spec.ts b/integration-tests/http/__tests__/product/admin/product-export.spec.ts index ce46bd63af..bab6279ee7 100644 --- a/integration-tests/http/__tests__/product/admin/product-export.spec.ts +++ b/integration-tests/http/__tests__/product/admin/product-export.spec.ts @@ -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": "", + }, + ]) + ) }) }) },