From 7ec174309adfe7b4687aa2b979c6f582025dc5b0 Mon Sep 17 00:00:00 2001 From: Sebastian Rindom Date: Wed, 9 Oct 2024 16:22:51 +0200 Subject: [PATCH] fix: add metadata to product type resp (#9515) --- .../product-type/admin/product-type.spec.ts | 42 ++++++++++++++++--- .../api/admin/product-types/query-config.ts | 1 + 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/integration-tests/http/__tests__/product-type/admin/product-type.spec.ts b/integration-tests/http/__tests__/product-type/admin/product-type.spec.ts index 654b3d60a3..21dca450fe 100644 --- a/integration-tests/http/__tests__/product-type/admin/product-type.spec.ts +++ b/integration-tests/http/__tests__/product-type/admin/product-type.spec.ts @@ -44,12 +44,20 @@ medusaIntegrationTestRunner({ expect(res.status).toEqual(200) expect(res.data.product_types).toEqual( expect.arrayContaining([ - expect.objectContaining({ + { + id: expect.stringMatching(/ptyp_.{24}/), value: "test1", - }), - expect.objectContaining({ + created_at: expect.any(String), + updated_at: expect.any(String), + metadata: null, + }, + { + id: expect.stringMatching(/ptyp_.{24}/), value: "test2", - }), + created_at: expect.any(String), + updated_at: expect.any(String), + metadata: null, + }, ]) ) }) @@ -61,13 +69,35 @@ medusaIntegrationTestRunner({ // The value of the type should match the search param expect(res.data.product_types).toEqual([ - expect.objectContaining({ + { + id: expect.stringMatching(/ptyp_.{24}/), value: "test1", - }), + created_at: expect.any(String), + updated_at: expect.any(String), + metadata: null, + }, ]) }) // BREAKING: Removed a test around filtering based on discount condition id, which is no longer supported }) + + describe("/admin/product-types/:id", () => { + it("returns a product type", async () => { + const res = await api.get( + `/admin/product-types/${type1.id}`, + adminHeaders + ) + + expect(res.status).toEqual(200) + expect(res.data.product_type).toEqual({ + id: expect.stringMatching(/ptyp_.{24}/), + value: "test1", + created_at: expect.any(String), + updated_at: expect.any(String), + metadata: null, + }) + }) + }) }, }) diff --git a/packages/medusa/src/api/admin/product-types/query-config.ts b/packages/medusa/src/api/admin/product-types/query-config.ts index f05f9378fa..ed795fe8f9 100644 --- a/packages/medusa/src/api/admin/product-types/query-config.ts +++ b/packages/medusa/src/api/admin/product-types/query-config.ts @@ -3,6 +3,7 @@ export const defaultAdminProductTypeFields = [ "value", "created_at", "updated_at", + "metadata", ] export const retrieveProductTypeTransformQueryConfig = {