fix: add metadata to collection resp (#9514)

**What**
- Adds `metadata` to the default response for `/admin/collection` endpoints.
- Fixes tests to expect correct shape and not use objectContaining.

Fixes CC-551
This commit is contained in:
Sebastian Rindom
2024-10-09 17:52:59 +02:00
committed by GitHub
parent 0e11e89233
commit aeaedc8539
2 changed files with 42 additions and 27 deletions

View File

@@ -77,17 +77,16 @@ medusaIntegrationTestRunner({
)
expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
})
)
expect(response.data).toEqual({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "New collection",
handle: "test-new-collection",
created_at: expect.any(String),
updated_at: expect.any(String),
metadata: null,
},
})
})
it("lists collections", async () => {
@@ -96,22 +95,33 @@ medusaIntegrationTestRunner({
expect(response.data).toEqual(
expect.objectContaining({
count: 3,
limit: 10,
offset: 0,
collections: expect.arrayContaining([
expect.objectContaining({
id: baseCollection2.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
id: baseCollection1.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
expect.objectContaining({
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection",
metadata: null,
title: "test-collection",
},
{
id: baseCollection1.id,
created_at: expect.any(String),
updated_at: expect.any(String),
handle: "test-collection1",
metadata: null,
title: "test-collection1",
},
{
id: baseCollection2.id,
created_at: expect.any(String),
updated_at: expect.any(String),
handle: "test-collection2",
metadata: null,
title: "test-collection2",
},
]),
})
)
@@ -127,11 +137,14 @@ medusaIntegrationTestRunner({
expect.objectContaining({
count: 1,
collections: expect.arrayContaining([
expect.objectContaining({
{
id: baseCollection.id,
created_at: expect.any(String),
updated_at: expect.any(String),
}),
handle: "test-collection",
metadata: null,
title: "test-collection",
},
]),
})
)
@@ -154,13 +167,14 @@ medusaIntegrationTestRunner({
expect(response.status).toEqual(200)
expect(response.data).toEqual(
expect.objectContaining({
collection: expect.objectContaining({
collection: {
id: expect.stringMatching(/^pcol_*/),
title: "test collection creation",
handle: "test-handle-creation",
created_at: expect.any(String),
updated_at: expect.any(String),
}),
metadata: null,
},
})
)
})

View File

@@ -4,6 +4,7 @@ export const defaultAdminCollectionFields = [
"handle",
"created_at",
"updated_at",
"metadata",
]
export const retrieveTransformQueryConfig = {