feat: Add batch method to collection and clean up some batch implementations (#7102)

This commit is contained in:
Stevche Radevski
2024-04-22 10:36:22 +02:00
committed by GitHub
parent 0f5b015df0
commit 89143e1032
26 changed files with 425 additions and 123 deletions

View File

@@ -2844,7 +2844,7 @@ medusaIntegrationTestRunner({
}
const response = await api.post(
"/admin/products/op/batch",
"/admin/products/batch",
{
create: [createPayload],
update: [updatePayload],
@@ -2952,7 +2952,7 @@ medusaIntegrationTestRunner({
}
const response = await api.post(
`/admin/products/${createdProduct.id}/variants/op/batch`,
`/admin/products/${createdProduct.id}/variants/batch`,
{
create: [createPayload],
update: [updatePayload],
@@ -2983,6 +2983,40 @@ medusaIntegrationTestRunner({
}
)
})
it("successfully adds and removes products to a collection", async () => {
await breaking(
() => {},
async () => {
const response = await api.post(
`/admin/collections/${baseCollection.id}/products`,
{
add: [publishedProduct.id],
remove: [baseProduct.id],
},
adminHeaders
)
expect(response.status).toEqual(200)
expect(response.data.added).toHaveLength(1)
expect(response.data.removed).toHaveLength(1)
const collection = (
await api.get(
`/admin/collections/${baseCollection.id}?fields=*products`,
adminHeaders
)
).data.collection
expect(collection.products).toHaveLength(1)
expect(collection.products[0]).toEqual(
expect.objectContaining({
id: publishedProduct.id,
})
)
}
)
})
})
// TODO: Discuss how this should be handled