feat: Make tags unique, clean up searchability of product entities (#7014)
This commit is contained in:
@@ -658,8 +658,7 @@ medusaIntegrationTestRunner({
|
||||
}
|
||||
})
|
||||
|
||||
// TODO: Enforce tag uniqueness in product module
|
||||
it.skip("returns a list of products with tags", async () => {
|
||||
it("returns a list of products with tags", async () => {
|
||||
const response = await api.get(
|
||||
`/admin/products?tags[]=${baseProduct.tags[0].id}`,
|
||||
adminHeaders
|
||||
@@ -668,26 +667,25 @@ medusaIntegrationTestRunner({
|
||||
expect(response.status).toEqual(200)
|
||||
expect(response.data.products).toHaveLength(2)
|
||||
expect(response.data.products).toEqual(
|
||||
expect.arrayContaining(
|
||||
[
|
||||
expect.objectContaining({
|
||||
id: baseProduct.id,
|
||||
tags: [
|
||||
expect.objectContaining({ id: baseProduct.tags[0].id }),
|
||||
],
|
||||
}),
|
||||
],
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: baseProduct.id,
|
||||
tags: expect.arrayContaining([
|
||||
expect.objectContaining({ id: baseProduct.tags[0].id }),
|
||||
]),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: publishedProduct.id,
|
||||
// It should be the same tag instance in both products
|
||||
tags: [expect.objectContaining({ id: baseProduct.tags[0].id })],
|
||||
})
|
||||
)
|
||||
tags: expect.arrayContaining([
|
||||
expect.objectContaining({ id: baseProduct.tags[0].id }),
|
||||
]),
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
// TODO: Enforce tag uniqueness in product module
|
||||
it.skip("returns a list of products with tags in a collection", async () => {
|
||||
it("returns a list of products with tags in a collection", async () => {
|
||||
const response = await api.get(
|
||||
`/admin/products?collection_id[]=${baseCollection.id}&tags[]=${baseProduct.tags[0].id}`,
|
||||
adminHeaders
|
||||
@@ -700,7 +698,9 @@ medusaIntegrationTestRunner({
|
||||
expect.objectContaining({
|
||||
id: baseProduct.id,
|
||||
collection_id: baseCollection.id,
|
||||
tags: [expect.objectContaining({ id: baseProduct.tags[0].id })],
|
||||
tags: expect.arrayContaining([
|
||||
expect.objectContaining({ id: baseProduct.tags[0].id }),
|
||||
]),
|
||||
}),
|
||||
])
|
||||
)
|
||||
@@ -2655,8 +2655,7 @@ medusaIntegrationTestRunner({
|
||||
expect(response2.data.id).toEqual(res.data.product.id)
|
||||
})
|
||||
|
||||
// TODO: We just need to return the correct error message
|
||||
it.skip("should fail when creating a product with a handle that already exists", async () => {
|
||||
it("should fail when creating a product with a handle that already exists", async () => {
|
||||
// Lets try to create a product with same handle as deleted one
|
||||
const payload = {
|
||||
title: baseProduct.title,
|
||||
@@ -2675,7 +2674,10 @@ medusaIntegrationTestRunner({
|
||||
await api.post("/admin/products", payload, adminHeaders)
|
||||
} catch (error) {
|
||||
expect(error.response.data.message).toMatch(
|
||||
"Product with handle test-product already exists."
|
||||
breaking(
|
||||
() => "Product with handle base-product already exists.",
|
||||
() => "Product with handle: base-product already exists."
|
||||
)
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user